using BLL; using System; using System.Linq; namespace FineUIPro.Web.HJGL.BaseInfo { public partial class TestingEdit : PageBase { #region 定义项 /// /// 主键 /// public string DetectionTypeId { get { return (string)ViewState["DetectionTypeId"]; } set { ViewState["DetectionTypeId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { btnClose.OnClientClick = ActiveWindow.GetHideReference(); //系统对应类型 this.drpSysType.DataTextField = "Text"; this.drpSysType.DataValueField = "Value"; this.drpSysType.DataSource = BLL.DropListService.HJGL_GetTestintTypeList(); this.drpSysType.DataBind(); Funs.FineUIPleaseSelect(this.drpSysType); this.DetectionTypeId = Request.Params["DetectionTypeId"]; if (!string.IsNullOrEmpty(this.DetectionTypeId)) { Model.Base_DetectionType DetectionType = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(this.DetectionTypeId); if (DetectionType != null) { this.txtDetectionTypeCode.Text = DetectionType.DetectionTypeCode; this.txtDetectionTypeName.Text = DetectionType.DetectionTypeName; if (!string.IsNullOrEmpty(DetectionType.SysType)) { this.drpSysType.SelectedValue = DetectionType.SysType; } this.txtSecuritySpace.Text = DetectionType.SecuritySpace.ToString(); this.txtInjuryDegree.Text = DetectionType.InjuryDegree; this.txtRemark.Text = DetectionType.Remark; this.txtDescriptions.Text = DetectionType.Descriptions; } } } } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { var q = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.DetectionTypeCode == this.txtDetectionTypeCode.Text.Trim() && (x.DetectionTypeId != this.DetectionTypeId || (this.DetectionTypeId == null && x.DetectionTypeId != null))); if (q != null) { Alert.ShowInTop("此探伤类型代号已经存在!", MessageBoxIcon.Warning); return; } var q2 = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.DetectionTypeName == this.txtDetectionTypeName.Text.Trim() && (x.DetectionTypeId != this.DetectionTypeId || (this.DetectionTypeId == null && x.DetectionTypeId != null))); if (q2 != null) { Alert.ShowInTop("此探伤类型已经存在!", MessageBoxIcon.Warning); return; } Model.Base_DetectionType newDetectionType = new Model.Base_DetectionType { DetectionTypeCode = this.txtDetectionTypeCode.Text.Trim(), DetectionTypeName = this.txtDetectionTypeName.Text.Trim(), SecuritySpace = Funs.GetNewDecimal(this.txtSecuritySpace.Text.Trim()), InjuryDegree=this.txtInjuryDegree.Text.Trim(), Remark = this.txtRemark.Text.Trim(), Descriptions = this.txtDescriptions.Text.Trim() }; if (this.drpSysType.SelectedValue!=BLL.Const._Null) { newDetectionType.SysType = this.drpSysType.SelectedValue; } if (!string.IsNullOrEmpty(this.DetectionTypeId)) { newDetectionType.DetectionTypeId = this.DetectionTypeId; BLL.Base_DetectionTypeService.UpdateDetectionType(newDetectionType); //BLL.Sys_LogService.AddLog(Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_DetectionTypeMenuId, Const.BtnModify, newDetectionType.DetectionTypeId); } else { this.DetectionTypeId = SQLHelper.GetNewID(typeof(Model.Base_DetectionType)); newDetectionType.DetectionTypeId = this.DetectionTypeId; BLL.Base_DetectionTypeService.AddDetectionType(newDetectionType); //BLL.Sys_LogService.AddLog(Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_DetectionTypeMenuId, Const.BtnAdd, newDetectionType.DetectionTypeId); } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion } }