using BLL; using System; namespace FineUIPro.Web.TestRun.ProduceProperty { public partial class PropertyRunReportEdit : PageBase { #region 加载 /// /// 页面加载 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BLL.UnitWorkService.InitUnitWorkDropDownList(this.drpUnitWorkId, this.CurrUser.LoginProjectId, true); BLL.UserService.InitUserDropDownList(this.drpInstallationMan, this.CurrUser.LoginProjectId, true); string id = Request.Params["id"]; if (!string.IsNullOrEmpty(id)) { Model.ProduceProperty_PropertyRunReport data = BLL.PropertyRunReportService.GetPropertyRunReportById(id); if (data != null) { this.hdId.Text = id; this.txtCode.Text = data.Code; if (!string.IsNullOrEmpty(data.UnitWorkId)) { this.drpUnitWorkId.SelectedValue = data.UnitWorkId; } if (!string.IsNullOrEmpty(data.InstallationMan)) { this.drpInstallationMan.SelectedValue = data.InstallationMan; } this.txtReportName.Text = data.ReportName; this.txtReportCode.Text = data.ReportCode; this.txtReportMan.Text = BLL.UserService.GetUserNameByUserId(data.ReportMan); this.txtStartDate.Text = data.StartDate.HasValue ? string.Format("{0:yyyy-MM-dd}", data.StartDate) : ""; this.txtEndDate.Text = data.EndDate.HasValue ? string.Format("{0:yyyy-MM-dd}", data.EndDate) : ""; this.txtRemark.Text = data.Remark; } } else { this.txtReportMan.Text = this.CurrUser.UserName; } } } #endregion #region 附件上传 /// /// 附件上传 /// /// /// protected void btnAttach_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.hdId.Text)) //新增记录 { this.hdId.Text = SQLHelper.GetNewID(typeof(Model.ProduceProperty_PropertyRunReport)); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/ProduceProperty/PropertyRunReport&menuId={1}", this.hdId.Text, BLL.Const.PropertyRunReportMenuId))); } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (this.drpUnitWorkId.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择考核装置!", MessageBoxIcon.Warning); return; } string id = Request.Params["id"]; Model.ProduceProperty_PropertyRunReport newData = new Model.ProduceProperty_PropertyRunReport(); newData.Code = this.txtCode.Text.Trim(); newData.UnitWorkId = this.drpUnitWorkId.SelectedValue; if (this.drpInstallationMan.SelectedValue != BLL.Const._Null) { newData.InstallationMan = this.drpInstallationMan.SelectedValue; } newData.ReportName = this.txtReportName.Text.Trim(); newData.ReportCode = this.txtReportCode.Text.Trim(); newData.ReportMan = this.CurrUser.UserId; newData.StartDate = Funs.GetNewDateTime(this.txtStartDate.Text.Trim()); newData.EndDate = Funs.GetNewDateTime(this.txtEndDate.Text.Trim()); newData.Remark = this.txtRemark.Text.Trim(); newData.ProjectId = this.CurrUser.LoginProjectId; if (!string.IsNullOrEmpty(id)) { newData.PropertyRunReportId = id; BLL.PropertyRunReportService.UpdatePropertyRunReport(newData); } else { if (!string.IsNullOrEmpty(this.hdId.Text)) { newData.PropertyRunReportId = this.hdId.Text.Trim(); } else { newData.PropertyRunReportId = SQLHelper.GetNewID(typeof(Model.ProduceProperty_PropertyRunReport)); this.hdId.Text = newData.PropertyRunReportId; } BLL.PropertyRunReportService.AddPropertyRunReport(newData); } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion } }