using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using BLL; using BLL.OfficeCheck.Inspect; namespace FineUIPro.Web.OfficeCheck.Inspect { public partial class ProjectSafetyInspectionRectify : PageBase { #region 定义项 /// /// 主键 /// private string InspectionItemId { get { return (string)ViewState["InspectionItemId"]; } set { ViewState["InspectionItemId"] = value; } } /// /// 责任人 /// public string PersonResponsible { get { return (string)ViewState["PersonResponsible"]; } set { ViewState["PersonResponsible"] = value; } } /// /// 类型 /// public string type { get { return (string)ViewState["type"]; } set { ViewState["type"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.InspectionItemId = Request.QueryString["InspectionItemId"]; this.type = Request.QueryString["type"]; if (this.type == "1") { this.btnSave.Hidden = true; } if (!string.IsNullOrEmpty(this.InspectionItemId)) { var registration = (from x in Funs.DB.Inspect_InspectionItem join y in Funs.DB.Inspect_Inspection on x.InspectionId equals y.InspectionId into inspection from inspectionJoin in inspection.DefaultIfEmpty() where x.InspectionItemId == this.InspectionItemId select new { //x.InspectionItemId, //x.InspectionDescribe, //x.PhotoUrl, //x.VideoUrl, //inspectionJoin.PersonResponsible, //x.EvaluateResults, //inspectionJoin.InspectMan, //x.TimeLimited, //x.RectificationDescription }).FirstOrDefault(); //if (registration != null) //{ // this.txtInspectionDescribe.Text = registration.InspectionDescribe; // // this.UploadPhoto.Text = registration.PhotoUrl; // // this.UploadVideo.Text = registration.VideoUrl; // if (registration.InspectMan != null) // { // //查询用户名 // var user = (from x in Funs.DB.Sys_User // where x.UserId == registration.InspectMan // select new { x.UserName }).FirstOrDefault(); // if (user != null) // { // this.txtCheckManName.Text = user.UserName; // } // } // this.txtEvaluateResults.Text = registration.EvaluateResults; // if (registration.PersonResponsible != null) // { // //查询用户名 // var user = (from x in Funs.DB.Sys_User // where x.UserId == registration.PersonResponsible // select new { x.UserName }).FirstOrDefault(); // if (user != null) // { // this.txtResponsibleManName.Text = user.UserName; // } // } // if (registration.TimeLimited != null) // { // this.txtTimeLimited.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", registration.TimeLimited); // } // this.txtRectificationDescription.Text = registration.RectificationDescription; // this.PersonResponsible = registration.PersonResponsible; //} } } } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.PersonResponsible) && this.PersonResponsible == this.CurrUser.UserId) { SaveData(true); } else { Alert.ShowInTop("您不是当前责任人,无法整改!", MessageBoxIcon.Warning); return; } } /// /// 保存数据 /// /// private void SaveData(bool isClosed) { var register = Inspect_InspectionService.GetInspectItemsById(this.InspectionItemId); if (register != null) { //var file = AttachFileService.GetAttachFile(register.InspectionItemId + "_3", BLL.Const.ProjectSafetyInspectionMenuId); //if (file != null && file.AttachUrl != "") //{ // register.States = "3"; //已整改待复查 // //register.RectificationPhotoUrl = file.AttachUrl.Trim(); //} //else //{ // ShowNotify("请先上传整改后照片!", MessageBoxIcon.Warning); // return; //} //Inspect_InspectionService.UpdateInspectionItem(register); if (isClosed) { if (string.IsNullOrEmpty(Request.Params["Main"])) { PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } else { PageContext.RegisterStartupScript(String.Format("window.close();")); } } } } #endregion #region 附件查看 /// /// 附件查看 /// /// /// protected void btnPhotoUrl_Click(object sender, EventArgs e) { var itemId = this.InspectionItemId + "_1"; PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format( "../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/InspectionItem&menuId={1}", itemId, BLL.Const.ProjectSafetyInspectionMenuId))); } protected void btnVideoUrl_Click(object sender, EventArgs e) { var itemId = this.InspectionItemId + "_2"; PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format( "../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/InspectionItem&menuId={1}", itemId, BLL.Const.ProjectSafetyInspectionMenuId))); } #endregion #region 附件上传 /// /// 附件上传 /// /// /// protected void btnAttachUrlR_Click(object sender, EventArgs e) { var itemId = this.InspectionItemId + "_3"; PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format( "../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/InspectionItem&menuId={1}", itemId, BLL.Const.ProjectSafetyInspectionMenuId))); } #endregion } }