SGGL_JT/SUBQHSE/FineUIPro.Web/HSSE/Administrative/DriverManagerEdit.aspx.cs

143 lines
5.7 KiB
C#

using BLL;
using System;
namespace FineUIPro.Web.HSSE.Administrative
{
public partial class DriverManagerEdit :PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
private string DriverManagerId
{
get
{
return (string)ViewState["DriverManagerId"];
}
set
{
ViewState["DriverManagerId"] = value;
}
}
/// <summary>
/// 项目主键
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
this.ProjectId = this.CurrUser.LoginProjectId;
this.DriverManagerId = Request.Params["DriverManagerId"];
if (!string.IsNullOrEmpty(this.DriverManagerId))
{
Model.Administrative_DriverManager DriverManager = BLL.DriverManagerService.GetDriverManagerById(this.DriverManagerId);
if (DriverManager != null)
{
this.ProjectId = DriverManager.ProjectId;
this.txtDriverManagerCode.Text = BLL.CodeRecordsService.ReturnCodeByDataId(this.DriverManagerId);
this.txtDriverName.Text = DriverManager.DriverName;
this.txtDriverCode.Text = DriverManager.DriverCode;
this.txtDrivingDate.Text = string.Format("{0:yyyy-MM-dd}", DriverManager.DrivingDate);
this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", DriverManager.CheckDate);
this.txtDriverCarModel.Text = DriverManager.DriverCarModel;
this.txtRemark.Text = DriverManager.Remark;
}
}
else
{
////自动生成编码
this.txtDriverManagerCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.DriverManagerMenuId, this.ProjectId, this.CurrUser.UnitId);
this.txtDrivingDate.Text = string.Format("{0:yyyy-MM-dd}", System.DateTime.Now);
this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", System.DateTime.Now.AddYears(1));
}
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
this.SaveData(BLL.Const.BtnSave);
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="type"></param>
private void SaveData(string type)
{
Model.Administrative_DriverManager DriverManager = new Model.Administrative_DriverManager
{
ProjectId = this.ProjectId,
DriverManagerCode = this.txtDriverManagerCode.Text.Trim(),
DriverName = this.txtDriverName.Text.Trim(),
DriverCode = this.txtDriverCode.Text.Trim(),
DrivingDate = Funs.GetNewDateTime(this.txtDrivingDate.Text.Trim()),
CheckDate = Funs.GetNewDateTime(this.txtCheckDate.Text.Trim()),
DriverCarModel = this.txtDriverCarModel.Text.Trim(),
Remark = this.txtRemark.Text.Trim(),
CompileMan = this.CurrUser.UserId,
CompileDate = DateTime.Now,
States = BLL.Const.State_2
};
if (!string.IsNullOrEmpty(this.DriverManagerId))
{
DriverManager.DriverManagerId = this.DriverManagerId;
BLL.DriverManagerService.UpdateDriverManager(DriverManager);
BLL.LogService.AddSys_Log(this.CurrUser, DriverManager.DriverManagerCode, DriverManager.DriverManagerId, BLL.Const.DriverManagerMenuId, BLL.Const.BtnAdd);
}
else
{
this.DriverManagerId = SQLHelper.GetNewID(typeof(Model.Administrative_DriverManager));
DriverManager.DriverManagerId = this.DriverManagerId;
BLL.DriverManagerService.AddDriverManager(DriverManager);
BLL.LogService.AddSys_Log(this.CurrUser, DriverManager.DriverManagerCode, DriverManager.DriverManagerId, BLL.Const.DriverManagerMenuId, BLL.Const.BtnModify);
}
}
#endregion
#region
/// <summary>
/// 上传附件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.DriverManagerId))
{
SaveData(BLL.Const.BtnSave);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/DriverManagerAttachUrl&menuId={1}", DriverManagerId, BLL.Const.DriverManagerMenuId)));
}
#endregion
}
}