using BLL; using System; using System.Linq; namespace FineUIPro.Web.CQMS.Comprehensive { public partial class InspectionPersonEdit : PageBase { #region 定义变量 /// /// 主键 /// public string InspectionPersonId { get { return (string)ViewState["InspectionPersonId"]; } set { ViewState["InspectionPersonId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GetButtonPower(); BLL.UnitWorkService.InitUnitWorkDownList(this.drpUnitWorkIds, this.CurrUser.LoginProjectId, false); BLL.UnitService.InitUnitDownList(this.drpUnitId, this.CurrUser.LoginProjectId, true); BLL.PostService.InitPostDownList(this.drpPostId, true); BLL.CNProfessionalService.InitCNProfessionalDownList(this.drpCNProfessionalId, true); this.InspectionPersonId = Request.Params["InspectionPersonId"]; Model.Comprehensive_InspectionPerson inspectionPerson = BLL.InspectionPersonService.GetInspectionPersonById(this.InspectionPersonId); if (inspectionPerson != null) { this.InspectionPersonId = inspectionPerson.InspectionPersonId; this.hdAttachUrl.Text =this.InspectionPersonId; if (!string.IsNullOrEmpty(inspectionPerson.CNProfessionalId)) { this.drpCNProfessionalId.SelectedValue = inspectionPerson.CNProfessionalId; } if (!string.IsNullOrEmpty(inspectionPerson.UnitId)) { this.drpUnitId.SelectedValue = inspectionPerson.UnitId; } this.txtInspectionCode.Text = inspectionPerson.InspectionPersonCode; if (!string.IsNullOrEmpty(inspectionPerson.PostId)) { this.drpPostId.SelectedValue = inspectionPerson.PostId; } this.txtPersonName.Text = inspectionPerson.PersonName; this.txtCertificateNumber.Text = inspectionPerson.CertificateNumber; this.txtQualifiedProjectCode.Text = inspectionPerson.QualifiedProjectCode; if (inspectionPerson.ValidityDate != null) { this.txtValidityDate.Text = string.Format("{0:yyyy-MM-dd}", inspectionPerson.ValidityDate); } if (inspectionPerson.ApprovalTime != null) { this.txtApprovalTime.Text = string.Format("{0:yyyy-MM-dd}", inspectionPerson.ApprovalTime); } this.rblIsOnSite.SelectedValue = inspectionPerson.IsOnSite.HasValue && inspectionPerson.IsOnSite == true ? "true" : "false"; if (inspectionPerson.DepartureTime != null) { this.txtDepartureTime.Text = string.Format("{0:yyyy-MM-dd}", inspectionPerson.DepartureTime); } if (!string.IsNullOrEmpty(inspectionPerson.UnitWorkId)) { this.drpUnitWorkIds.SelectedValueArray = inspectionPerson.UnitWorkId.Split(','); } this.txtRemark.Text = inspectionPerson.Remark; } else { this.txtValidityDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); this.txtApprovalTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); this.txtDepartureTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); } } } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (this.drpUnitId.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择报验单位!", MessageBoxIcon.Warning); return; } // 焊工部分 Model.BS_Welder welder = new Model.BS_Welder(); if (this.drpUnitId.SelectedValue != BLL.Const._Null) { welder.WED_Unit = this.drpUnitId.SelectedValue; } welder.WED_Code = this.txtInspectionCode.Text.Trim(); welder.WED_Name = this.txtPersonName.Text.Trim(); if (!String.IsNullOrEmpty(this.txtValidityDate.Text.ToString())) { welder.LimitDate = Convert.ToDateTime(this.txtValidityDate.Text.ToString()); } if (!String.IsNullOrEmpty(this.txtDepartureTime.Text.ToString())) { welder.LeaveDate = Convert.ToDateTime(this.txtDepartureTime.Text.ToString()); } if (!String.IsNullOrEmpty(this.txtApprovalTime.Text.ToString())) { welder.PostDate = Convert.ToDateTime(this.txtApprovalTime.Text.ToString()); } welder.WED_WorkCode = this.txtCertificateNumber.Text.Trim(); welder.WED_Class = this.txtQualifiedProjectCode.Text.Trim(); if (this.rblIsOnSite.SelectedValue == "true") { welder.WED_IfOnGuard = true; } else { welder.WED_IfOnGuard = false; } welder.WED_Remark = this.txtRemark.Text.Trim(); welder.ProjectId = this.CurrUser.LoginProjectId; //人员报验 Model.Comprehensive_InspectionPerson inspectionPerson = new Model.Comprehensive_InspectionPerson(); inspectionPerson.ProjectId = this.CurrUser.LoginProjectId; if (this.drpUnitId.SelectedValue != BLL.Const._Null) { inspectionPerson.UnitId = this.drpUnitId.SelectedValue; } inspectionPerson.InspectionPersonCode = this.txtInspectionCode.Text.Trim(); if (this.drpPostId.SelectedValue != BLL.Const._Null) { inspectionPerson.PostId = this.drpPostId.SelectedValue; } if (this.drpCNProfessionalId.SelectedValue != BLL.Const._Null) { inspectionPerson.CNProfessionalId = this.drpCNProfessionalId.SelectedValue; } inspectionPerson.PersonName = this.txtPersonName.Text.Trim(); inspectionPerson.CertificateNumber = this.txtCertificateNumber.Text.Trim(); inspectionPerson.QualifiedProjectCode = this.txtQualifiedProjectCode.Text.Trim(); if (!string.IsNullOrEmpty(this.txtValidityDate.Text.ToString())) { inspectionPerson.ValidityDate = Convert.ToDateTime(this.txtValidityDate.Text.ToString()); } if (!string.IsNullOrEmpty(this.txtApprovalTime.Text.ToString())) { inspectionPerson.ApprovalTime = Convert.ToDateTime(this.txtApprovalTime.Text.ToString()); } if (this.rblIsOnSite.SelectedValue == "true") { inspectionPerson.IsOnSite = true; } else { inspectionPerson.IsOnSite = false; } if (!string.IsNullOrEmpty(this.txtDepartureTime.Text.ToString())) { inspectionPerson.DepartureTime = Convert.ToDateTime(this.txtDepartureTime.Text.ToString()); } inspectionPerson.Remark = this.txtRemark.Text.Trim(); string ids = string.Empty; var lists = this.drpUnitWorkIds.SelectedValueArray; foreach (var item in lists) { ids += item + ","; } if (!string.IsNullOrEmpty(ids)) { ids = ids.Substring(0, ids.LastIndexOf(",")); } inspectionPerson.UnitWorkId = ids; if (string.IsNullOrEmpty(this.InspectionPersonId)) { inspectionPerson.CompileMan = this.CurrUser.UserId; inspectionPerson.CompileDate = DateTime.Now; if (!string.IsNullOrEmpty(this.hdAttachUrl.Text)) { inspectionPerson.InspectionPersonId = this.hdAttachUrl.Text; } else { inspectionPerson.InspectionPersonId = SQLHelper.GetNewID(typeof(Model.Comprehensive_InspectionPerson)); this.hdAttachUrl.Text = inspectionPerson.InspectionPersonId; } // 人员报验 BLL.InspectionPersonService.AddInspectionPerson(inspectionPerson); if (this.drpPostId.SelectedItem.Text == "焊工") { // 焊工部分 BLL.PersonManageService.AddBSWelder(welder); } } else { inspectionPerson.InspectionPersonId = this.InspectionPersonId; BLL.InspectionPersonService.UpdateInspectionPerson(inspectionPerson); // 焊工部分 var oldWelder = BLL.PersonManageService.GetBSWelderByProjectIdUnitIdAndWED_Code(welder.ProjectId, welder.WED_Unit, welder.WED_Code); if (oldWelder != null) { welder.WED_ID = oldWelder.WED_ID; BLL.PersonManageService.UpdateBSWelder(welder); } else { BLL.PersonManageService.AddBSWelder(welder); } } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion #region 附件上传 /// /// 附件上传 /// /// /// protected void btnAttach_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.hdAttachUrl.Text)) //新增记录 { this.hdAttachUrl.Text = SQLHelper.GetNewID(typeof(Model.Comprehensive_InspectionPerson)); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/CQMS/InspectionPerson&menuId={1}", this.hdAttachUrl.Text, BLL.Const.InspectionPersonMenuId))); } #endregion #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { if (Request.Params["value"] == "0") { return; } var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.InspectionPersonMenuId); if (buttonList.Count() > 0) { if (buttonList.Contains(BLL.Const.BtnSave)) { this.btnSave.Hidden = false; } } } #endregion } }