using BLL; using System; namespace FineUIPro.Web.HSSE.QualityAudit { public partial class PersonQualityEdit : PageBase { #region 定义项 /// /// 人员主键 /// private string PersonId { get { return (string)ViewState["PersonId"]; } set { ViewState["PersonId"] = value; } } /// /// 资质主键 /// private string PersonQualityId { get { return (string)ViewState["PersonQualityId"]; } set { ViewState["PersonQualityId"] = value; } } /// /// 项目主键 /// private string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.PersonId = Request.Params["PersonId"]; this.PersonQualityId = Request.Params["PersonQualityId"]; this.ProjectId = this.CurrUser.LoginProjectId; CertificateService.InitCertificateDropDownList(this.drpCertificate, true); Person_PersonsService.InitUserProjectIdUnitIdRoleIdDropDownList(this.drpAuditor, this.ProjectId, Const.UnitId_SEDIN, null, true); if (!string.IsNullOrEmpty(this.PersonQualityId)) { var getData = BLL.PersonQualityService.GetDataById(this.PersonQualityId); if (getData != null) { this.PersonId = getData.PersonId; this.txtCertificateNo.Text = getData.CertificateNo; this.drpCertificate.SelectedValue = getData.CertificateId; this.txtGrade.Text = getData.Grade; this.txtSendUnit.Text = getData.SendUnit; this.txtSendDate.Text = string.Format("{0:yyyy-MM-dd}", getData.SendDate); this.txtLimitDate.Text = string.Format("{0:yyyy-MM-dd}", getData.LimitDate); this.txtLateCheckDate.Text = string.Format("{0:yyyy-MM-dd}", getData.LateCheckDate); this.txtRegisterDate.Text = string.Format("{0:yyyy-MM-dd}", getData.RegisterDate); this.txtMajor.Text = getData.Major; if (!string.IsNullOrEmpty(getData.AuditorId)) { this.drpAuditor.SelectedValue = getData.AuditorId; } this.txtRemark.Text = getData.Remark; this.txtAuditDate.Text = string.Format("{0:yyyy-MM-dd}", getData.AuditDate); } else { this.txtSendDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); this.txtLimitDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); } } var person = BLL.Person_PersonsService.GetPerson_PersonsById(this.PersonId); if (person != null) { //this.ProjectId = person.ProjectId; var unit = UnitService.GetUnitByUnitId(person.UnitId); if (unit != null) { this.txtUnitCode.Text = unit.UnitCode; this.txtUnitName.Text = unit.UnitName; } this.txtPersonName.Text = person.PersonName; var workPost = WorkPostService.GetWorkPostById(person.WorkPostId); if (workPost != null) { this.txtWorkPostName.Text = workPost.WorkPostName; } } if (Request.Params["value"] == "0") { this.btnSave.Hidden = true; } } } #endregion #region 附件上传 /// /// 上传附件 /// /// /// protected void btnAttachUrl_Click(object sender, EventArgs e) { if (this.btnSave.Hidden) { PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/PersonQualityAttachUrl&menuId={1}&type=-1", PersonQualityId, BLL.Const.PersonQualityMenuId))); } else { if (string.IsNullOrEmpty(this.PersonQualityId)) { SaveData(false); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/PersonQualityAttachUrl&menuId={1}", PersonQualityId, BLL.Const.PersonQualityMenuId))); } } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { SaveData(true); } /// /// 保存数据 /// /// private void SaveData(bool isClose) { if (this.drpCertificate.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpCertificate.SelectedValue)) { Alert.ShowInTop("请选择特岗证书!", MessageBoxIcon.Warning); return; } if (!String.IsNullOrEmpty(this.PersonId)) { Model.QualityAudit_PersonQuality personQuality = new Model.QualityAudit_PersonQuality { PersonId = this.PersonId, PersonQualityId = this.PersonQualityId, CertificateNo = this.txtCertificateNo.Text.Trim(), CertificateId = this.drpCertificate.SelectedValue, CertificateName = this.drpCertificate.SelectedItem.Text, Grade = this.txtGrade.Text.Trim(), SendUnit = this.txtSendUnit.Text.Trim(), SendDate = Funs.GetNewDateTime(this.txtSendDate.Text.Trim()), LimitDate = Funs.GetNewDateTime(this.txtLimitDate.Text.Trim()), LateCheckDate = Funs.GetNewDateTime(this.txtLateCheckDate.Text.Trim()), Remark = this.txtRemark.Text.Trim(), CompileMan = this.CurrUser.PersonId, CompileDate = DateTime.Now, AuditDate = Funs.GetNewDateTime(this.txtAuditDate.Text.Trim()) }; if (this.drpAuditor.SelectedValue != Const._Null) { personQuality.AuditorId = this.drpAuditor.SelectedValue; } if (!string.IsNullOrEmpty(this.PersonQualityId)) { personQuality.PersonQualityId = this.PersonQualityId; BLL.PersonQualityService.UpdatePersonQuality(personQuality); BLL.LogService.AddSys_Log(this.CurrUser, personQuality.CertificateNo, personQuality.PersonQualityId, BLL.Const.PersonQualityMenuId, BLL.Const.BtnModify); } else { this.PersonQualityId = SQLHelper.GetNewID(); personQuality.PersonQualityId = this.PersonQualityId; BLL.PersonQualityService.AddPersonQuality(personQuality); BLL.LogService.AddSys_Log(this.CurrUser, personQuality.CertificateNo, personQuality.PersonQualityId, BLL.Const.PersonQualityMenuId, BLL.Const.BtnAdd); } if (isClose) { PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); } } } #endregion } }