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_RiskEdit : PageBase { #region 公共字段 /// /// 主键 /// public string Id { get { return (string)ViewState["Id"]; } set { ViewState["Id"] = value; } } #endregion /// /// 把状态转换代号为文字形式 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Id = Request.Params["Id"]; if (!string.IsNullOrEmpty(Id)) { var risk = Funs.DB.SYHSEData_Risk.FirstOrDefault(x => x.Id == Id); if (risk != null) { if (risk.ReportDate.HasValue) { this.txtReportDate.Text = risk.ReportDate.Value.ToString("yyyy-MM-dd"); } this.txtControlObject.Text = risk.ControlObject; this.txtRespDepartment.Text = risk.RespDepartment; this.txtRespPerson.Text = risk.RespPerson; this.txtAnalysisUnit.Text = risk.AnalysisUnit; this.txtRiskEvent.Text = risk.RiskEvent; this.txtRiskLevel.Text = risk.RiskLevel; } } } } 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_PromiseMenuId, BLL.Const.BtnSave)) { Model.SYHSEData_Risk risk = Funs.DB.SYHSEData_Risk.FirstOrDefault(x => x.Id == Id); if (risk == null) { risk = new Model.SYHSEData_Risk(); risk.Id = Guid.NewGuid().ToString(); Funs.DB.SYHSEData_Risk.InsertOnSubmit(risk); } risk.ReportDate = this.txtReportDate.SelectedDate; risk.ProjectId = this.CurrUser.LoginProjectId; risk.CreateMan = this.CurrUser.UserId; risk.CreateDate = DateTime.Now; risk.ControlObject = this.txtControlObject.Text; risk.RespDepartment = this.txtRespDepartment.Text; risk.RespPerson = this.txtRespPerson.Text; risk.AnalysisUnit = this.txtAnalysisUnit.Text; risk.RiskEvent = this.txtRiskEvent.Text; risk.RiskLevel = this.txtRiskLevel.Text; Funs.DB.SubmitChanges(); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } } }