diff --git a/SGGL/BLL/TestRun/DriverPrepare/DriverPrepareSchemePlanItemService.cs b/SGGL/BLL/TestRun/DriverPrepare/DriverPrepareSchemePlanItemService.cs index 439d722c..2ee216e1 100644 --- a/SGGL/BLL/TestRun/DriverPrepare/DriverPrepareSchemePlanItemService.cs +++ b/SGGL/BLL/TestRun/DriverPrepare/DriverPrepareSchemePlanItemService.cs @@ -29,7 +29,7 @@ namespace BLL /// public static List GetSchemePlanItemByschemePlanId(string schemePlanId) { - return (from x in Funs.DB.DriverPrepare_SchemePlanItem where x.SchemePlanId == schemePlanId orderby x.SortIndex select x).ToList(); + return (from x in Funs.DB.DriverPrepare_SchemePlanItem where x.SchemePlanId == schemePlanId orderby x.SolutionType, x.SortIndex select x).ToList(); } /// diff --git a/SGGL/FineUIPro.Web/File/Excel/TestRun/开车方案编制计划2.xlsx b/SGGL/FineUIPro.Web/File/Excel/TestRun/开车方案编制计划2.xlsx new file mode 100644 index 00000000..f1593bea Binary files /dev/null and b/SGGL/FineUIPro.Web/File/Excel/TestRun/开车方案编制计划2.xlsx differ diff --git a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj index 56b8c24e..eeddcae4 100644 --- a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj +++ b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj @@ -2075,6 +2075,7 @@ + diff --git a/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlan.aspx.cs b/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlan.aspx.cs index cb89735d..419f1737 100644 --- a/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlan.aspx.cs +++ b/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlan.aspx.cs @@ -1,5 +1,6 @@ using BLL; using Newtonsoft.Json.Linq; +using NPOI.SS.Util; using System; using System.Collections.Generic; using System.Data; @@ -38,6 +39,18 @@ namespace FineUIPro.Web.TestRun.DriverPrepare var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); + var solutionType = (from x in Funs.DB.DriverPrepare_SchemePlan + join y in Funs.DB.DriverPrepare_SchemePlanItem on x.SchemePlanId equals y.SchemePlanId + where y.SolutionType != null && x.ProjectId == this.CurrUser.LoginProjectId + select y).FirstOrDefault(); + if (solutionType == null) + { + this.Grid1.Columns[1].Hidden = true; + } + else + { + this.Grid1.Columns[1].Hidden = false; + } } #endregion @@ -178,87 +191,201 @@ namespace FineUIPro.Web.TestRun.DriverPrepare string uploadfilepath = string.Empty; string newUrl = string.Empty; string filePath = string.Empty; - initTemplatePath = Const.SchemePlanTemplateUrl; + var solutionType = (from x in Funs.DB.DriverPrepare_SchemePlan + join y in Funs.DB.DriverPrepare_SchemePlanItem on x.SchemePlanId equals y.SchemePlanId + where y.SolutionType != null && x.ProjectId == this.CurrUser.LoginProjectId + select y).FirstOrDefault(); + if (solutionType == null) + { + initTemplatePath = Const.SchemePlanTemplateUrl; + } + else + { + initTemplatePath = Const.SchemePlan2TemplateUrl; + } uploadfilepath = rootPath + initTemplatePath; Model.DriverPrepare_SchemePlan plan = BLL.DriverPrepareSchemePlanService.GetDriverPlanByProjectId(this.CurrUser.LoginProjectId); if (plan != null) { string projectName = BLL.ProjectService.GetProjectNameByProjectId(plan.ProjectId); - newUrl = uploadfilepath.Replace(".xlsx", "(" + projectName + ")" + ".xlsx"); - File.Copy(uploadfilepath, newUrl); - // 第一步:读取文件流 - NPOI.SS.UserModel.IWorkbook workbook; - using (FileStream stream = new FileStream(newUrl, FileMode.Open, FileAccess.Read)) - { - workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(stream); - } - // 创建单元格样式 - NPOI.SS.UserModel.ICellStyle cellStyle = workbook.CreateCellStyle(); - cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; - cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; - cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; - cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; - cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; - cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; - var font = workbook.CreateFont(); - font.FontHeightInPoints = 11; - cellStyle.SetFont(font); - NPOI.SS.UserModel.ICellStyle cellStyle0 = workbook.CreateCellStyle(); - cellStyle0.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; - cellStyle0.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; - cellStyle0.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; - cellStyle0.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; - cellStyle0.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; - cellStyle0.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; - var font0 = workbook.CreateFont(); - font0.FontHeightInPoints = 12; - font0.IsBold = true; - cellStyle0.SetFont(font0); - // 第二步:创建新数据行 - NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0); - NPOI.SS.UserModel.IRow row = sheet.GetRow(0); - NPOI.SS.UserModel.ICell cell; - cell = row.GetCell(0); - cell.CellStyle = cellStyle0; - cell.SetCellValue(projectName + "试车方案"); - var items = BLL.DriverPrepareSchemePlanItemService.GetSchemePlanItemByschemePlanId(plan.SchemePlanId); - int i = 2; - foreach (var item in items) + if (solutionType == null) { + newUrl = uploadfilepath.Replace(".xlsx", "(" + projectName + ")" + ".xlsx"); + File.Copy(uploadfilepath, newUrl); + // 第一步:读取文件流 + NPOI.SS.UserModel.IWorkbook workbook; + using (FileStream stream = new FileStream(newUrl, FileMode.Open, FileAccess.Read)) + { + workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(stream); + } + // 创建单元格样式 + NPOI.SS.UserModel.ICellStyle cellStyle = workbook.CreateCellStyle(); + cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; + cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; + var font = workbook.CreateFont(); + font.FontHeightInPoints = 11; + cellStyle.SetFont(font); + NPOI.SS.UserModel.ICellStyle cellStyle0 = workbook.CreateCellStyle(); + cellStyle0.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle0.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle0.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle0.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle0.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; + cellStyle0.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; + var font0 = workbook.CreateFont(); + font0.FontHeightInPoints = 12; + font0.IsBold = true; + cellStyle0.SetFont(font0); // 第二步:创建新数据行 - row = sheet.CreateRow(i); - // 添加数据 - cell = row.CreateCell(0); - cell.CellStyle = cellStyle; - cell.SetCellValue((i-1).ToString()); - cell = row.CreateCell(1); - cell.CellStyle = cellStyle; - cell.SetCellValue(item.SolutionName); - cell = row.CreateCell(2); - cell.CellStyle = cellStyle; - cell.SetCellValue(string.Empty); - cell = row.CreateCell(3); - cell.CellStyle = cellStyle; - cell.SetCellValue(string.Empty); - i++; + NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0); + NPOI.SS.UserModel.IRow row = sheet.GetRow(0); + NPOI.SS.UserModel.ICell cell; + cell = row.GetCell(0); + cell.CellStyle = cellStyle0; + cell.SetCellValue(projectName + "试车方案"); + var items = BLL.DriverPrepareSchemePlanItemService.GetSchemePlanItemByschemePlanId(plan.SchemePlanId); + int i = 2; + foreach (var item in items) + { + // 第二步:创建新数据行 + row = sheet.CreateRow(i); + // 添加数据 + cell = row.CreateCell(0); + cell.CellStyle = cellStyle; + cell.SetCellValue((i - 1).ToString()); + cell = row.CreateCell(1); + cell.CellStyle = cellStyle; + cell.SetCellValue(item.SolutionName); + cell = row.CreateCell(2); + cell.CellStyle = cellStyle; + cell.SetCellValue(string.Empty); + cell = row.CreateCell(3); + cell.CellStyle = cellStyle; + cell.SetCellValue(string.Empty); + i++; + } + // 第三步:写入文件流 + 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); } - // 第三步:写入文件流 - using (FileStream stream = new FileStream(newUrl, FileMode.Create, FileAccess.Write)) + else { - workbook.Write(stream); - workbook.Close(); + newUrl = uploadfilepath.Replace("2.xlsx", "(" + projectName + ")" + ".xlsx"); + File.Copy(uploadfilepath, newUrl); + // 第一步:读取文件流 + NPOI.SS.UserModel.IWorkbook workbook; + using (FileStream stream = new FileStream(newUrl, FileMode.Open, FileAccess.Read)) + { + workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(stream); + } + // 创建单元格样式 + NPOI.SS.UserModel.ICellStyle cellStyle = workbook.CreateCellStyle(); + cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; + cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; + var font = workbook.CreateFont(); + font.FontHeightInPoints = 11; + cellStyle.SetFont(font); + NPOI.SS.UserModel.ICellStyle cellStyle0 = workbook.CreateCellStyle(); + cellStyle0.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle0.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle0.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle0.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; + cellStyle0.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; + cellStyle0.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; + var font0 = workbook.CreateFont(); + font0.FontHeightInPoints = 12; + font0.IsBold = true; + cellStyle0.SetFont(font0); + // 第二步:创建新数据行 + NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0); + NPOI.SS.UserModel.IRow row = sheet.GetRow(0); + NPOI.SS.UserModel.ICell cell; + cell = row.GetCell(0); + cell.CellStyle = cellStyle0; + cell.SetCellValue(projectName + "试车方案"); + var items = BLL.DriverPrepareSchemePlanItemService.GetSchemePlanItemByschemePlanId(plan.SchemePlanId); + int i = 2; + string type = string.Empty; + int firstRow = 2; + foreach (var item in items) + { + if (string.IsNullOrEmpty(type)) + { + type = item.SolutionType; + } + // 第二步:创建新数据行 + row = sheet.CreateRow(i); + // 添加数据 + cell = row.CreateCell(0); + cell.CellStyle = cellStyle; + cell.SetCellValue((i - 1).ToString()); + cell = row.CreateCell(1); + cell.CellStyle = cellStyle; + cell.SetCellValue(item.SolutionType); + cell = row.CreateCell(2); + cell.CellStyle = cellStyle; + cell.SetCellValue(item.SolutionName); + cell = row.CreateCell(3); + cell.CellStyle = cellStyle; + cell.SetCellValue(string.Empty); + cell = row.CreateCell(4); + cell.CellStyle = cellStyle; + cell.SetCellValue(string.Empty); + if (type != item.SolutionType) + { + type = item.SolutionType; + sheet.AddMergedRegion(new CellRangeAddress(firstRow, i - 1, 1, 1)); + firstRow = i; + } + else + { + if (i == 1 + items.Count) + { + sheet.AddMergedRegion(new CellRangeAddress(firstRow, i, 1, 1)); + } + } + i++; + } + // 第三步:写入文件流 + 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); } - 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); } else { diff --git a/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx b/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx index d362434e..fab5528f 100644 --- a/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx +++ b/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx @@ -14,6 +14,11 @@ + + + + + diff --git a/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx.cs b/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx.cs index c6f319a4..6a48ebf1 100644 --- a/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx.cs +++ b/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx.cs @@ -21,8 +21,21 @@ namespace FineUIPro.Web.TestRun.DriverPrepare if (item != null) { this.txtSolutionName.Text = item.SolutionName; + this.txtSolutionType.Text = item.SolutionType; } } + var solutionType = (from x in Funs.DB.DriverPrepare_SchemePlan + join y in Funs.DB.DriverPrepare_SchemePlanItem on x.SchemePlanId equals y.SchemePlanId + where y.SolutionType != null && x.ProjectId == this.CurrUser.LoginProjectId + select y).FirstOrDefault(); + if (solutionType != null) + { + this.txtSolutionType.Hidden = false; + } + else + { + this.txtSolutionType.Hidden = true; + } } } @@ -54,13 +67,25 @@ namespace FineUIPro.Web.TestRun.DriverPrepare newItem.SchemePlanId = newData.SchemePlanId; } newItem.SortIndex = sortIndex; + var solutionType = (from x in Funs.DB.DriverPrepare_SchemePlan + join y in Funs.DB.DriverPrepare_SchemePlanItem on x.SchemePlanId equals y.SchemePlanId + where y.SolutionType != null && x.ProjectId == this.CurrUser.LoginProjectId + select y).FirstOrDefault(); + if (solutionType != null) + { + newItem.SolutionType = this.txtSolutionType.Text.Trim(); + } + else + { + + } if (string.IsNullOrEmpty(SchemePlanItemId)) { newItem.SchemePlanItemId = SQLHelper.GetNewID(); BLL.DriverPrepareSchemePlanItemService.AddSchemePlanItem(newItem); BLL.LogService.AddSys_Log(this.CurrUser, newItem.SolutionName, newItem.SolutionName, BLL.Const.ControlItemInitSetMenuId, "增加开车方案!"); } - if (Request.Params["type"] == "modify") + else { newItem.SchemePlanItemId = SchemePlanItemId; BLL.DriverPrepareSchemePlanItemService.UpdateSchemePlanItem(newItem); diff --git a/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx.designer.cs b/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx.designer.cs index 793f876e..3e0a5b44 100644 --- a/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx.designer.cs +++ b/SGGL/FineUIPro.Web/TestRun/DriverPrepare/SchemePlanItemAdd.aspx.designer.cs @@ -39,6 +39,15 @@ namespace FineUIPro.Web.TestRun.DriverPrepare { /// protected global::FineUIPro.Form SimpleForm1; + /// + /// txtSolutionType 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.TextBox txtSolutionType; + /// /// txtSolutionName 控件。 ///