using BLL; using System; namespace FineUIPro.Web.CQMS.Technical { public partial class TechnicalDiscloseEdit : PageBase { /// /// 主键 /// public string TechnicalDiscloseId { get { return (string)ViewState["TechnicalDiscloseId"]; } set { ViewState["TechnicalDiscloseId"] = value; } } /// /// 办理类型 /// public string State { get { return (string)ViewState["State"]; } set { ViewState["State"] = value; } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { TechnicalDiscloseId = Request.Params["TechnicalDiscloseId"]; BLL.SitePerson_PersonService.InitProjectUserListByProjectUnitTypeDropDownList(this.drpMainPartys, this.CurrUser.LoginProjectId, Const.ProjectUnitType_1, true); if (!string.IsNullOrEmpty(TechnicalDiscloseId)) { Model.Technical_TechnicalDisclose TechnicalDisclose = BLL.CQMS_TechnicalDiscloseService.GetTechnicalDiscloseById(TechnicalDiscloseId); hdId.Text = this.TechnicalDiscloseId; if (!string.IsNullOrEmpty(TechnicalDisclose.UnitId)) { this.txtUnitName.Text = BLL.UnitService.GetUnitNameByUnitId(TechnicalDisclose.UnitId); BindDiscloseMan(TechnicalDisclose.UnitId); } if (!string.IsNullOrEmpty(TechnicalDisclose.UnitWorkId)) { txtUnitWork.Text = BLL.UnitWorkService.GetUnitWorkALLName(TechnicalDisclose.UnitWorkId); } txtDiscloseName.Text = TechnicalDisclose.DiscloseName; txtDiscloseRequire.Text = TechnicalDisclose.DiscloseRequire; if (!string.IsNullOrEmpty(TechnicalDisclose.DiscloseMan)) { this.drpDiscloseMan.SelectedValue = TechnicalDisclose.DiscloseMan; } else { this.drpDiscloseMan.SelectedValue = this.CurrUser.PersonId; } if (TechnicalDisclose.DiscloseDate != null) { this.txtDiscloseDate.Text = string.Format("{0:yyyy-MM-dd}", TechnicalDisclose.DiscloseDate); } else { this.txtDiscloseDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); } if (!string.IsNullOrEmpty(TechnicalDisclose.MainPartys)) { this.drpMainPartys.SelectedValueArray = TechnicalDisclose.MainPartys.Split(','); } } } } private void BindDiscloseMan(string unitId) { this.drpDiscloseMan.DataTextField = "PersonName"; this.drpDiscloseMan.DataValueField = "PersonId"; this.drpDiscloseMan.DataSource = BLL.SitePerson_PersonService.GetSitePerson_PersonListByUnitIdsRoleIds(this.CurrUser.LoginProjectId, unitId, null); this.drpDiscloseMan.DataBind(); Funs.FineUIPleaseSelect(this.drpDiscloseMan); } protected void Grid1_Sort(object sender, GridSortEventArgs e) { } protected void WindowAtt_Close(object sender, WindowCloseEventArgs e) { } /// /// 时间转换 /// /// /// public string ConvertDate(object date) { if (date != null) { return string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(date)); } else { return null; } } protected void imgBtnFile_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(hdId.Text)) { hdId.Text = SQLHelper.GetNewID(); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=1&toKeyId={0}&path=FileUpload/CQMS/Technical&menuId={1}", hdId.Text, BLL.Const.CQMSTechnicalDiscloseMenuId))); } protected void btnSave_Click(object sender, EventArgs e) { if (validate()) { SaveTechnicalDisclose("save"); } } /// /// 保存 /// public void SaveTechnicalDisclose(string saveType) { Model.Technical_TechnicalDisclose TechnicalDisclose = BLL.CQMS_TechnicalDiscloseService.GetTechnicalDiscloseById(this.TechnicalDiscloseId); if (TechnicalDisclose != null) { TechnicalDisclose.DiscloseRequire = this.txtDiscloseRequire.Text.Trim(); TechnicalDisclose.DiscloseMan = this.drpDiscloseMan.SelectedValue; TechnicalDisclose.DiscloseDate = Funs.GetNewDateTimeOrNow(this.txtDiscloseDate.Text.Trim()); string mainPartys = string.Empty; foreach (var item in this.drpMainPartys.SelectedValueArray) { if (item != Const._Null) { mainPartys += item + ","; } } if (!string.IsNullOrEmpty(mainPartys)) { TechnicalDisclose.MainPartys = mainPartys.Substring(0, mainPartys.Length - 1); } TechnicalDisclose.State = "1"; //已交底 BLL.CQMS_TechnicalDiscloseService.UpdateTechnicalDisclose(TechnicalDisclose); LogService.AddSys_Log(CurrUser, TechnicalDisclose.DiscloseName, TechnicalDisclose.TechnicalDiscloseId, Const.CQMSTechnicalDiscloseMenuId, "修改施工技术交底"); } PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } /// /// 表格数据验证 /// private bool validate() { bool res = false; string err = string.Empty; if (this.drpDiscloseMan.SelectedValue == BLL.Const._Null) { err += "请选择交底人!"; } if (this.drpMainPartys.SelectedValue == BLL.Const._Null && this.drpMainPartys.SelectedValueArray.Length == 1) { err += "请选择总包参与人!"; } var att = BLL.AttachFileService.GetAttachFileByToKeyId(this.hdId.Text); if (att == null) { err += "请上传附件!"; } if (!string.IsNullOrWhiteSpace(err)) { Alert.ShowInTop(err, MessageBoxIcon.Warning); } else { res = true; } return res; } } }