using BLL; using FineUIPro.Web.CQMS.Material; using System; using System.Linq; namespace FineUIPro.Web.SmartSite { public partial class EquipmentManageEdit : PageBase { #region 定义项 /// /// 安全措施主键 /// public string EquipmentId { get { return (string)ViewState["EquipmentId"]; } set { ViewState["EquipmentId"] = value; } } /// /// 类型 /// public string Type { get { return (string)ViewState["Type"]; } set { ViewState["Type"] = value; } } /// /// 菜单id /// public string MenuId { get { return (string)ViewState["MenuId"]; } set { ViewState["MenuId"] = value; } } #endregion /// /// 安全措施编辑页面 /// /// /// 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; } } } } /// /// 保存按钮 /// /// /// 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 获取按钮权限 /// /// 获取按钮权限 /// /// /// 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 } }