Basf_TCC11/HJGL/FineUIPro.Web/PublicInfo/BaseInfo/TestingEdit.aspx.cs

117 lines
5.1 KiB
C#

using BLL;
using System;
using System.Linq;
namespace FineUIPro.Web.PublicInfo.BaseInfo
{
public partial class TestingEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string DetectionTypeId
{
get
{
return (string)ViewState["DetectionTypeId"];
}
set
{
ViewState["DetectionTypeId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.txtDetectionTypeCode.Focus();
btnClose.OnClientClick = ActiveWindow.GetHideReference();
this.drpSysType.DataTextField = "Text";
this.drpSysType.DataValueField = "Value";
this.drpSysType.DataSource = BLL.DropListService.HJGL_GetTestintTypeList();
this.drpSysType.DataBind();
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;
this.drpSysType.SelectedValue = DetectionType.SysType;
this.txtSecuritySpace.Text = DetectionType.SecuritySpace != null ? DetectionType.SecuritySpace.ToString() : "";
txtTestStandard.Text = DetectionType.TestStandard;
txtTechLevel.Text = DetectionType.TechLevel;
this.txtInjuryDegree.Text = DetectionType.InjuryDegree;
this.txtRemark.Text = DetectionType.Remark;
}
}
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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(Resources.Lan.NDETypeCodeExists, 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(Resources.Lan.NDETypeNameExists, MessageBoxIcon.Warning);
return;
}
Model.Base_DetectionType newDetectionType = new Model.Base_DetectionType
{
DetectionTypeCode = this.txtDetectionTypeCode.Text.Trim(),
DetectionTypeName = this.txtDetectionTypeName.Text.Trim(),
SysType = this.drpSysType.SelectedValue,
SecuritySpace = Funs.GetNewDecimal(this.txtSecuritySpace.Text.Trim()),
TestStandard = txtTestStandard.Text.Trim(),
TechLevel=txtTechLevel.Text.Trim(),
InjuryDegree=this.txtInjuryDegree.Text.Trim(),
Remark = this.txtRemark.Text.Trim()
};
if (!string.IsNullOrEmpty(this.DetectionTypeId))
{
newDetectionType.DetectionTypeId = this.DetectionTypeId;
BLL.Base_DetectionTypeService.UpdateDetectionType(newDetectionType);
BLL.Sys_LogService.AddLog(Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.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_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.DetectionTypeMenuId, Const.BtnAdd, newDetectionType.DetectionTypeId);
}
ShowNotify(Resources.Lan.SaveSuccessfully, MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}