using BLL; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FineUIPro.Web.Customization.CNCEC4.ZHGL.Report { public partial class PersonnelAllocationInfoEdit : PageBase { #region 定义变量 /// /// 主键 /// public string ReportId { get { return (string)ViewState["ReportId"]; } set { ViewState["ReportId"] = value; } } /// /// 项目id /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } /// /// 单位id /// public string UnitId { get { return (string)ViewState["UnitId"]; } set { ViewState["UnitId"] = value; } } #endregion #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.ReportId = Request.Params["reportId"]; if (!string.IsNullOrEmpty(this.ReportId)) { var report = BLL.PersonnelAllocationInfoService.GetReportById(this.ReportId); if (report != null) { this.ProjectId = report.ProjectId; this.UnitId = report.UnitId; var project = BLL.ProjectService.GetProjectByProjectId(this.ProjectId); if (project!=null) { this.txtProjectName.Text = project.ProjectName; this.txtUnitName.Text = BLL.UnitService.GetUnitNameByUnitId(project.UnitId); } this.txtMonths.Text = string.Format("{0:yyyy-MM}", report.Months); this.txtDuties.Text = report.Duties; this.txtPersonName.Text = report.PersonName; this.txtTelephone.Text = report.Telephone; this.txtEmergentTel.Text = report.EmergentTel; this.txtIdentityCard.Text = report.IdentityCard; this.cblSex.SelectedValueArray = new string[] { report.Sex }; this.cblEducation.SelectedValueArray = new string[] { report.Education }; this.cblMajor.SelectedValueArray = new string[] { report.Major }; this.cblYearsOfService.SelectedValueArray = new string[] { report.YearsOfService }; this.cblQualification.SelectedValueArray = new string[] { report.Qualification }; this.cblPersonStates.SelectedValueArray = new string[] { report.PersonStates }; this.txtRemark.Text = report.Remark; } } } } #endregion #region 保存、提交 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { SaveData(BLL.Const.BtnSave); } /// /// 保存方法 /// /// private void SaveData(string type) { Model.Report_PersonnelAllocationInfo newReport = new Model.Report_PersonnelAllocationInfo(); newReport.Months = Convert.ToDateTime(this.txtMonths.Text); newReport.ProjectId = this.ProjectId; newReport.UnitId = BLL.ProjectService.GetProjectByProjectId(this.ProjectId).UnitId; newReport.Duties = this.txtDuties.Text.Trim(); newReport.PersonName = this.txtPersonName.Text.Trim(); newReport.Telephone = this.txtTelephone.Text.Trim(); newReport.EmergentTel = this.txtEmergentTel.Text.Trim(); newReport.IdentityCard = this.txtIdentityCard.Text.Trim(); newReport.Sex = String.Join(",", this.cblSex.SelectedValueArray); newReport.Education = String.Join(",", this.cblEducation.SelectedValueArray); newReport.Major = String.Join(",", this.cblMajor.SelectedValueArray); newReport.YearsOfService = String.Join(",", this.cblYearsOfService.SelectedValueArray); newReport.Qualification = String.Join(",", this.cblQualification.SelectedValueArray); newReport.PersonStates = String.Join(",", this.cblPersonStates.SelectedValueArray); newReport.Remark = this.txtRemark.Text.Trim(); if (!string.IsNullOrEmpty(this.ReportId)) { newReport.ReportId = this.ReportId; BLL.PersonnelAllocationInfoService.UpdateReport(newReport); } else { newReport.ReportId = SQLHelper.GetNewID(typeof(Model.Report_PersonnelAllocationInfo)); BLL.PersonnelAllocationInfoService.AddReport(newReport); } ShowNotify("保存成功"); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion } }