| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  | using BLL; | 
					
						
							|  |  |  |  | using Model; | 
					
						
							|  |  |  |  | using Newtonsoft.Json.Linq; | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Data; | 
					
						
							|  |  |  |  | using System.Data.SqlClient; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Web; | 
					
						
							|  |  |  |  | using System.Web.UI; | 
					
						
							|  |  |  |  | using System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.JDGL.Check | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class MonthPlanEditNew : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         #region 定义项 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 主键 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private string Id | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (string)ViewState["Id"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["Id"] = value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 默认月 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private string Months | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (string)ViewState["Months"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["Months"] = value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 项目主键 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public string ProjectId | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (string)ViewState["ProjectId"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["ProjectId"] = value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.Id = Request.Params["Id"]; | 
					
						
							|  |  |  |  |                 this.ProjectId = this.CurrUser.LoginProjectId; | 
					
						
							|  |  |  |  |                 BLL.ProjectUnitService.InitUnitDropDownList(drpUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, false); | 
					
						
							| 
									
										
										
										
											2025-03-25 10:47:40 +08:00
										 |  |  |  |                 //五环责任人 | 
					
						
							|  |  |  |  |                 UserService.Init2(drpDutyPerson, this.CurrUser.LoginProjectId, false); | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                 if (!string.IsNullOrEmpty(Id)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     var model = Funs.DB.JDGL_MonthPlan.FirstOrDefault(x => x.MonthPlanId == Id); | 
					
						
							|  |  |  |  |                     if (model != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         txtMonths.Text = string.Format("{0:yyyy-MM}", model.Months); | 
					
						
							|  |  |  |  |                         txtMonths.Readonly = true; | 
					
						
							|  |  |  |  |                         drpUnit.SelectedValue = model.UnitId; | 
					
						
							| 
									
										
										
										
											2025-05-24 14:48:16 +08:00
										 |  |  |  |                         if (model.IsOK == true) | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             this.drpIsOK.SelectedValue = "已完成"; | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                         else | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             this.drpIsOK.SelectedValue = "未完成"; | 
					
						
							|  |  |  |  |                         } | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                         if (!string.IsNullOrEmpty(model.DutyPerson)) | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             List<string> listPersonId = model.DutyPerson.Split(',').ToList(); | 
					
						
							|  |  |  |  |                             drpDutyPerson.SelectedValueArray = listPersonId.ToArray(); | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                         if (model.PlanDate != null) | 
					
						
							|  |  |  |  |                             this.txtPlanDate.Text = Convert.ToDateTime(model.PlanDate).ToString("yyyy-MM-dd"); | 
					
						
							|  |  |  |  |                         if (model.RealDate != null) | 
					
						
							|  |  |  |  |                             this.txtRealDate.Text = Convert.ToDateTime(model.RealDate).ToString("yyyy-MM-dd"); | 
					
						
							|  |  |  |  |                         txtNodeContent.Text = model.NodeContent; | 
					
						
							|  |  |  |  |                         txtRemark.Text = model.Remark; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.Months = Request.Params["Months"]; | 
					
						
							|  |  |  |  |                     this.txtMonths.Text = !string.IsNullOrWhiteSpace(this.Months) ? this.Months : DateTime.Now.ToString("yyyy-MM"); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-24 14:48:16 +08:00
										 |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 完成时间选择后触发事件 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void RealDate_TextChanged(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             var txtRealDate = this.txtRealDate.Text.Trim(); | 
					
						
							|  |  |  |  |             if (!string.IsNullOrWhiteSpace(txtRealDate)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.drpIsOK.SelectedValue = "已完成"; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 保存 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnSave_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             var Months = Convert.ToDateTime(this.txtMonths.Text + "-01"); | 
					
						
							|  |  |  |  |             var model = new Model.JDGL_MonthPlan | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Months = Months, | 
					
						
							|  |  |  |  |                 UnitId = drpUnit.SelectedValue, | 
					
						
							|  |  |  |  |                 NodeContent = txtNodeContent.Text, | 
					
						
							|  |  |  |  |                 Remark = txtRemark.Text, | 
					
						
							|  |  |  |  |                 PlanDate = Funs.GetNewDateTime(this.txtPlanDate.Text), | 
					
						
							|  |  |  |  |                 CompileMan = this.CurrUser.UserId, | 
					
						
							|  |  |  |  |                 CompileDate = DateTime.Now, | 
					
						
							|  |  |  |  |             }; | 
					
						
							| 
									
										
										
										
											2025-05-24 14:48:16 +08:00
										 |  |  |  |             model.IsOK = this.drpIsOK.SelectedValue == "已完成"; | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |             if (!string.IsNullOrWhiteSpace(this.txtRealDate.Text)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 model.RealDate = Funs.GetNewDateTime(this.txtRealDate.Text); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             model.DutyPerson = string.Join(",", drpDutyPerson.SelectedValueArray); | 
					
						
							|  |  |  |  |             //foreach (var item in this.drpDutyPerson.SelectedValueArray) | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  |             //    if (item != BLL.Const._Null) | 
					
						
							|  |  |  |  |             //    { | 
					
						
							|  |  |  |  |             //        if (string.IsNullOrEmpty(model.DutyPerson)) | 
					
						
							|  |  |  |  |             //        { | 
					
						
							|  |  |  |  |             //            model.DutyPerson = item; | 
					
						
							|  |  |  |  |             //        } | 
					
						
							|  |  |  |  |             //        else | 
					
						
							|  |  |  |  |             //        { | 
					
						
							|  |  |  |  |             //            model.DutyPerson += "," + item; | 
					
						
							|  |  |  |  |             //        } | 
					
						
							|  |  |  |  |             //    } | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(Id)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 model.MonthPlanId = Id; | 
					
						
							|  |  |  |  |                 BLL.MonthPlanService.UpdateMonthPlan(model); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var lastMonthPlan = Funs.DB.JDGL_MonthPlan.Where(p => p.ProjectId == this.ProjectId && p.Months == Months).OrderByDescending(x => x.SortIndex).FirstOrDefault(); | 
					
						
							|  |  |  |  |                 model.MonthPlanId = SQLHelper.GetNewID(typeof(Model.JDGL_MonthPlan)); | 
					
						
							|  |  |  |  |                 model.ProjectId = this.ProjectId; | 
					
						
							|  |  |  |  |                 model.SortIndex = lastMonthPlan != null ? lastMonthPlan.SortIndex + 1 : 1; | 
					
						
							|  |  |  |  |                 BLL.MonthPlanService.AddMonthPlan(model); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             Funs.DB.SubmitChanges(); | 
					
						
							|  |  |  |  |             ShowNotify("保存成功", MessageBoxIcon.Success); | 
					
						
							|  |  |  |  |             PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |