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

123 lines
5.2 KiB
C#

using BLL;
using System;
namespace FineUIPro.Web.TestRun
{
public partial class DriverProgressEdit : 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);
BLL.UserService.InitUserDropDownList(this.drpCompileMan, this.CurrUser.LoginProjectId, true);
string id = Request.Params["id"];
if (!string.IsNullOrEmpty(id))
{
Model.Driver_DriverProgress data = BLL.DriverProgressService.GetDriverProgressById(id);
if (data != null)
{
this.hdId.Text = id;
this.txtCode.Text = data.Code;
if (!string.IsNullOrEmpty(data.UnitWorkId))
{
this.drpUnitWorkId.SelectedValue = data.UnitWorkId;
}
this.txtPlanName.Text = data.PlanName;
this.txtPlanCode.Text = data.PlanCode;
if (!string.IsNullOrEmpty(data.CompileMan))
{
this.drpCompileMan.SelectedValue = data.CompileMan;
}
this.txtCompileDate.Text = data.CompileDate.HasValue ? string.Format("{0:yyyy-MM-dd}", data.CompileDate) : "";
this.txtRevision.Text = data.Revision;
this.txtExecutionDeviation.Text = data.ExecutionDeviation;
this.txtEffect.Text = data.Effect;
this.txtRemark.Text = data.Remark;
}
}
else
{
this.drpCompileMan.SelectedValue = this.CurrUser.UserId;
this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
}
}
}
#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_DriverProgress));
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/DriverProgress&menuId={1}", this.hdId.Text, BLL.Const.DriverProgressMenuId)));
}
#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_DriverProgress newData = new Model.Driver_DriverProgress();
newData.Code = this.txtCode.Text.Trim();
newData.PlanName = this.txtPlanName.Text.Trim();
newData.PlanCode = this.txtPlanCode.Text.Trim();
newData.UnitWorkId = this.drpUnitWorkId.SelectedValue;
if (this.drpCompileMan.SelectedValue != BLL.Const._Null)
{
newData.CompileMan = this.drpCompileMan.SelectedValue;
}
newData.CompileDate = Funs.GetNewDateTime(this.txtCompileDate.Text.Trim());
newData.Revision = this.txtRevision.Text.Trim();
newData.ExecutionDeviation = this.txtExecutionDeviation.Text.Trim();
newData.Effect = this.txtEffect.Text.Trim();
newData.Remark = this.txtRemark.Text.Trim();
newData.ProjectId = this.CurrUser.LoginProjectId;
if (!string.IsNullOrEmpty(id))
{
newData.DriverProgressId = id;
BLL.DriverProgressService.UpdateDriverProgress(newData);
}
else
{
if (!string.IsNullOrEmpty(this.hdId.Text))
{
newData.DriverProgressId = this.hdId.Text.Trim();
}
else
{
newData.DriverProgressId = SQLHelper.GetNewID(typeof(Model.Driver_DriverProgress));
this.hdId.Text = newData.DriverProgressId;
}
BLL.DriverProgressService.AddDriverProgress(newData);
}
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}