CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/TestRun/ProduceTestRun/TestRunReportEdit.aspx.cs

107 lines
4.5 KiB
C#

using BLL;
using System;
namespace FineUIPro.Web.TestRun.ProduceTestRun
{
public partial class TestRunReportEdit :PageBase
{
#region
/// <summary>
/// 页面加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BLL.UnitWorkService.InitUnitWorkDropDownList(this.drpUnitWorkId, this.CurrUser.LoginProjectId, true);
string id = Request.Params["id"];
if (!string.IsNullOrEmpty(id))
{
Model.ProduceTestRun_TestRunReport data = BLL.TestRunReportService.GetTestRunReportById(id);
if (data != null)
{
this.hdId.Text = id;
if (!string.IsNullOrEmpty(data.UnitWorkId))
{
this.drpUnitWorkId.SelectedValue = data.UnitWorkId;
}
this.txtUnitHead.Text = data.UnitHead;
this.txtTestRunReportName.Text = data.TestRunReportName;
this.txtTestRunReportCode.Text = data.TestRunReportCode;
this.txtCompileMan.Text = data.CompileMan;
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;
}
}
}
}
#endregion
#region
/// <summary>
/// 附件上传
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttach_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.hdId.Text)) //新增记录
{
this.hdId.Text = SQLHelper.GetNewID(typeof(Model.ProduceTestRun_TestRunReport));
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/ProduceTestRun/TestRunReport&menuId={1}", this.hdId.Text, BLL.Const.TestRunReportMenuId)));
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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.ProduceTestRun_TestRunReport newData = new Model.ProduceTestRun_TestRunReport();
newData.UnitWorkId = this.drpUnitWorkId.SelectedValue;
newData.UnitHead = this.txtUnitHead.Text.Trim();
newData.TestRunReportName = this.txtTestRunReportName.Text.Trim();
newData.TestRunReportCode = this.txtTestRunReportCode.Text.Trim();
newData.CompileMan = this.txtCompileMan.Text.Trim();
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.TestRunReportId = id;
BLL.TestRunReportService.UpdateTestRunReport(newData);
}
else
{
if (!string.IsNullOrEmpty(this.hdId.Text))
{
newData.TestRunReportId = this.hdId.Text.Trim();
}
else
{
newData.TestRunReportId = SQLHelper.GetNewID(typeof(Model.ProduceTestRun_TestRunReport));
this.hdId.Text = newData.TestRunReportId;
}
BLL.TestRunReportService.AddTestRunReport(newData);
}
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}