SGGL_SHJ/SGGL/FineUIPro.Web/SmartSite/EquipmentManageEdit.aspx.cs

167 lines
5.7 KiB
C#
Raw Normal View History

using BLL;
using FineUIPro.Web.CQMS.Material;
using System;
using System.Linq;
namespace FineUIPro.Web.SmartSite
{
public partial class EquipmentManageEdit : PageBase
{
#region
/// <summary>
/// 安全措施主键
/// </summary>
public string EquipmentId
{
get
{
return (string)ViewState["EquipmentId"];
}
set
{
ViewState["EquipmentId"] = value;
}
}
/// <summary>
/// 类型
/// </summary>
public string Type
{
get
{
return (string)ViewState["Type"];
}
set
{
ViewState["Type"] = value;
}
}
/// <summary>
/// 菜单id
/// </summary>
public string MenuId
{
get
{
return (string)ViewState["MenuId"];
}
set
{
ViewState["MenuId"] = value;
}
}
#endregion
/// <summary>
/// 安全措施编辑页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
this.EquipmentId = Request.Params["EquipmentId"];
this.Type = Request.Params["type"];
if (this.Type == "D")
{
this.MenuId = Const.EquipmentManageDMenuId;
}
else if (this.Type == "M")
{
this.MenuId = Const.EquipmentManageMMenuId;
}
else
{
this.MenuId = Const.EquipmentManageEMenuId;
}
///权限
this.GetButtonPower();
ProjectService.InitProjectDropDownList(this.drpProject, true);
if (!string.IsNullOrEmpty(this.EquipmentId))
{
var Equipment = BLL.EquipmentService.GetEquipmentByEquipmentId(this.EquipmentId);
if (Equipment != null)
{
ProjectService.InitAllProjectDropDownList(this.drpProject, true);
this.drpProject.SelectedValue = Equipment.ProjectId;
this.Type = Equipment.Type;
this.txtEquipmentName.Text = Equipment.EquipmentName;
this.txtEquipmentModel.Text = Equipment.EquipmentModel;
this.txtNumber.Text = Equipment.Number.ToString();
this.txtRunningState.Text = Equipment.RunningState;
this.txtSupplier.Text = Equipment.Supplier;
this.txtSupplierMan.Text = Equipment.SupplierMan;
this.txtSupplierTel.Text = Equipment.SupplierTel;
}
}
}
}
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (this.drpProject.SelectedValue == Const._Null)
{
Alert.ShowInParent("请选择项目!", MessageBoxIcon.Warning);
return;
}
Model.SmartSite_Equipment newEquipment = new Model.SmartSite_Equipment
{
EquipmentName = this.txtEquipmentName.Text.Trim(),
Type = this.Type,
EquipmentModel = this.txtEquipmentModel.Text.Trim(),
Number = Funs.GetNewIntOrZero(this.txtNumber.Text.Trim()),
RunningState = this.txtRunningState.Text.Trim(),
Supplier = this.txtSupplier.Text.Trim(),
SupplierMan = this.txtSupplierMan.Text.Trim(),
SupplierTel = this.txtSupplierTel.Text.Trim(),
};
if (this.drpProject.SelectedValue != Const._Null)
{
newEquipment.ProjectId = this.drpProject.SelectedValue;
}
if (string.IsNullOrEmpty(this.EquipmentId))
{
newEquipment.EquipmentId = SQLHelper.GetNewID();
BLL.EquipmentService.AddEquipment(newEquipment);
BLL.LogService.AddSys_Log(this.CurrUser, newEquipment.EquipmentName, newEquipment.EquipmentId, this.MenuId, Const.BtnAdd);
}
else
{
newEquipment.EquipmentId = this.EquipmentId;
BLL.EquipmentService.UpdateEquipment(newEquipment);
BLL.LogService.AddSys_Log(this.CurrUser, newEquipment.EquipmentName, newEquipment.EquipmentId, this.MenuId, Const.BtnModify);
}
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
#region
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, this.MenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnSave))
{
this.btnSave.Hidden = false;
}
}
}
#endregion
}
}