| 
									
										
										
										
											2024-07-04 14:01:20 +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; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.HSSE.CostGoods | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class FeeRegistrationEdit : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         #region 定义项 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 主键 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public string Id | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (string)ViewState["Id"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["Id"] = 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(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-05 14:11:35 +08:00
										 |  |  |  |                 BLL.UnitService.InitUnitDownList(this.drpUnitId, this.CurrUser.LoginProjectId, true); | 
					
						
							| 
									
										
										
										
											2024-07-04 14:01:20 +08:00
										 |  |  |  |                 //如果不是中国五环工程有限公司,只加载自己的 | 
					
						
							|  |  |  |  |                 if (CurrUser.UnitId == CommonService.GetThisUnitId() || CurrUser.UserId == Const.hfnbdId) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     drpUnitId.Readonly = false; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else { | 
					
						
							|  |  |  |  |                     drpUnitId.Readonly = true; | 
					
						
							|  |  |  |  |                     drpUnitId.SelectedValue = CurrUser.UnitId; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 this.Id = Request.Params["Id"]; | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(this.Id)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     var result = BLL.FeeRegistration.Detail(this.Id); | 
					
						
							|  |  |  |  |                     if (result != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         | 
					
						
							|  |  |  |  |                         if (!string.IsNullOrEmpty(result.UnitId)) | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             this.drpUnitId.SelectedValue = result.UnitId; | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                         if (result.CompileDate != null) | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", result.CompileDate); | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                         this.txtCost.Text = result.Cost.ToString(); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); | 
					
						
							|  |  |  |  |                    | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 if (Request.Params["value"] == "0") | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.btnSave.Hidden = true; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 保存 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 保存按钮 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnSave_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (this.drpUnitId.SelectedValue == BLL.Const._Null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Alert.ShowInTop("请选择单位名称!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             SaveData(); | 
					
						
							|  |  |  |  |             PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 保存数据 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="type"></param> | 
					
						
							|  |  |  |  |         private void SaveData() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             var model = new Model.CostGoods_FeeRegistration | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ProjectId = this.CurrUser.LoginProjectId, | 
					
						
							|  |  |  |  |                 | 
					
						
							|  |  |  |  |             }; | 
					
						
							|  |  |  |  |             if (this.drpUnitId.SelectedValue != BLL.Const._Null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 model.UnitId = this.drpUnitId.SelectedValue; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             model.Cost =Convert.ToDecimal(this.txtCost.Text.Trim()); | 
					
						
							|  |  |  |  |             model.CompileMan = this.CurrUser.UserId; | 
					
						
							|  |  |  |  |             model.CompileDate = Funs.GetNewDateTime(this.txtCompileDate.Text.Trim()); | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(this.Id)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 model.Id = this.Id; | 
					
						
							|  |  |  |  |                 BLL.FeeRegistration.Update(model); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.Id = SQLHelper.GetNewID(typeof(Model.CostGoods_MeasuresPlan)); | 
					
						
							|  |  |  |  |                 model.Id = this.Id; | 
					
						
							|  |  |  |  |                 BLL.FeeRegistration.Insert(model); | 
					
						
							|  |  |  |  |                  | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |