| 
									
										
										
										
											2023-03-09 14:50:40 +08:00
										 |  |  |  | using BLL; | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Web; | 
					
						
							|  |  |  |  | using System.Web.UI; | 
					
						
							|  |  |  |  | using System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | using AspNet = System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.BaseInfo | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class BaseFactoryEdit: PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         #region   | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 主键 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public string FactoryId | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (string)ViewState["FactoryId"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["FactoryId"] = value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.btnClose.OnClientClick = ActiveWindow.GetHideReference();              | 
					
						
							|  |  |  |  |                 ////权限按钮方法 | 
					
						
							|  |  |  |  |                 this.GetButtonPower(); | 
					
						
							|  |  |  |  |                 this.FactoryId = Request.Params["FactoryId"]; | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(this.FactoryId)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     Model.Base_Factory model = BLL.Base_FactoryService.GetBase_FactoryById(this.FactoryId); | 
					
						
							|  |  |  |  |                     if (model != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.txtFactoryCode.Text = model.FactoryCode; | 
					
						
							|  |  |  |  |                         this.txtFactoryName.Text = model.FactoryName; | 
					
						
							|  |  |  |  |                         this.txtAddress.Text = model.Address; | 
					
						
							| 
									
										
										
										
											2023-03-10 10:23:33 +08:00
										 |  |  |  |                         this.txtMapCoordinates.Text = model.MapCoordinates; | 
					
						
							| 
									
										
										
										
											2023-03-09 14:50:40 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 保存按钮 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnSave_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsSaveCode()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ShowNotify("编号重复,请注意!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             Model.Base_Factory table = new Model.Base_Factory(); | 
					
						
							|  |  |  |  |             table.UnitId = BLL.Const.UnitId_CWCEC; | 
					
						
							|  |  |  |  |             table.FactoryCode = this.txtFactoryCode.Text; | 
					
						
							|  |  |  |  |             table.FactoryName = this.txtFactoryName.Text; | 
					
						
							|  |  |  |  |             table.Address = this.txtAddress.Text; | 
					
						
							| 
									
										
										
										
											2023-03-10 10:23:33 +08:00
										 |  |  |  |             table.MapCoordinates=this.txtMapCoordinates.Text; | 
					
						
							| 
									
										
										
										
											2023-03-09 14:50:40 +08:00
										 |  |  |  |             if (string.IsNullOrEmpty(this.FactoryId)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 table.FactoryId = SQLHelper.GetNewID(typeof(Model.Base_Factory)); | 
					
						
							|  |  |  |  |                 BLL.Base_FactoryService.AddBase_Factory(table); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 table.FactoryId = this.FactoryId; | 
					
						
							|  |  |  |  |                 BLL.Base_FactoryService.UpdateBase_Factory(table); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         protected bool IsSaveCode() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             bool result = true; | 
					
						
							|  |  |  |  |             var model = BLL.Base_FactoryService.GetBase_FactoryByCode(this.txtFactoryCode.Text); | 
					
						
							|  |  |  |  |             if(model != null && model.FactoryId !=this.FactoryId)  | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 result=false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return result; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #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.Base_FactoryMenuId); | 
					
						
							|  |  |  |  |             if (buttonList.Count() > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (buttonList.Contains(BLL.Const.BtnSave)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.btnSave.Hidden = false; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion         | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |