ChengDa_English/SGGL/FineUIPro.Web/TestRun/PersonTrain/TrainPlanEdit.aspx.cs

105 lines
4.3 KiB
C#

using BLL;
using System;
namespace FineUIPro.Web.TestRun.PersonTrain
{
public partial class TrainPlanEdit : 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["id"];
if (!string.IsNullOrEmpty(id))
{
Model.PersonTrain_TrainPlan data = BLL.DriverPrepareTrainPlanService.GetDriverPlanById(id);
if (data != null)
{
this.hdId.Text = id;
this.txtCode.Text = data.PlanCode;
this.txtName.Text = data.PlanName;
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.txtConfirmDate.Text = data.ConfirmDate.HasValue ? string.Format("{0:yyyy-MM-dd}", data.ConfirmDate) : "";
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.PersonTrain_TrainPlan));
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/PersonTrain/TrainPlan&menuId={1}", this.hdId.Text, BLL.Const.TrainPlanMenuId)));
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
string id = Request.Params["id"];
Model.PersonTrain_TrainPlan newData = new Model.PersonTrain_TrainPlan();
newData.PlanCode = this.txtCode.Text.Trim();
newData.PlanName = this.txtName.Text.Trim();
if (this.drpCompileMan.SelectedValue != BLL.Const._Null)
{
newData.CompileMan = this.drpCompileMan.SelectedValue;
}
newData.CompileDate = Funs.GetNewDateTime(this.txtCompileDate.Text.Trim());
newData.ConfirmDate = Funs.GetNewDateTime(this.txtConfirmDate.Text.Trim());
newData.Remark = this.txtRemark.Text.Trim();
newData.ProjectId = this.CurrUser.LoginProjectId;
if (!string.IsNullOrEmpty(id))
{
newData.TrainPlanId = id;
BLL.DriverPrepareTrainPlanService.UpdateDriverPrepareDriverPlan(newData);
}
else
{
if (!string.IsNullOrEmpty(this.hdId.Text))
{
newData.TrainPlanId = this.hdId.Text.Trim();
}
else
{
newData.TrainPlanId = SQLHelper.GetNewID(typeof(Model.PersonTrain_TrainPlan));
this.hdId.Text = newData.TrainPlanId;
}
BLL.DriverPrepareTrainPlanService.AddDriverPrepareDriverPlan(newData);
}
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}