diff --git a/DataBase/菜单初始化脚本/1-4进度管理(Menu_JDGL).sql b/DataBase/菜单初始化脚本/1-4进度管理(Menu_JDGL).sql index 02b777c5..e682de42 100644 --- a/DataBase/菜单初始化脚本/1-4进度管理(Menu_JDGL).sql +++ b/DataBase/菜单初始化脚本/1-4进度管理(Menu_JDGL).sql @@ -55,7 +55,7 @@ go --GO INSERT INTO dbo.Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuType,IsOffice,IsEnd,IsUsed) -VALUES('E23F0879-3E9F-4E7B-9A2D-EFF34798D629','进度计划设置','JDGL/Check/PlanSet.aspx',10,'0','Menu_JDGL',0,1,1) +VALUES('E23F0879-3E9F-4E7B-9A2D-EFF34798D629','进度计划编制','JDGL/Check/PlanSet.aspx',10,'0','Menu_JDGL',0,1,1) GO INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex) VALUES('F5055103-6182-43E0-93EC-7DD7BEF2B71C','E23F0879-3E9F-4E7B-9A2D-EFF34798D629','保存',4) diff --git a/SGGL/BLL/CQMS/WBS/WorkPackageService.cs b/SGGL/BLL/CQMS/WBS/WorkPackageService.cs index 6a9a7529..cacebc16 100644 --- a/SGGL/BLL/CQMS/WBS/WorkPackageService.cs +++ b/SGGL/BLL/CQMS/WBS/WorkPackageService.cs @@ -245,7 +245,7 @@ namespace BLL /// 获取模拟树表格 /// /// - public static DataTable GetAllTreeDataTable(string projectId) + public static DataTable GetAllTreeDataTable(string projectId, string IsOut) { using (var db = new Model.SGGLDB(Funs.ConnString)) { @@ -260,7 +260,7 @@ namespace BLL table.Columns.Add(new DataColumn("WBSType", typeof(String))); table.Columns.Add(new DataColumn("ProjectId", typeof(String))); table.Columns.Add(new DataColumn("ShowId", typeof(String))); - table.Columns.Add(new DataColumn("Weights", typeof(String))); + table.Columns.Add(new DataColumn("JDWeights", typeof(String))); table.Columns.Add(new DataColumn("Unit", typeof(String))); table.Columns.Add(new DataColumn("PlanProjectQuantity", typeof(String))); table.Columns.Add(new DataColumn("RealProjectQuantity", typeof(String))); @@ -271,14 +271,25 @@ namespace BLL table.Columns.Add(new DataColumn("IsMileStone", typeof(bool))); table.Columns.Add(new DataColumn("PlanCost", typeof(String))); table.Columns.Add(new DataColumn("PreWorkCode", typeof(String))); + table.Columns.Add(new DataColumn("Code", typeof(String))); if (getWBSs.Count() > 0) { List newList = new List(); var projectTypes = getWBSs.Where(x => x.WBSType == "ProjectType" && x.SupId == "0"); + int a = 1; foreach (var item in projectTypes) { + item.Code = a.ToString(); newList.Add(item); - AddDetail(newList, getWBSs.ToList(), item.Id); + if (string.IsNullOrEmpty(IsOut)) + { + AddDetail(newList, getWBSs.ToList(), item.Id, a.ToString()); + } + else + { + AddDetail(newList, getWBSs.ToList(), item.Id, a.ToString(), string.Empty); + } + a++; } DataRow row; foreach (Model.View_WBS item in newList) @@ -370,6 +381,7 @@ namespace BLL } } } + row[17] = item.Code; table.Rows.Add(row); } } @@ -377,13 +389,30 @@ namespace BLL } } - private static void AddDetail(List newList, List oldList, string id) + private static void AddDetail(List newList, List oldList, string id, string preCode) { var items = oldList.Where(x => x.SupId == id).OrderBy(x => x.Code); + int b = 1; foreach (var item in items) { + item.Code = preCode + "." + b.ToString(); newList.Add(item); - AddDetail(newList, oldList, item.Id); + AddDetail(newList, oldList, item.Id, item.Code); + b++; + } + } + + private static void AddDetail(List newList, List oldList, string id, string preCode, string prefix) + { + var items = oldList.Where(x => x.SupId == id).OrderBy(x => x.Code); + int b = 1; + foreach (var item in items) + { + item.Code = preCode + "." + b.ToString(); + item.Name = prefix + "...." + item.Name; + newList.Add(item); + AddDetail(newList, oldList, item.Id, item.Code, prefix + "...."); + b++; } } diff --git a/SGGL/BLL/Common/Const.cs b/SGGL/BLL/Common/Const.cs index 2d1365e0..e85553c6 100644 --- a/SGGL/BLL/Common/Const.cs +++ b/SGGL/BLL/Common/Const.cs @@ -3342,6 +3342,11 @@ /// public const string OpinionTemplateUrl = "File\\Excel\\DataOut\\策划评审意见收集汇总表.xlsx"; + /// + /// 进度计划编制模板文件原始虚拟路径 + /// + public const string JDPlanTemplateUrl = "File\\Excel\\DataOut\\进度计划编制.xls"; + #endregion #region 初始化上传路径 diff --git a/SGGL/FineUIPro.Web/File/Excel/DataOut/进度计划编制.xls b/SGGL/FineUIPro.Web/File/Excel/DataOut/进度计划编制.xls new file mode 100644 index 00000000..90af43b5 Binary files /dev/null and b/SGGL/FineUIPro.Web/File/Excel/DataOut/进度计划编制.xls differ diff --git a/SGGL/FineUIPro.Web/JDGL/Check/PlanSet.aspx b/SGGL/FineUIPro.Web/JDGL/Check/PlanSet.aspx index 98132d3a..c71bec83 100644 --- a/SGGL/FineUIPro.Web/JDGL/Check/PlanSet.aspx +++ b/SGGL/FineUIPro.Web/JDGL/Check/PlanSet.aspx @@ -33,11 +33,17 @@ + + <%----%> + + - + - - - diff --git a/SGGL/FineUIPro.Web/JDGL/Check/PlanSet.aspx.cs b/SGGL/FineUIPro.Web/JDGL/Check/PlanSet.aspx.cs index fba96f7f..cbde1d5b 100644 --- a/SGGL/FineUIPro.Web/JDGL/Check/PlanSet.aspx.cs +++ b/SGGL/FineUIPro.Web/JDGL/Check/PlanSet.aspx.cs @@ -3,6 +3,7 @@ using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Data; +using System.IO; using System.Linq; using System.Web.UI.WebControls; @@ -27,7 +28,7 @@ namespace FineUIPro.Web.JDGL.Check private void BindGrid() { - DataTable table = BLL.WorkPackageService.GetAllTreeDataTable(this.CurrUser.LoginProjectId); + DataTable table = BLL.WorkPackageService.GetAllTreeDataTable(this.CurrUser.LoginProjectId, string.Empty); Grid1.DataSource = table; Grid1.DataBind(); for (int i = 0; i < this.Grid1.Rows.Count; i++) @@ -38,7 +39,7 @@ namespace FineUIPro.Web.JDGL.Check cbIsMileStone.Visible = false; foreach (GridColumn column in Grid1.Columns) { - if (column.ColumnIndex != 0) + if (column.ColumnIndex != 0 && column.ColumnIndex != 1) { this.Grid1.Rows[i].CellCssClasses[column.ColumnIndex] = "f-grid-cell-uneditable"; } @@ -98,7 +99,7 @@ namespace FineUIPro.Web.JDGL.Check Model.WBS_WorkPackage workPackage = workPackages.FirstOrDefault(x => x.WorkPackageId == this.Grid1.Rows[i].DataKeys[2].ToString()); if (workPackage != null) { - string weights = values.Value("Weights"); + string weights = values.Value("JDWeights"); string unit = values.Value("Unit"); string planProjectQuantity = values.Value("PlanProjectQuantity"); string realProjectQuantity = values.Value("RealProjectQuantity"); @@ -107,7 +108,7 @@ namespace FineUIPro.Web.JDGL.Check string realStartDate = values.Value("RealStartDate"); string preWorkCode = values.Value("PreWorkCode"); System.Web.UI.WebControls.CheckBox cbIsMileStone = (System.Web.UI.WebControls.CheckBox)(this.Grid1.Rows[i].FindControl("cbIsMileStone")); - workPackage.Weights = Funs.GetNewDecimal(weights); + workPackage.JDWeights = Funs.GetNewDecimal(weights); workPackage.Unit = unit; workPackage.PlanProjectQuantity = Funs.GetNewDecimal(planProjectQuantity); workPackage.RealProjectQuantity = Funs.GetNewDecimal(realProjectQuantity); @@ -171,5 +172,190 @@ namespace FineUIPro.Web.JDGL.Check } } #endregion + + #region 导出(excel按钮) + protected void btnOutExcel_Click(object sender, EventArgs e) + { + if (this.Grid1.Rows.Count > 0) + { + try + { + DataTable table = BLL.WorkPackageService.GetAllTreeDataTable(this.CurrUser.LoginProjectId, "Out"); + string projectNmae = BLL.ProjectService.GetProjectNameByProjectId(this.CurrUser.LoginProjectId); + if (!string.IsNullOrEmpty(projectNmae)) + { + projectNmae = "(" + projectNmae + ")"; + } + string rootPath = Server.MapPath("~/"); + string initTemplatePath = string.Empty; + string uploadfilepath = string.Empty; + string newUrl = string.Empty; + string filePath = string.Empty; + initTemplatePath = Const.JDPlanTemplateUrl; + uploadfilepath = rootPath + initTemplatePath; + newUrl = uploadfilepath.Replace(".xls", projectNmae + ".xls"); + File.Copy(uploadfilepath, newUrl); + // 第一步:读取文件流 + NPOI.SS.UserModel.IWorkbook workbook; + using (FileStream stream = new FileStream(newUrl, FileMode.Open, FileAccess.Read)) + { + workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(stream); + } + + // 创建单元格样式 + NPOI.SS.UserModel.ICellStyle cellStyle0 = workbook.CreateCellStyle(); + cellStyle0.BorderTop = NPOI.SS.UserModel.BorderStyle.None; + cellStyle0.BorderRight = NPOI.SS.UserModel.BorderStyle.None; + cellStyle0.BorderBottom = NPOI.SS.UserModel.BorderStyle.None; + cellStyle0.BorderLeft = NPOI.SS.UserModel.BorderStyle.None; + cellStyle0.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; + cellStyle0.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; + var font = workbook.CreateFont(); + font.FontHeightInPoints = 12; + font.IsBold = true; + //font.FontHeightInPoints = (short)8.5;字号为小数时要转为short + cellStyle0.SetFont(font); + + // 第二步:创建新数据行 + NPOI.SS.UserModel.ISheet sheet = workbook.GetSheet("Sheet1"); + NPOI.SS.UserModel.IRow row1 = sheet.CreateRow(1); + NPOI.SS.UserModel.ICell cell2; + // 添加测试数据 + cell2 = row1.CreateCell(14); + cell2.CellStyle = cellStyle0; + cell2.SetCellValue("123"); + var font2 = workbook.CreateFont(); + font2.FontHeightInPoints = 10; + + + + // 创建单元格样式 + NPOI.SS.UserModel.ICellStyle cellStyle1 = workbook.CreateCellStyle(); + cellStyle1.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle1.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle1.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle1.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle1.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; + cellStyle1.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; + var font3 = workbook.CreateFont(); + font3.FontHeightInPoints = 14; + cellStyle1.SetFont(font3); + + NPOI.SS.UserModel.ICellStyle cellStyle2 = workbook.CreateCellStyle(); + cellStyle2.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle2.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle2.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle2.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle2.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left; + cellStyle2.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; + cellStyle2.SetFont(font3); + + int rowCount = 1; + NPOI.SS.UserModel.IRow row; + NPOI.SS.UserModel.ICell cell; + + #region 填充内容 + foreach (DataRow tr in table.Rows) + { + row = sheet.CreateRow(rowCount); + cell = row.CreateCell(0); + cell.CellStyle = cellStyle2; + cell.SetCellValue(tr["Code"].ToString()); + cell = row.CreateCell(1); + cell.CellStyle = cellStyle2; + cell.SetCellValue(tr["Name"].ToString()); + cell = row.CreateCell(2); + cell.CellStyle = cellStyle1; + cell.SetCellValue(tr["PreWorkCode"].ToString()); + cell = row.CreateCell(3); + cell.CellStyle = cellStyle1; + if (!string.IsNullOrEmpty(tr["IsMileStone"].ToString()) && Convert.ToBoolean(tr["IsMileStone"].ToString()) == true) + { + cell.SetCellValue("是"); + } + cell = row.CreateCell(4); + cell.CellStyle = cellStyle1; + if (!string.IsNullOrEmpty(tr["JDWeights"].ToString())) + { + cell.SetCellValue(decimal.Round(Convert.ToDecimal(tr["JDWeights"]), 2).ToString("0.##")); + } + cell = row.CreateCell(5); + cell.CellStyle = cellStyle1; + cell.SetCellValue(tr["Unit"].ToString()); + cell = row.CreateCell(6); + cell.CellStyle = cellStyle1; + if (!string.IsNullOrEmpty(tr["PlanProjectQuantity"].ToString())) + { + cell.SetCellValue(decimal.Round(Convert.ToDecimal(tr["PlanProjectQuantity"]), 2).ToString("0.##")); + } + cell = row.CreateCell(7); + cell.CellStyle = cellStyle1; + if (!string.IsNullOrEmpty(tr["PlanCost"].ToString())) + { + cell.SetCellValue(decimal.Round(Convert.ToDecimal(tr["PlanCost"]), 2).ToString("0.##")); + } + cell = row.CreateCell(8); + cell.CellStyle = cellStyle1; + if (!string.IsNullOrEmpty(tr["RealProjectQuantity"].ToString())) + { + cell.SetCellValue(decimal.Round(Convert.ToDecimal(tr["RealProjectQuantity"]), 2).ToString("0.##")); + } + cell = row.CreateCell(9); + cell.CellStyle = cellStyle1; + if (tr["PlanStartDate"] != null) + { + cell.SetCellValue(string.Format("{0:yyyy-MM-dd}", tr["PlanStartDate"])); + } + cell = row.CreateCell(10); + cell.CellStyle = cellStyle1; + if (tr["PlanEndDate"] != null) + { + cell.SetCellValue(string.Format("{0:yyyy-MM-dd}", tr["PlanEndDate"])); + } + cell = row.CreateCell(11); + cell.CellStyle = cellStyle1; + if (tr["RealStartDate"] != null) + { + cell.SetCellValue(string.Format("{0:yyyy-MM-dd}", tr["RealStartDate"])); + } + cell = row.CreateCell(12); + cell.CellStyle = cellStyle1; + if (tr["RealEndDate"] != null) + { + cell.SetCellValue(string.Format("{0:yyyy-MM-dd}", tr["RealEndDate"])); + } + rowCount++; + } + #endregion + // 第三步:写入文件流 + using (FileStream stream = new FileStream(newUrl, FileMode.Create, FileAccess.Write)) + { + workbook.Write(stream); + workbook.Close(); + } + string fileName = Path.GetFileName(newUrl); + FileInfo info = new FileInfo(newUrl); + long fileSize = info.Length; + Response.Clear(); + Response.ContentType = "application/x-zip-compressed"; + Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); + Response.AddHeader("Content-Length", fileSize.ToString()); + Response.TransmitFile(newUrl, 0, fileSize); + Response.Flush(); + Response.Close(); + File.Delete(newUrl); + } + catch (Exception ex) + { + + throw ex; + } + } + else + { + ShowNotify("没有数据,无法导出!", MessageBoxIcon.Warning); + } + } + #endregion } } \ No newline at end of file diff --git a/SGGL/FineUIPro.Web/JDGL/Check/PlanSet.aspx.designer.cs b/SGGL/FineUIPro.Web/JDGL/Check/PlanSet.aspx.designer.cs index 656badf1..0da2811c 100644 --- a/SGGL/FineUIPro.Web/JDGL/Check/PlanSet.aspx.designer.cs +++ b/SGGL/FineUIPro.Web/JDGL/Check/PlanSet.aspx.designer.cs @@ -75,6 +75,15 @@ namespace FineUIPro.Web.JDGL.Check { /// protected global::FineUIPro.Button btnSave; + /// + /// btnOut 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnOut; + /// /// txtPreWorkCode 控件。 /// @@ -103,13 +112,13 @@ namespace FineUIPro.Web.JDGL.Check { protected global::System.Web.UI.WebControls.CheckBox cbIsMileStone; /// - /// nbWeights 控件。 + /// nbJDWeights 控件。 /// /// /// 自动生成的字段。 /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// - protected global::FineUIPro.NumberBox nbWeights; + protected global::FineUIPro.NumberBox nbJDWeights; /// /// txtUnit 控件。