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

98 lines
3.8 KiB
C#

using BLL;
using System;
namespace FineUIPro.Web.TestRun.DriverPrepare
{
public partial class DutyEdit : 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.DriverPrepare_Duty data = BLL.DriverPrepareDutyService.GetDriverPlanById(id);
if (data != null)
{
this.hdId.Text = id;
this.txtCode.Text = data.DutyCode;
this.txtName.Text = data.DutyName;
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.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.DriverPrepare_Duty));
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/DriverPrepare/Duty&menuId={1}", this.hdId.Text, BLL.Const.DutyMenuId)));
}
#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.DriverPrepare_Duty newData = new Model.DriverPrepare_Duty();
newData.DutyCode = this.txtCode.Text.Trim();
newData.DutyName = 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.Remark = this.txtRemark.Text.Trim();
newData.ProjectId = this.CurrUser.LoginProjectId;
if (!string.IsNullOrEmpty(id))
{
newData.DutyId = id;
BLL.DriverPrepareDutyService.UpdateDriverPrepareDriverPlan(newData);
}
else
{
if (!string.IsNullOrEmpty(this.hdId.Text))
{
newData.DutyId = this.hdId.Text.Trim();
}
else
{
newData.DutyId = SQLHelper.GetNewID(typeof(Model.DriverPrepare_Duty));
this.hdId.Text = newData.DutyId;
}
BLL.DriverPrepareDutyService.AddDriverPrepareDriverPlan(newData);
}
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}