xinjiang/SGGL/FineUIPro.Web/TestRun/DriverHse/HseHazardEdit.aspx.cs

111 lines
4.4 KiB
C#

using BLL;
using System;
namespace FineUIPro.Web.TestRun.DriverHse
{
public partial class HseHazardEdit : 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);
string id = Request.Params["id"];
if (!string.IsNullOrEmpty(id))
{
Model.DriverHse_HseHazard data = BLL.HseHazardService.GetHseHazardById(id);
if (data != null)
{
this.hdId.Text = id;
this.txtCode.Text = data.Code;
if (!string.IsNullOrEmpty(data.UnitWorkId))
{
this.drpUnitWorkId.SelectedValue = data.UnitWorkId;
}
this.txtWorkArea.Text = data.WorkArea;
this.txtUnitHead.Text = data.UnitHead;
this.txtSupervisor.Text = data.Supervisor;
this.txtHazards.Text = data.Hazards;
this.txtHarm.Text = data.Harm;
this.txtPreventiveMeasures.Text = data.PreventiveMeasures;
this.txtDarificaiton.Text = data.Darificaiton;
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.DriverHse_HseHazard));
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/DriverHse/HseHazard&menuId={1}", this.hdId.Text, BLL.Const.HseHazardMenuId)));
}
#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.DriverHse_HseHazard newData = new Model.DriverHse_HseHazard();
newData.Code = this.txtCode.Text.Trim();
newData.WorkArea = this.txtWorkArea.Text.Trim();
newData.UnitHead = this.txtUnitHead.Text.Trim();
newData.UnitWorkId = this.drpUnitWorkId.SelectedValue;
newData.Supervisor = this.txtSupervisor.Text.Trim();
newData.Hazards = this.txtHazards.Text.Trim();
newData.Harm = this.txtHarm.Text.Trim();
newData.PreventiveMeasures = this.txtPreventiveMeasures.Text.Trim();
newData.Darificaiton = this.txtDarificaiton.Text.Trim();
newData.Remark = this.txtRemark.Text.Trim();
newData.ProjectId = this.CurrUser.LoginProjectId;
if (!string.IsNullOrEmpty(id))
{
newData.HseHazardId = id;
BLL.HseHazardService.UpdateHseHazard(newData);
}
else
{
if (!string.IsNullOrEmpty(this.hdId.Text))
{
newData.HseHazardId = this.hdId.Text.Trim();
}
else
{
newData.HseHazardId = SQLHelper.GetNewID(typeof(Model.DriverHse_HseHazard));
this.hdId.Text = newData.HseHazardId;
}
BLL.HseHazardService.AddHseHazard(newData);
}
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}