xinjiang/SGGL/FineUIPro.Web/SYHSE/Data_MajorHazardEdit.aspx.cs

199 lines
7.8 KiB
C#

using BLL;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.SYHSE
{
public partial class Data_MajorHazardEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string Id
{
get
{
return (string)ViewState["Id"];
}
set
{
ViewState["Id"] = value;
}
}
#endregion
/// <summary>
/// 把状态转换代号为文字形式
/// </summary>
/// <param name="state"></param>
/// <returns></returns>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Id = Request.Params["Id"];
if (!string.IsNullOrEmpty(Id))
{
var majorHazard = Funs.DB.SYHSEData_MajorHazard.FirstOrDefault(x => x.Id == Id);
if (majorHazard != null)
{
if (majorHazard.ReportDate.HasValue)
{
this.txtReportDate.Text = majorHazard.ReportDate.Value.ToString("yyyy-MM-dd");
}
if (!string.IsNullOrEmpty(majorHazard.HazardName))
{
this.txtHazardName.Text = majorHazard.HazardName;
}
if (!string.IsNullOrEmpty(majorHazard.HazardCode))
{
this.txtHazardCode.Text = majorHazard.HazardCode;
}
if (!string.IsNullOrEmpty(majorHazard.DeviceName))
{
this.txtDeviceName.Text = majorHazard.DeviceName;
}
if (!string.IsNullOrEmpty(majorHazard.Material))
{
this.txtMaterial.Text = majorHazard.Material;
}
if (!string.IsNullOrEmpty(majorHazard.Amount))
{
this.txtAmount.Text = majorHazard.Amount;
}
if (!string.IsNullOrEmpty(majorHazard.MaxAmount))
{
this.txtMaxAmount.Text = majorHazard.MaxAmount;
}
if (!string.IsNullOrEmpty(majorHazard.MinAmount))
{
this.txtMinAmount.Text = majorHazard.MinAmount;
}
if (!string.IsNullOrEmpty(majorHazard.MainOperaPerson))
{
this.txtMainOperaPerson.Text = majorHazard.MainOperaPerson;
}
if (!string.IsNullOrEmpty(majorHazard.MainRespPerson))
{
this.txtMainRespPerson.Text = majorHazard.MainRespPerson;
}
if (!string.IsNullOrEmpty(majorHazard.MainRespDepartment))
{
this.txtMainRespDepartment.Text = majorHazard.MainRespDepartment;
}
if (!string.IsNullOrEmpty(majorHazard.MainTechPerson))
{
this.txtMainTechPerson.Text = majorHazard.MainTechPerson;
}
//if (!string.IsNullOrEmpty(majorHazard.Type))
//{
// this.drpType.SelectedValue = majorHazard.Type;
//}
if (!string.IsNullOrEmpty(majorHazard.HazardLevel))
{
this.drpHazardLevel.SelectedValue = majorHazard.HazardLevel;
}
}
}
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
//string projectId, string userId, string menuId, string buttonName)
if (BLL.CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.SYHSE_MajorHazardMenuId, BLL.Const.BtnSave))
{
Model.SYHSEData_MajorHazard majorHazard = Funs.DB.SYHSEData_MajorHazard.FirstOrDefault(x => x.Id == Id);
if (majorHazard == null)
{
majorHazard = new Model.SYHSEData_MajorHazard();
majorHazard.Id = Guid.NewGuid().ToString();
Funs.DB.SYHSEData_MajorHazard.InsertOnSubmit(majorHazard);
}
majorHazard.ProjectId = this.CurrUser.LoginProjectId;
majorHazard.UnitId = this.CurrUser.UserId;
majorHazard.CreateMan = this.CurrUser.UserId;
majorHazard.CrateDate = DateTime.Now;
if (!string.IsNullOrEmpty(this.txtDeviceName.Text))
{
majorHazard.DeviceName = this.txtDeviceName.Text;
}
if (!string.IsNullOrEmpty(this.txtHazardName.Text))
{
majorHazard.HazardName = this.txtHazardName.Text;
}
if (!string.IsNullOrEmpty(this.txtHazardCode.Text))
{
majorHazard.HazardCode = this.txtHazardCode.Text;
}
if (!string.IsNullOrEmpty(this.txtMainOperaPerson.Text))
{
majorHazard.MainOperaPerson = this.txtMainOperaPerson.Text;
}
if (!string.IsNullOrEmpty(this.txtMainRespPerson.Text))
{
majorHazard.MainRespPerson = this.txtMainRespPerson.Text;
}
if (!string.IsNullOrEmpty(this.txtMainRespDepartment.Text))
{
majorHazard.MainRespDepartment = this.txtMainRespDepartment.Text;
}
if (!string.IsNullOrEmpty(this.txtMainTechPerson.Text))
{
majorHazard.MainTechPerson = this.txtMainTechPerson.Text;
}
if (!string.IsNullOrEmpty(this.txtMaterial.Text))
{
majorHazard.Material = this.txtMaterial.Text;
}
if (!string.IsNullOrEmpty(this.txtAmount.Text))
{
majorHazard.Amount = this.txtAmount.Text;
}
if (!string.IsNullOrEmpty(this.txtMaxAmount.Text))
{
majorHazard.MaxAmount = this.txtMaxAmount.Text;
}
if (!string.IsNullOrEmpty(this.txtMinAmount.Text))
{
majorHazard.MinAmount = this.txtMinAmount.Text;
}
//if (!string.IsNullOrEmpty(drpType.SelectedValue))
//{
// majorHazard.Type = drpType.SelectedValue;
//}
if (!string.IsNullOrEmpty(drpHazardLevel.SelectedValue))
{
majorHazard.HazardLevel = drpHazardLevel.SelectedValue;
}
majorHazard.ReportDate = this.txtReportDate.SelectedDate;
Funs.DB.SubmitChanges();
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
}
}