| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Data; | 
					
						
							|  |  |  |  | using System.Data.OleDb; | 
					
						
							|  |  |  |  | using System.IO; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  | using System.Text; | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  | using System.Web; | 
					
						
							|  |  |  |  | using System.Web.UI; | 
					
						
							|  |  |  |  | using System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | using BLL; | 
					
						
							| 
									
										
										
										
											2022-06-14 18:21:58 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  | namespace FineUIPro.Web.JDGL.WBS | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class WorkloadInputIn : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |         #region 定义变量 | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |         /// <summary> | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |         /// 列数量 | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |         /// </summary> | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |         public int ColumnNum | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                 return (int)ViewState["ColumnNum"]; | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                 ViewState["ColumnNum"] = value; | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 上传预设的虚拟路径 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private string initPath = Const.ExcelUrl; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |         /// 错误集合 | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |         /// </summary> | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |         public static string errorInfos = string.Empty; | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |         /// 月份集合 | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |         /// </summary> | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |         public static List<DateTime> months = new List<DateTime>(); | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 加载表头 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         protected void Page_Init(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             InitGrid(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 表头 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 表头 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private void InitGrid() | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |             ColumnNum = 0; | 
					
						
							|  |  |  |  |             months.Clear(); | 
					
						
							|  |  |  |  |             var installation = Funs.DB.Project_Installation.FirstOrDefault(x => x.SuperInstallationId == "0" && x.ProjectId == this.CurrUser.LoginProjectId); | 
					
						
							|  |  |  |  |             if (installation != null) | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                 DateTime startDate, endDate, startMonth, endMonth; | 
					
						
							|  |  |  |  |                 if (installation.StartDate != null && installation.EndDate != null) | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                     startDate = Convert.ToDateTime(installation.StartDate); | 
					
						
							|  |  |  |  |                     endDate = Convert.ToDateTime(installation.EndDate); | 
					
						
							|  |  |  |  |                     startMonth = Convert.ToDateTime(startDate.Year + "-" + startDate.Month + "-01"); | 
					
						
							|  |  |  |  |                     endMonth = Convert.ToDateTime(endDate.Year + "-" + endDate.Month + "-01"); | 
					
						
							|  |  |  |  |                     do | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         months.Add(startMonth); | 
					
						
							|  |  |  |  |                         startMonth = startMonth.AddMonths(1); | 
					
						
							|  |  |  |  |                     } while (startMonth <= endMonth); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 for (int i = 0; i < months.Count; i++) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     RenderField rdPlan = new RenderField(); | 
					
						
							|  |  |  |  |                     rdPlan.ColumnID = string.Format("{0:yyyy-MM}", months[i]) + "Plan"; | 
					
						
							|  |  |  |  |                     rdPlan.Width = Unit.Pixel(100); | 
					
						
							|  |  |  |  |                     rdPlan.DataField = "PlanNum" + (i + 1).ToString(); | 
					
						
							|  |  |  |  |                     rdPlan.FieldType = FieldType.Double; | 
					
						
							|  |  |  |  |                     rdPlan.HeaderText = string.Format("{0:yyyy年MM月}", months[i]) + "<br/>计划量"; | 
					
						
							|  |  |  |  |                     rdPlan.HeaderTextAlign = TextAlign.Center; | 
					
						
							|  |  |  |  |                     NumberBox numPlan = new NumberBox(); | 
					
						
							|  |  |  |  |                     numPlan.NoNegative = true; | 
					
						
							|  |  |  |  |                     numPlan.NoDecimal = false; | 
					
						
							|  |  |  |  |                     rdPlan.Editor.Add(numPlan); | 
					
						
							|  |  |  |  |                     Grid1.Columns.Add(rdPlan); | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                     RenderField rdThis = new RenderField(); | 
					
						
							|  |  |  |  |                     rdThis.ColumnID = string.Format("{0:yyyy-MM}", months[i]) + "This"; | 
					
						
							|  |  |  |  |                     rdThis.Width = Unit.Pixel(100); | 
					
						
							|  |  |  |  |                     rdThis.DataField = "ThisNum" + (i + 1).ToString(); | 
					
						
							|  |  |  |  |                     rdThis.FieldType = FieldType.Double; | 
					
						
							|  |  |  |  |                     rdThis.HeaderText = string.Format("{0:yyyy年MM月}", months[i]) + "<br/>完成量"; | 
					
						
							|  |  |  |  |                     rdThis.HeaderTextAlign = TextAlign.Center; | 
					
						
							|  |  |  |  |                     NumberBox numReal = new NumberBox(); | 
					
						
							|  |  |  |  |                     numReal.NoNegative = true; | 
					
						
							|  |  |  |  |                     numReal.NoDecimal = false; | 
					
						
							|  |  |  |  |                     rdThis.Editor.Add(numReal); | 
					
						
							|  |  |  |  |                     Grid1.Columns.Add(rdThis); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 RenderField rdId = new RenderField(); | 
					
						
							|  |  |  |  |                 rdId.ColumnID = "ShowId"; | 
					
						
							|  |  |  |  |                 rdId.Width = Unit.Pixel(350); | 
					
						
							|  |  |  |  |                 rdId.DataField = "ShowId"; | 
					
						
							|  |  |  |  |                 rdId.FieldType = FieldType.String; | 
					
						
							|  |  |  |  |                 rdId.HeaderText = "ShowId"; | 
					
						
							|  |  |  |  |                 rdId.HeaderTextAlign = TextAlign.Center; | 
					
						
							|  |  |  |  |                 Grid1.Columns.Add(rdId); | 
					
						
							|  |  |  |  |                 rdId.Hidden = true; | 
					
						
							| 
									
										
										
										
											2022-06-14 18:21:58 +08:00
										 |  |  |  |                 ColumnNum = 9 + months.Count * 2 + 1; | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 加载 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 加载页面 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 errorInfos = string.Empty; | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                 this.hdFileName.Text = string.Empty; | 
					
						
							|  |  |  |  |                 this.hdCheckResult.Text = string.Empty; | 
					
						
							| 
									
										
										
										
											2023-07-25 17:32:36 +08:00
										 |  |  |  |                 DataTable table = BLL.WorkloadStatisticsService.GetAllTreeDataTable(this.CurrUser.LoginProjectId, string.Empty,string.Empty); | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                 Grid1.DataSource = table; | 
					
						
							|  |  |  |  |                 Grid1.DataBind(); | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |         #region 导出按钮 | 
					
						
							|  |  |  |  |         /// 导出按钮 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnOut_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Response.ClearContent(); | 
					
						
							|  |  |  |  |             string filename = Funs.GetNewFileName(); | 
					
						
							|  |  |  |  |             Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("项目进度情况" + filename, System.Text.Encoding.UTF8) + ".xls"); | 
					
						
							|  |  |  |  |             Response.ContentType = "application/excel"; | 
					
						
							|  |  |  |  |             Response.ContentEncoding = Encoding.UTF8; | 
					
						
							|  |  |  |  |             this.Grid1.Columns[ColumnNum - 1].Hidden = false; | 
					
						
							| 
									
										
										
										
											2023-07-25 17:32:36 +08:00
										 |  |  |  |             DataTable tableOut = BLL.WorkloadStatisticsService.GetAllTreeDataTable(this.CurrUser.LoginProjectId, "Out", string.Empty); | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |             Grid1.DataSource = tableOut; | 
					
						
							|  |  |  |  |             Grid1.DataBind(); | 
					
						
							|  |  |  |  |             this.Grid1.PageSize = Grid1.RecordCount; | 
					
						
							|  |  |  |  |             Response.Write(GetGridTableHtml2(Grid1)); | 
					
						
							|  |  |  |  |             Response.End(); | 
					
						
							|  |  |  |  |             this.Grid1.Columns[ColumnNum - 1].Hidden = true; | 
					
						
							| 
									
										
										
										
											2023-07-25 17:32:36 +08:00
										 |  |  |  |             DataTable table = BLL.WorkloadStatisticsService.GetAllTreeDataTable(this.CurrUser.LoginProjectId, string.Empty, string.Empty); | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |             Grid1.DataSource = table; | 
					
						
							|  |  |  |  |             Grid1.DataBind(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 审核 | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |         /// <summary> | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |         /// 审核 | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnAudit_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (this.fuAttachUrl.HasFile == false) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     ShowNotify("请您选择Excel文件!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                     return; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 string IsXls = Path.GetExtension(this.fuAttachUrl.FileName).ToString().Trim().ToLower(); | 
					
						
							|  |  |  |  |                 if (IsXls != ".xls") | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     ShowNotify("只可以选择Excel文件!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                     return; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 string rootPath = Server.MapPath("~/"); | 
					
						
							|  |  |  |  |                 string initFullPath = rootPath + initPath; | 
					
						
							|  |  |  |  |                 if (!Directory.Exists(initFullPath)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     Directory.CreateDirectory(initFullPath); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 this.hdFileName.Text = BLL.Funs.GetNewFileName() + IsXls; | 
					
						
							|  |  |  |  |                 string filePath = initFullPath + this.hdFileName.Text; | 
					
						
							|  |  |  |  |                 this.fuAttachUrl.PostedFile.SaveAs(filePath); | 
					
						
							|  |  |  |  |                 ImportXlsToData(rootPath + initPath + this.hdFileName.Text); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ShowNotify("'" + ex.Message + "'", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 读Excel提取数据 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 从Excel提取数据--》Dataset | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="filename">Excel文件路径名</param> | 
					
						
							|  |  |  |  |         private void ImportXlsToData(string fileName) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2023-03-09 14:50:40 +08:00
										 |  |  |  |                 //strConn = "Provider=Microsoft.Jet.OleDb.4.0;" +  | 
					
						
							|  |  |  |  |                 //    "data source=" + Server.MapPath("ExcelFiles/MyExcelFile.xls") +  | 
					
						
							|  |  |  |  |                 //    ";Extended Properties='Excel 8.0; HDR=Yes; IMEX=1'"; //此连接只能操作Excel2003或之前版本(.xls)文件 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                 string oleDBConnString = String.Empty; | 
					
						
							|  |  |  |  |                 oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;"; | 
					
						
							|  |  |  |  |                 oleDBConnString += "Data Source="; | 
					
						
							|  |  |  |  |                 oleDBConnString += fileName; | 
					
						
							|  |  |  |  |                 oleDBConnString += ";Extended Properties=Excel 8.0;"; | 
					
						
							|  |  |  |  |                 OleDbConnection oleDBConn = null; | 
					
						
							|  |  |  |  |                 OleDbDataAdapter oleAdMaster = null; | 
					
						
							|  |  |  |  |                 DataTable m_tableName = new DataTable(); | 
					
						
							|  |  |  |  |                 DataSet ds = new DataSet(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 oleDBConn = new OleDbConnection(oleDBConnString); | 
					
						
							|  |  |  |  |                 oleDBConn.Open(); | 
					
						
							|  |  |  |  |                 m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 if (m_tableName != null && m_tableName.Rows.Count > 0) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     m_tableName.TableName = m_tableName.Rows[0]["TABLE_NAME"].ToString().Trim(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 string sqlMaster; | 
					
						
							|  |  |  |  |                 sqlMaster = " SELECT *  FROM [" + m_tableName.TableName + "]"; | 
					
						
							|  |  |  |  |                 oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn); | 
					
						
							|  |  |  |  |                 oleAdMaster.Fill(ds, "m_tableName"); | 
					
						
							|  |  |  |  |                 oleAdMaster.Dispose(); | 
					
						
							|  |  |  |  |                 oleDBConn.Close(); | 
					
						
							|  |  |  |  |                 oleDBConn.Dispose(); | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                 hdCheckResult.Text = "1"; | 
					
						
							|  |  |  |  |                 AddDatasetToSQL(ds.Tables[0], ColumnNum); | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception exc) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Response.Write(exc); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 将Dataset的数据导入数据库 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 将Dataset的数据导入数据库 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="pds">数据集</param> | 
					
						
							|  |  |  |  |         /// <param name="Cols">数据集行数</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         private bool AddDatasetToSQL(DataTable pds, int Cols) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string result = string.Empty; | 
					
						
							|  |  |  |  |             int ic, ir; | 
					
						
							|  |  |  |  |             ic = pds.Columns.Count; | 
					
						
							|  |  |  |  |             if (ic < Cols) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ShowNotify("导入Excel格式错误!Excel只有" + ic.ToString().Trim() + "列", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             ir = pds.Rows.Count; | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |             if (pds != null && ir > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                 var oldViewInfos = from x in Funs.DB.WBS_CostControl | 
					
						
							|  |  |  |  |                                    where x.ProjectId == this.CurrUser.LoginProjectId | 
					
						
							|  |  |  |  |                                    select x; | 
					
						
							|  |  |  |  |                 var units = from x in Funs.DB.Base_Unit | 
					
						
							|  |  |  |  |                             select x; | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                 for (int i = 0; i < ir; i++) | 
					
						
							|  |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                     Model.WBS_CostControl oldViewInfo = oldViewInfos.FirstOrDefault(x => x.CostControlId == pds.Rows[i][Cols - 1].ToString()); | 
					
						
							|  |  |  |  |                     if (oldViewInfo != null) | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                     { | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                         for (int j = 2; j < Cols - 1; j++) | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                         { | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                             string row = pds.Rows[i][j].ToString(); | 
					
						
							|  |  |  |  |                             if (!string.IsNullOrEmpty(row)) | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                             { | 
					
						
							| 
									
										
										
										
											2022-06-14 18:21:58 +08:00
										 |  |  |  |                                 if (j != 5 && j != 6 && j != 7 && j != 8) | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                                 { | 
					
						
							| 
									
										
										
										
											2022-06-14 18:21:58 +08:00
										 |  |  |  |                                     try | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                                     { | 
					
						
							| 
									
										
										
										
											2022-06-14 18:21:58 +08:00
										 |  |  |  |                                         decimal d = Convert.ToDecimal(row.Trim()); | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                                     } | 
					
						
							| 
									
										
										
										
											2022-06-14 18:21:58 +08:00
										 |  |  |  |                                     catch (Exception) | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                                     { | 
					
						
							| 
									
										
										
										
											2022-06-14 18:21:58 +08:00
										 |  |  |  |                                         if (j == 2) | 
					
						
							|  |  |  |  |                                         { | 
					
						
							|  |  |  |  |                                             result += "第" + (i + 2).ToString() + "行," + "合同工作量" + "," + "[" + row + "]格式错误!" + "|"; | 
					
						
							|  |  |  |  |                                         } | 
					
						
							|  |  |  |  |                                         else if (j == 3) | 
					
						
							|  |  |  |  |                                         { | 
					
						
							|  |  |  |  |                                             result += "第" + (i + 2).ToString() + "行," + "预算单价" + "," + "[" + row + "]格式错误!" + "|"; | 
					
						
							|  |  |  |  |                                         } | 
					
						
							|  |  |  |  |                                         else if (j == 4) | 
					
						
							|  |  |  |  |                                         { | 
					
						
							|  |  |  |  |                                             result += "第" + (i + 2).ToString() + "行," + "实际单价" + "," + "[" + row + "]格式错误!" + "|"; | 
					
						
							|  |  |  |  |                                         } | 
					
						
							|  |  |  |  |                                         else if (j % 2 == 1)  //奇数列 | 
					
						
							|  |  |  |  |                                         { | 
					
						
							|  |  |  |  |                                             result += "第" + (i + 2).ToString() + "行," + string.Format("{0:yyyy-MM}", months[j - 9]) + "计划量" + "," + "[" + row + "]格式错误!" + "|"; | 
					
						
							|  |  |  |  |                                         } | 
					
						
							|  |  |  |  |                                         else | 
					
						
							|  |  |  |  |                                         { | 
					
						
							|  |  |  |  |                                             result += "第" + (i + 2).ToString() + "行," + string.Format("{0:yyyy-MM}", months[j - 9]) + "完成量" + "," + "[" + row + "]格式错误!" + "|"; | 
					
						
							|  |  |  |  |                                         } | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                                     } | 
					
						
							| 
									
										
										
										
											2022-06-14 18:21:58 +08:00
										 |  |  |  |                                 } | 
					
						
							|  |  |  |  |                                 else | 
					
						
							|  |  |  |  |                                 { | 
					
						
							|  |  |  |  |                                     try | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                                     { | 
					
						
							| 
									
										
										
										
											2022-06-14 18:21:58 +08:00
										 |  |  |  |                                         DateTime d = Convert.ToDateTime(row.Trim()); | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                                     } | 
					
						
							| 
									
										
										
										
											2022-06-14 18:21:58 +08:00
										 |  |  |  |                                     catch (Exception) | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                                     { | 
					
						
							| 
									
										
										
										
											2022-06-14 18:21:58 +08:00
										 |  |  |  |                                         if (j == 5) | 
					
						
							|  |  |  |  |                                         { | 
					
						
							|  |  |  |  |                                             result += "第" + (i + 2).ToString() + "行," + "计划开始时间" + "," + "[" + row + "]格式错误!" + "|"; | 
					
						
							|  |  |  |  |                                         } | 
					
						
							|  |  |  |  |                                         else if (j == 6) | 
					
						
							|  |  |  |  |                                         { | 
					
						
							|  |  |  |  |                                             result += "第" + (i + 2).ToString() + "行," + "计划完成时间" + "," + "[" + row + "]格式错误!" + "|"; | 
					
						
							|  |  |  |  |                                         } | 
					
						
							|  |  |  |  |                                         else if (j == 7) | 
					
						
							|  |  |  |  |                                         { | 
					
						
							|  |  |  |  |                                             result += "第" + (i + 2).ToString() + "行," + "实际开始时间" + "," + "[" + row + "]格式错误!" + "|"; | 
					
						
							|  |  |  |  |                                         } | 
					
						
							| 
									
										
										
										
											2022-07-18 15:33:29 +08:00
										 |  |  |  |                                         else if (j == 8) | 
					
						
							| 
									
										
										
										
											2022-06-14 18:21:58 +08:00
										 |  |  |  |                                         { | 
					
						
							|  |  |  |  |                                             result += "第" + (i + 2).ToString() + "行," + "实际完成时间" + "," + "[" + row + "]格式错误!" + "|"; | 
					
						
							|  |  |  |  |                                         } | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                                     } | 
					
						
							|  |  |  |  |                                 } | 
					
						
							|  |  |  |  |                             } | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(result)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     result = result.Substring(0, result.LastIndexOf("|")); | 
					
						
							|  |  |  |  |                     errorInfos = result; | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                     Alert alert = new Alert | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         Message = result, | 
					
						
							|  |  |  |  |                         Target = Target.Self | 
					
						
							|  |  |  |  |                     }; | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                     alert.Show(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                     ShowNotify("审核完成,请点击导入!", MessageBoxIcon.Success); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ShowNotify("导入数据为空!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 导入 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 导入 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnImport_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(hdCheckResult.Text)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (string.IsNullOrEmpty(errorInfos)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     string rootPath = Server.MapPath("~/"); | 
					
						
							|  |  |  |  |                     ImportXlsToData2(rootPath + initPath + this.hdFileName.Text); | 
					
						
							|  |  |  |  |                     hdCheckResult.Text = string.Empty; | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                     ShowNotify("导入成功!", MessageBoxIcon.Success); | 
					
						
							| 
									
										
										
										
											2023-07-25 17:32:36 +08:00
										 |  |  |  |                     DataTable table = BLL.WorkloadStatisticsService.GetAllTreeDataTable(this.CurrUser.LoginProjectId, string.Empty, string.Empty); | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                     Grid1.DataSource = table; | 
					
						
							|  |  |  |  |                     Grid1.DataBind(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     ShowNotify("请先将错误数据修正,再重新导入提交!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ShowNotify("请先审核要导入的文件!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region Excel提取数据 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 从Excel提取数据--》Dataset | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="filename">Excel文件路径名</param> | 
					
						
							|  |  |  |  |         private void ImportXlsToData2(string fileName) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 string oleDBConnString = String.Empty; | 
					
						
							|  |  |  |  |                 oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;"; | 
					
						
							|  |  |  |  |                 oleDBConnString += "Data Source="; | 
					
						
							|  |  |  |  |                 oleDBConnString += fileName; | 
					
						
							|  |  |  |  |                 oleDBConnString += ";Extended Properties=Excel 8.0;"; | 
					
						
							|  |  |  |  |                 OleDbConnection oleDBConn = null; | 
					
						
							|  |  |  |  |                 OleDbDataAdapter oleAdMaster = null; | 
					
						
							|  |  |  |  |                 DataTable m_tableName = new DataTable(); | 
					
						
							|  |  |  |  |                 DataSet ds = new DataSet(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 oleDBConn = new OleDbConnection(oleDBConnString); | 
					
						
							|  |  |  |  |                 oleDBConn.Open(); | 
					
						
							|  |  |  |  |                 m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 if (m_tableName != null && m_tableName.Rows.Count > 0) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     m_tableName.TableName = m_tableName.Rows[0]["TABLE_NAME"].ToString().Trim(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 string sqlMaster; | 
					
						
							|  |  |  |  |                 sqlMaster = " SELECT *  FROM [" + m_tableName.TableName + "]"; | 
					
						
							|  |  |  |  |                 oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn); | 
					
						
							|  |  |  |  |                 oleAdMaster.Fill(ds, "m_tableName"); | 
					
						
							|  |  |  |  |                 oleAdMaster.Dispose(); | 
					
						
							|  |  |  |  |                 oleDBConn.Close(); | 
					
						
							|  |  |  |  |                 oleDBConn.Dispose(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 AddDatasetToSQL2(ds.Tables[0], ColumnNum); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 throw ex; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 将Dataset的数据导入数据库 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 将Dataset的数据导入数据库 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="pds">数据集</param> | 
					
						
							|  |  |  |  |         /// <param name="Cols">数据集列数</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         private bool AddDatasetToSQL2(DataTable pds, int Cols) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             int ic, ir; | 
					
						
							|  |  |  |  |             ic = pds.Columns.Count; | 
					
						
							|  |  |  |  |             if (ic < Cols) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ShowNotify("导入Excel格式错误!Excel只有" + ic.ToString().Trim() + "列", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             string result = string.Empty; | 
					
						
							|  |  |  |  |             ir = pds.Rows.Count; | 
					
						
							|  |  |  |  |             if (pds != null && ir > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var oldViewInfos = from x in Funs.DB.WBS_CostControl | 
					
						
							|  |  |  |  |                                    where x.ProjectId == this.CurrUser.LoginProjectId | 
					
						
							|  |  |  |  |                                    select x; | 
					
						
							|  |  |  |  |                 decimal changeThisPlanValue = 0, changeThisRealCost = 0, changeThisPlanCost = 0,  //当月总变化完成成本、完成预算 | 
					
						
							|  |  |  |  |             oldThisPlanValue = 0, oldThisRealCost = 0, oldThisPlanCost = 0, | 
					
						
							|  |  |  |  |             thisPlanValue = 0, thisRealCost = 0, thisPlanCost = 0; | 
					
						
							|  |  |  |  |                 for (int i = 0; i < ir; i++) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     Model.WBS_CostControl costControl = oldViewInfos.FirstOrDefault(x => x.CostControlId == pds.Rows[i][Cols - 1].ToString()); | 
					
						
							|  |  |  |  |                     if (costControl != null) | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                     { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:33:29 +08:00
										 |  |  |  |                         decimal oldPlanPrice = costControl.PlanPrice ?? 0; | 
					
						
							|  |  |  |  |                         decimal oldRealPrice = costControl.RealPrice ?? 0; | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                         costControl.TotalNum = Funs.GetNewDecimal(pds.Rows[i][2].ToString().Trim()); | 
					
						
							|  |  |  |  |                         costControl.PlanPrice = Funs.GetNewDecimal(pds.Rows[i][3].ToString().Trim()); | 
					
						
							|  |  |  |  |                         costControl.RealPrice = Funs.GetNewDecimal(pds.Rows[i][4].ToString().Trim()); | 
					
						
							| 
									
										
										
										
											2022-06-14 18:21:58 +08:00
										 |  |  |  |                         costControl.PlanStartDate = Funs.GetNewDateTime(pds.Rows[i][5].ToString().Trim()); | 
					
						
							|  |  |  |  |                         costControl.PlanEndDate = Funs.GetNewDateTime(pds.Rows[i][6].ToString().Trim()); | 
					
						
							|  |  |  |  |                         costControl.RealStartDate = Funs.GetNewDateTime(pds.Rows[i][7].ToString().Trim()); | 
					
						
							|  |  |  |  |                         costControl.RealEndDate = Funs.GetNewDateTime(pds.Rows[i][8].ToString().Trim()); | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                         BLL.CostControlService.UpdateCostControl(costControl); | 
					
						
							|  |  |  |  |                         for (int j = 0; j < months.Count; j++) | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                         { | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                             oldThisPlanValue = 0; | 
					
						
							|  |  |  |  |                             oldThisRealCost = 0; | 
					
						
							|  |  |  |  |                             oldThisPlanCost = 0; | 
					
						
							|  |  |  |  |                             changeThisPlanValue = 0; | 
					
						
							|  |  |  |  |                             changeThisRealCost = 0; | 
					
						
							|  |  |  |  |                             changeThisPlanCost = 0; | 
					
						
							| 
									
										
										
										
											2022-06-14 18:21:58 +08:00
										 |  |  |  |                             string planNum = pds.Rows[i][9 + j * 2].ToString().Trim(); | 
					
						
							|  |  |  |  |                             string thisNum = pds.Rows[i][10 + j * 2].ToString().Trim(); | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                             Model.WBS_CostControlDetail costControlDetail = BLL.CostControlDetailService.GetCostControlDetailByCostControlIdAndMonths(costControl.CostControlId, months[j]); | 
					
						
							|  |  |  |  |                             if (costControlDetail != null) | 
					
						
							|  |  |  |  |                             { | 
					
						
							| 
									
										
										
										
											2022-07-18 15:33:29 +08:00
										 |  |  |  |                                 oldThisPlanValue = (costControlDetail.PlanNum ?? 0) * oldPlanPrice; | 
					
						
							|  |  |  |  |                                 oldThisRealCost = (costControlDetail.ThisNum ?? 0) * oldRealPrice; | 
					
						
							|  |  |  |  |                                 oldThisPlanCost = (costControlDetail.ThisNum ?? 0) * oldPlanPrice; | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                                 costControlDetail.PlanNum = Funs.GetNewDecimalOrZero(planNum); | 
					
						
							|  |  |  |  |                                 costControlDetail.ThisNum = Funs.GetNewDecimalOrZero(thisNum); | 
					
						
							|  |  |  |  |                                 thisPlanValue = (costControlDetail.PlanNum ?? 0) * (costControl.PlanPrice ?? 0); | 
					
						
							|  |  |  |  |                                 thisRealCost = (costControlDetail.ThisNum ?? 0) * (costControl.RealPrice ?? 0); | 
					
						
							|  |  |  |  |                                 thisPlanCost = (costControlDetail.ThisNum ?? 0) * (costControl.PlanPrice ?? 0); | 
					
						
							|  |  |  |  |                                 BLL.CostControlDetailService.UpdateCostControlDetail(costControlDetail); | 
					
						
							|  |  |  |  |                             } | 
					
						
							|  |  |  |  |                             else | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                             { | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                                 costControlDetail = new Model.WBS_CostControlDetail(); | 
					
						
							|  |  |  |  |                                 costControlDetail.CostControlDetailId = SQLHelper.GetNewID(); | 
					
						
							|  |  |  |  |                                 costControlDetail.CostControlId = costControl.CostControlId; | 
					
						
							|  |  |  |  |                                 costControlDetail.Months = months[j]; | 
					
						
							|  |  |  |  |                                 costControlDetail.PlanNum = Funs.GetNewDecimalOrZero(planNum); | 
					
						
							|  |  |  |  |                                 costControlDetail.ThisNum = Funs.GetNewDecimalOrZero(thisNum); | 
					
						
							|  |  |  |  |                                 thisPlanValue = (costControlDetail.PlanNum ?? 0) * (costControl.PlanPrice ?? 0); | 
					
						
							|  |  |  |  |                                 thisRealCost = (costControlDetail.ThisNum ?? 0) * (costControl.RealPrice ?? 0); | 
					
						
							|  |  |  |  |                                 thisPlanCost = (costControlDetail.ThisNum ?? 0) * (costControl.PlanPrice ?? 0); | 
					
						
							|  |  |  |  |                                 BLL.CostControlDetailService.AddCostControlDetail(costControlDetail); | 
					
						
							|  |  |  |  |                             } | 
					
						
							|  |  |  |  |                             //累加变化值,计算总的变化值 | 
					
						
							|  |  |  |  |                             changeThisPlanValue += thisPlanValue - oldThisPlanValue; | 
					
						
							|  |  |  |  |                             changeThisRealCost += thisRealCost - oldThisRealCost; | 
					
						
							|  |  |  |  |                             changeThisPlanCost += thisPlanCost - oldThisPlanCost; | 
					
						
							|  |  |  |  |                             //更新工作包、工作项 | 
					
						
							|  |  |  |  |                             Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(costControl.WbsSetId); | 
					
						
							|  |  |  |  |                             UpdateWbsSetDetail(costControl.WbsSetId, months[j], changeThisPlanValue, changeThisRealCost, changeThisPlanCost); | 
					
						
							|  |  |  |  |                             //更新分部 | 
					
						
							|  |  |  |  |                             Model.WBS_CostControlParentDetail unitProjectDetail = BLL.CostControlParentDetailService.GetCostControlParentDetailByParentIdAndMonths(wbsSet.UnitProjectId, months[j]); | 
					
						
							|  |  |  |  |                             if (unitProjectDetail != null) | 
					
						
							|  |  |  |  |                             { | 
					
						
							|  |  |  |  |                                 unitProjectDetail.ThisPlanValue += changeThisPlanValue; | 
					
						
							|  |  |  |  |                                 unitProjectDetail.ThisRealCost += changeThisRealCost; | 
					
						
							|  |  |  |  |                                 unitProjectDetail.ThisPlanCost += changeThisPlanCost; | 
					
						
							|  |  |  |  |                                 BLL.CostControlParentDetailService.UpdateCostControlParentDetail(unitProjectDetail); | 
					
						
							|  |  |  |  |                             } | 
					
						
							|  |  |  |  |                             else | 
					
						
							|  |  |  |  |                             { | 
					
						
							|  |  |  |  |                                 unitProjectDetail = new Model.WBS_CostControlParentDetail(); | 
					
						
							|  |  |  |  |                                 unitProjectDetail.CostControlParentDetailId = SQLHelper.GetNewID(); | 
					
						
							|  |  |  |  |                                 unitProjectDetail.ParentId = wbsSet.UnitProjectId; | 
					
						
							|  |  |  |  |                                 unitProjectDetail.Months = months[j]; | 
					
						
							|  |  |  |  |                                 unitProjectDetail.ThisPlanValue = changeThisPlanValue; | 
					
						
							|  |  |  |  |                                 unitProjectDetail.ThisRealCost = changeThisRealCost; | 
					
						
							|  |  |  |  |                                 unitProjectDetail.ThisPlanCost = changeThisPlanCost; | 
					
						
							|  |  |  |  |                                 BLL.CostControlParentDetailService.AddCostControlParentDetail(unitProjectDetail); | 
					
						
							|  |  |  |  |                             } | 
					
						
							|  |  |  |  |                             //更新专业 | 
					
						
							|  |  |  |  |                             if (!string.IsNullOrEmpty(wbsSet.CnProfessionId)) | 
					
						
							|  |  |  |  |                             { | 
					
						
							|  |  |  |  |                                 Model.WBS_CostControlParentDetail cnProfessionDetail = BLL.CostControlParentDetailService.GetCostControlParentDetailByParentIdAndMonths(wbsSet.CnProfessionId, months[j]); | 
					
						
							|  |  |  |  |                                 if (cnProfessionDetail != null) | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                                 { | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                                     cnProfessionDetail.ThisPlanValue += changeThisPlanValue; | 
					
						
							|  |  |  |  |                                     cnProfessionDetail.ThisRealCost += changeThisRealCost; | 
					
						
							|  |  |  |  |                                     cnProfessionDetail.ThisPlanCost += changeThisPlanCost; | 
					
						
							|  |  |  |  |                                     BLL.CostControlParentDetailService.UpdateCostControlParentDetail(cnProfessionDetail); | 
					
						
							|  |  |  |  |                                 } | 
					
						
							|  |  |  |  |                                 else | 
					
						
							|  |  |  |  |                                 { | 
					
						
							|  |  |  |  |                                     cnProfessionDetail = new Model.WBS_CostControlParentDetail(); | 
					
						
							|  |  |  |  |                                     cnProfessionDetail.CostControlParentDetailId = SQLHelper.GetNewID(); | 
					
						
							|  |  |  |  |                                     cnProfessionDetail.ParentId = wbsSet.CnProfessionId; | 
					
						
							|  |  |  |  |                                     cnProfessionDetail.Months = months[j]; | 
					
						
							|  |  |  |  |                                     cnProfessionDetail.ThisPlanValue = changeThisPlanValue; | 
					
						
							|  |  |  |  |                                     cnProfessionDetail.ThisRealCost = changeThisRealCost; | 
					
						
							|  |  |  |  |                                     cnProfessionDetail.ThisPlanCost = changeThisPlanCost; | 
					
						
							|  |  |  |  |                                     BLL.CostControlParentDetailService.AddCostControlParentDetail(cnProfessionDetail); | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                                 } | 
					
						
							|  |  |  |  |                             } | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                             //更新装置 | 
					
						
							|  |  |  |  |                             UpdateInstallationDetail(wbsSet.InstallationId, months[j], changeThisPlanValue, changeThisRealCost, changeThisPlanCost); | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |                         } | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2022-05-22 10:13:35 +08:00
										 |  |  |  |                 ShowNotify("导入成功!", MessageBoxIcon.Success); | 
					
						
							| 
									
										
										
										
											2021-12-29 15:03:49 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ShowNotify("导入数据为空!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region  更新工作包、工作项 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 更新月工作包、工作项 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="years"></param> | 
					
						
							|  |  |  |  |         /// <param name="months"></param> | 
					
						
							|  |  |  |  |         /// <param name="planValue"></param> | 
					
						
							|  |  |  |  |         /// <param name="parentId"></param> | 
					
						
							|  |  |  |  |         private void UpdateWbsSetDetail(string wbsSetId, DateTime months, decimal changeThisPlanValue, decimal changeThisRealCost, decimal changeThisPlanCost) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(wbsSetId); | 
					
						
							|  |  |  |  |             if (wbsSet != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Model.WBS_CostControlParentDetail parentDetail = BLL.CostControlParentDetailService.GetCostControlParentDetailByParentIdAndMonths(wbsSetId, months); | 
					
						
							|  |  |  |  |                 if (parentDetail != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanValue += changeThisPlanValue; | 
					
						
							|  |  |  |  |                     parentDetail.ThisRealCost += changeThisRealCost; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanCost += changeThisPlanCost; | 
					
						
							|  |  |  |  |                     BLL.CostControlParentDetailService.UpdateCostControlParentDetail(parentDetail); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     parentDetail = new Model.WBS_CostControlParentDetail(); | 
					
						
							|  |  |  |  |                     parentDetail.CostControlParentDetailId = SQLHelper.GetNewID(); | 
					
						
							|  |  |  |  |                     parentDetail.ParentId = wbsSetId; | 
					
						
							|  |  |  |  |                     parentDetail.Months = months; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanValue = changeThisPlanValue; | 
					
						
							|  |  |  |  |                     parentDetail.ThisRealCost = changeThisRealCost; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanCost = changeThisPlanCost; | 
					
						
							|  |  |  |  |                     BLL.CostControlParentDetailService.AddCostControlParentDetail(parentDetail); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 if (wbsSet.SuperWbsSetId != null)   //还存在上级节点,需要继续循环 | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     UpdateWbsSetDetail(wbsSet.SuperWbsSetId, months, changeThisPlanValue, changeThisRealCost, changeThisPlanCost); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 更新周工作包、工作项 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="years"></param> | 
					
						
							|  |  |  |  |         /// <param name="months"></param> | 
					
						
							|  |  |  |  |         /// <param name="planValue"></param> | 
					
						
							|  |  |  |  |         /// <param name="parentId"></param> | 
					
						
							|  |  |  |  |         private void UpdateWeekWbsSetDetail(string wbsSetId, DateTime months, DateTime startDate, DateTime endDate, decimal changeThisPlanValue, decimal changeThisRealCost, decimal changeThisPlanCost) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(wbsSetId); | 
					
						
							|  |  |  |  |             if (wbsSet != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Model.WBS_CostControlParentDetail parentDetail = BLL.CostControlParentDetailService.GetCostControlParentDetailByParentIdAndMonthsWeek(wbsSetId, months, startDate); | 
					
						
							|  |  |  |  |                 if (parentDetail != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanValue += changeThisPlanValue; | 
					
						
							|  |  |  |  |                     parentDetail.ThisRealCost += changeThisRealCost; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanCost += changeThisPlanCost; | 
					
						
							|  |  |  |  |                     BLL.CostControlParentDetailService.UpdateCostControlParentDetail(parentDetail); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     parentDetail = new Model.WBS_CostControlParentDetail(); | 
					
						
							|  |  |  |  |                     parentDetail.CostControlParentDetailId = SQLHelper.GetNewID(); | 
					
						
							|  |  |  |  |                     parentDetail.ParentId = wbsSetId; | 
					
						
							|  |  |  |  |                     parentDetail.Months = months; | 
					
						
							|  |  |  |  |                     parentDetail.StartDate = startDate; | 
					
						
							|  |  |  |  |                     parentDetail.EndDate = endDate; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanValue = changeThisPlanValue; | 
					
						
							|  |  |  |  |                     parentDetail.ThisRealCost = changeThisRealCost; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanCost = changeThisPlanCost; | 
					
						
							|  |  |  |  |                     BLL.CostControlParentDetailService.AddCostControlParentDetail(parentDetail); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 if (wbsSet.SuperWbsSetId != null)   //还存在上级节点,需要继续循环 | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     UpdateWeekWbsSetDetail(wbsSet.SuperWbsSetId, months, startDate, endDate, changeThisPlanValue, changeThisRealCost, changeThisPlanCost); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region  更新装置 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 更新月装置 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="years"></param> | 
					
						
							|  |  |  |  |         /// <param name="months"></param> | 
					
						
							|  |  |  |  |         /// <param name="planValue"></param> | 
					
						
							|  |  |  |  |         /// <param name="parentId"></param> | 
					
						
							|  |  |  |  |         private void UpdateInstallationDetail(string installationId, DateTime months, decimal changeThisPlanValue, decimal changeThisRealCost, decimal changeThisPlanCost) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.Project_Installation installation = BLL.Project_InstallationService.GetInstallationByInstallationId(installationId); | 
					
						
							|  |  |  |  |             if (installation != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Model.WBS_CostControlParentDetail parentDetail = BLL.CostControlParentDetailService.GetCostControlParentDetailByParentIdAndMonths(installationId, months); | 
					
						
							|  |  |  |  |                 if (parentDetail != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanValue += changeThisPlanValue; | 
					
						
							|  |  |  |  |                     parentDetail.ThisRealCost += changeThisRealCost; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanCost += changeThisPlanCost; | 
					
						
							|  |  |  |  |                     BLL.CostControlParentDetailService.UpdateCostControlParentDetail(parentDetail); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     parentDetail = new Model.WBS_CostControlParentDetail(); | 
					
						
							|  |  |  |  |                     parentDetail.CostControlParentDetailId = SQLHelper.GetNewID(); | 
					
						
							|  |  |  |  |                     parentDetail.ParentId = installationId; | 
					
						
							|  |  |  |  |                     parentDetail.Months = months; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanValue = changeThisPlanValue; | 
					
						
							|  |  |  |  |                     parentDetail.ThisRealCost = changeThisRealCost; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanCost = changeThisPlanCost; | 
					
						
							|  |  |  |  |                     BLL.CostControlParentDetailService.AddCostControlParentDetail(parentDetail); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 if (installation.SuperInstallationId != null)   //还存在上级节点,需要继续循环 | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     UpdateInstallationDetail(installation.SuperInstallationId, months, changeThisPlanValue, changeThisRealCost, changeThisPlanCost); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 更新周装置 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="years"></param> | 
					
						
							|  |  |  |  |         /// <param name="months"></param> | 
					
						
							|  |  |  |  |         /// <param name="planValue"></param> | 
					
						
							|  |  |  |  |         /// <param name="parentId"></param> | 
					
						
							|  |  |  |  |         private void UpdateWeekInstallationDetail(string installationId, DateTime months, DateTime startDate, DateTime endDate, decimal changeThisPlanValue, decimal changeThisRealCost, decimal changeThisPlanCost) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.Project_Installation installation = BLL.Project_InstallationService.GetInstallationByInstallationId(installationId); | 
					
						
							|  |  |  |  |             if (installation != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Model.WBS_CostControlParentDetail parentDetail = BLL.CostControlParentDetailService.GetCostControlParentDetailByParentIdAndMonths(installationId, months); | 
					
						
							|  |  |  |  |                 if (parentDetail != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanValue += changeThisPlanValue; | 
					
						
							|  |  |  |  |                     parentDetail.ThisRealCost += changeThisRealCost; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanCost += changeThisPlanCost; | 
					
						
							|  |  |  |  |                     BLL.CostControlParentDetailService.UpdateCostControlParentDetail(parentDetail); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     parentDetail = new Model.WBS_CostControlParentDetail(); | 
					
						
							|  |  |  |  |                     parentDetail.CostControlParentDetailId = SQLHelper.GetNewID(); | 
					
						
							|  |  |  |  |                     parentDetail.ParentId = installationId; | 
					
						
							|  |  |  |  |                     parentDetail.Months = months; | 
					
						
							|  |  |  |  |                     parentDetail.StartDate = startDate; | 
					
						
							|  |  |  |  |                     parentDetail.EndDate = endDate; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanValue = changeThisPlanValue; | 
					
						
							|  |  |  |  |                     parentDetail.ThisRealCost = changeThisRealCost; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanCost = changeThisPlanCost; | 
					
						
							|  |  |  |  |                     BLL.CostControlParentDetailService.AddCostControlParentDetail(parentDetail); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 if (installation.SuperInstallationId != null)   //还存在上级节点,需要继续循环 | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     UpdateWeekInstallationDetail(installation.SuperInstallationId, months, startDate, endDate, changeThisPlanValue, changeThisRealCost, changeThisPlanCost); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |