危害因素调整
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using BLL;
|
||||
|
||||
namespace FineUIPro.Web.BaseInfo
|
||||
{
|
||||
public partial class SafetyProblemClassifySave : PageBase
|
||||
{
|
||||
#region 定义变量
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
public string ClassifyId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["ClassifyId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["ClassifyId"] = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 加载
|
||||
/// <summary>
|
||||
/// 加载页面
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
this.GetButtonPower();
|
||||
btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
||||
|
||||
this.ClassifyId = Request.QueryString["ClassifyId"];
|
||||
if (!string.IsNullOrEmpty(ClassifyId))
|
||||
{
|
||||
var q = BLL.SafetyProblemClassifyService.GetClassifyById(ClassifyId);
|
||||
if (q != null)
|
||||
{
|
||||
this.txtClassifyCode.Text = q.ClassifyCode;
|
||||
this.txtClassifyName.Text = q.ClassifyName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 保存
|
||||
/// <summary>
|
||||
/// 保存按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
var obj = Funs.DB.Base_SafetyProblemClassify.FirstOrDefault(x => x.ClassifyCode == this.txtClassifyCode.Text.Trim() && x.ClassifyId != this.ClassifyId);
|
||||
if (obj != null)
|
||||
{
|
||||
ShowNotify("输入的编号已存在!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
obj = Funs.DB.Base_SafetyProblemClassify.FirstOrDefault(x => x.ClassifyName == this.txtClassifyName.Text.Trim() && x.ClassifyId != this.ClassifyId);
|
||||
if (obj != null)
|
||||
{
|
||||
ShowNotify("输入的名称已存在!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Model.Base_SafetyProblemClassify model = new Model.Base_SafetyProblemClassify();
|
||||
model.ClassifyCode = this.txtClassifyCode.Text.Trim();
|
||||
model.ClassifyName = this.txtClassifyName.Text.Trim();
|
||||
if (!string.IsNullOrEmpty(this.ClassifyId))
|
||||
{
|
||||
model.ClassifyId = this.ClassifyId;
|
||||
BLL.SafetyProblemClassifyService.UpdateClassify(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ClassifyId = SQLHelper.GetNewID(typeof(Model.Base_SafetyProblemClassify));
|
||||
model.ClassifyId = this.ClassifyId;
|
||||
BLL.SafetyProblemClassifyService.AddClassify(model);
|
||||
}
|
||||
// 2. 关闭本窗体,然后刷新父窗体
|
||||
// PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
||||
// 2. 关闭本窗体,然后回发父窗体
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
//PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(trainingId) + ActiveWindow.GetHideReference());
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 验证安全问题分类名称是否存在
|
||||
/// <summary>
|
||||
/// 验证安全问题分类名称是否存在
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
var model = Funs.DB.Base_SafetyProblemClassify.FirstOrDefault(x => x.ClassifyName == this.txtClassifyName.Text.Trim() && (x.ClassifyId != this.ClassifyId || this.ClassifyId == null));
|
||||
if (model != null)
|
||||
{
|
||||
ShowNotify("输入的名称已存在!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 按钮权限
|
||||
/// <summary>
|
||||
/// 获取按钮权限
|
||||
/// </summary>
|
||||
/// <param name="button"></param>
|
||||
/// <returns></returns>
|
||||
private void GetButtonPower()
|
||||
{
|
||||
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.SafetyProblemClassifyMenuId);
|
||||
if (buttonList.Count() > 0)
|
||||
{
|
||||
if (buttonList.Contains(BLL.Const.BtnSave))
|
||||
{
|
||||
this.btnSave.Hidden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user