CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/TestRun/FeedingTestRunEdit.aspx.cs

109 lines
4.6 KiB
C#

using BLL;
using System;
namespace FineUIPro.Web.TestRun
{
public partial class FeedingTestRunEdit :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.Driver_FeedingTestRun data = BLL.FeedingTestRunService.GetFeedingTestRunById(id);
if (data != null)
{
this.hdId.Text = id;
this.txtCode.Text = data.Code;
if (!string.IsNullOrEmpty(data.UnitWorkId))
{
this.drpUnitWorkId.SelectedValue = data.UnitWorkId;
}
this.txtInstallationHead.Text = data.InstallationHead;
this.txtWorkContents.Text = data.WorkContents;
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.txtDescriptions.Text = data.Descriptions;
this.txtProblemsAndSolutions.Text = data.ProblemsAndSolutions;
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.Driver_FeedingTestRun));
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/FeedingTestRun&menuId={1}", this.hdId.Text, BLL.Const.FeedingTestRunMenuId)));
}
#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.Driver_FeedingTestRun newData = new Model.Driver_FeedingTestRun();
newData.Code = this.txtCode.Text.Trim();
newData.UnitWorkId = this.drpUnitWorkId.SelectedValue;
newData.InstallationHead = this.txtInstallationHead.Text.Trim();
newData.WorkContents = this.txtWorkContents.Text.Trim();
newData.StartDate = Funs.GetNewDateTime(this.txtStartDate.Text.Trim());
newData.EndDate = Funs.GetNewDateTime(this.txtEndDate.Text.Trim());
newData.Descriptions = this.txtDescriptions.Text.Trim();
newData.ProblemsAndSolutions = this.txtProblemsAndSolutions.Text.Trim();
newData.Remark = this.txtRemark.Text.Trim();
newData.ProjectId = this.CurrUser.LoginProjectId;
if (!string.IsNullOrEmpty(id))
{
newData.FeedingTestRunId = id;
BLL.FeedingTestRunService.UpdateFeedingTestRun(newData);
}
else
{
if (!string.IsNullOrEmpty(this.hdId.Text))
{
newData.FeedingTestRunId = this.hdId.Text.Trim();
}
else
{
newData.FeedingTestRunId = SQLHelper.GetNewID(typeof(Model.Driver_FeedingTestRun));
this.hdId.Text = newData.FeedingTestRunId;
}
BLL.FeedingTestRunService.AddFeedingTestRun(newData);
}
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}