CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/TestRun/DriverPrepare/DriverPlanEdit.aspx.cs

109 lines
4.8 KiB
C#

using BLL;
using System;
namespace FineUIPro.Web.TestRun.DriverPrepare
{
public partial class DriverPlanEdit : PageBase
{
#region
/// <summary>
/// 页面加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BLL.UserService.InitUserDropDownList(this.drpCompileMan, this.CurrUser.LoginProjectId, true);
string id = Request.Params["driverPlanId"];
if (!string.IsNullOrEmpty(id))
{
Model.DriverPrepare_DriverPlan driverPlan = BLL.DriverPrepareDriverPlanService.GetDriverPlanById(id);
if (driverPlan != null)
{
this.hdId.Text = id;
this.txtDriverPlanName.Text = driverPlan.DriverPlanName;
this.txtDriverPlanCode.Text = driverPlan.DriverPlanCode;
if (!string.IsNullOrEmpty(driverPlan.CompileMan))
{
this.drpCompileMan.SelectedValue = driverPlan.CompileMan;
}
this.txtSubmitDate.Text = driverPlan.SubmitDate.HasValue ? string.Format("{0:yyyy-MM-dd}", driverPlan.SubmitDate) : "";
this.txtAudit.Text = driverPlan.Audit;
this.txtApprove.Text = driverPlan.Approve;
this.txtApproveDate.Text = driverPlan.ApproveDate.HasValue ? string.Format("{0:yyyy-MM-dd}", driverPlan.ApproveDate) : "";
this.txtRemark.Text = driverPlan.Remark;
}
}
else
{
this.drpCompileMan.SelectedValue = this.CurrUser.UserId;
this.txtSubmitDate.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.DriverPrepare_DriverPlan));
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/DriverPrepare/DriverPlan&menuId={1}", this.hdId.Text, BLL.Const.DriverPlanMenuId)));
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
string id = Request.Params["driverPlanId"];
Model.DriverPrepare_DriverPlan newDriverPlan = new Model.DriverPrepare_DriverPlan();
newDriverPlan.DriverPlanName = this.txtDriverPlanName.Text.Trim();
newDriverPlan.DriverPlanCode = this.txtDriverPlanCode.Text.Trim();
if (this.drpCompileMan.SelectedValue!=BLL.Const._Null)
{
newDriverPlan.CompileMan = this.drpCompileMan.SelectedValue;
}
newDriverPlan.SubmitDate = Funs.GetNewDateTime(this.txtSubmitDate.Text.Trim());
newDriverPlan.Audit = this.txtAudit.Text.Trim();
newDriverPlan.Approve = this.txtApprove.Text.Trim();
newDriverPlan.ApproveDate = Funs.GetNewDateTime(this.txtApproveDate.Text.Trim());
newDriverPlan.Remark = this.txtRemark.Text.Trim();
newDriverPlan.ProjectId = this.CurrUser.LoginProjectId;
if (!string.IsNullOrEmpty(id))
{
newDriverPlan.DriverPlanId = id;
BLL.DriverPrepareDriverPlanService.UpdateDriverPrepareDriverPlan(newDriverPlan);
}
else
{
if (!string.IsNullOrEmpty(this.hdId.Text))
{
newDriverPlan.DriverPlanId = this.hdId.Text.Trim();
}
else
{
newDriverPlan.DriverPlanId = SQLHelper.GetNewID(typeof(Model.DriverPrepare_DriverPlan));
this.hdId.Text = newDriverPlan.DriverPlanId;
}
BLL.DriverPrepareDriverPlanService.AddDriverPrepareDriverPlan(newDriverPlan);
}
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}