提交代码

This commit is contained in:
2024-01-24 09:17:17 +08:00
parent 210a264a30
commit a1f0314f72
13 changed files with 718 additions and 7 deletions
@@ -38,6 +38,9 @@
</f:Button>
<f:Button ID="btnModify" Icon="Pencil" ToolTip="修改" OnClick="btnMenuModify_Click" runat="server" Hidden="true">
</f:Button>
<f:Button ID="btnOut" OnClick="btnOut_Click" runat="server" ToolTip="导出" Icon="FolderUp"
EnableAjax="false" DisableControlBeforePostBack="false">
</f:Button>
<f:Button ID="btnDel" Icon="Delete" ToolTip="删除" OnClick="btnMenuDel_Click" runat="server" ConfirmText="确定删除当前数据?" Hidden="true">
</f:Button>
</Items>
@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
namespace FineUIPro.Web.TestRun.DriverPrepare
@@ -156,5 +157,181 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
}
}
#endregion
#region
/// 导出按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOut_Click(object sender, EventArgs e)
{
string rootPath = Server.MapPath("~/");
string initTemplatePath = string.Empty;
string uploadfilepath = string.Empty;
string newUrl = string.Empty;
string filePath = string.Empty;
initTemplatePath = Const.DutyTemplateUrl;
uploadfilepath = rootPath + initTemplatePath;
var duty = (from x in Funs.DB.DriverPrepare_Duty where x.ProjectId == this.CurrUser.LoginProjectId select x).FirstOrDefault();
if (duty != null)
{
string projectName = BLL.ProjectService.GetProjectNameByProjectId(duty.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.Left;
cellStyle0.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
var font0 = workbook.CreateFont();
font0.FontHeightInPoints = 11;
font0.IsBold = false;
cellStyle0.SetFont(font0);
// 第二步:创建新数据行
NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0);
NPOI.SS.UserModel.IRow row = sheet.GetRow(1);
NPOI.SS.UserModel.ICell cell;
cell = row.GetCell(3);
cell.CellStyle = cellStyle0;
cell.SetCellValue("项目名称:" + projectName);
var items = BLL.DriverPrepareDutyItemService.GetLists(duty.DutyId);
int i = 4;
foreach (var item in items)
{
// 第二步:创建新数据行
row = sheet.GetRow(i);
// 添加数据
cell = row.GetCell(3);
cell.CellStyle = cellStyle;
if (item.Item1 == true)
{
cell.SetCellValue("√");
}
cell = row.GetCell(4);
cell.CellStyle = cellStyle;
if (item.Item2 == true)
{
cell.SetCellValue("√");
}
cell = row.GetCell(5);
cell.CellStyle = cellStyle;
if (item.Item3 == true)
{
cell.SetCellValue("√");
}
cell = row.GetCell(6);
cell.CellStyle = cellStyle;
if (item.Item4 == true)
{
cell.SetCellValue("√");
}
cell = row.GetCell(7);
cell.CellStyle = cellStyle;
if (item.Item5 == true)
{
cell.SetCellValue("√");
}
cell = row.GetCell(8);
cell.CellStyle = cellStyle;
if (item.Item6 == true)
{
cell.SetCellValue("√");
}
cell = row.GetCell(9);
cell.CellStyle = cellStyle;
if (item.Item7 == true)
{
cell.SetCellValue("√");
}
cell = row.GetCell(10);
cell.CellStyle = cellStyle;
if (item.Item8 == true)
{
cell.SetCellValue("√");
}
cell = row.GetCell(11);
cell.CellStyle = cellStyle;
if (item.Item9 == true)
{
cell.SetCellValue("√");
}
cell = row.GetCell(12);
cell.CellStyle = cellStyle;
if (item.Item10 == true)
{
cell.SetCellValue("√");
}
cell = row.GetCell(13);
cell.CellStyle = cellStyle;
if (item.Item11 == true)
{
cell.SetCellValue("√");
}
cell = row.GetCell(14);
cell.CellStyle = cellStyle;
if (item.Item12 == true)
{
cell.SetCellValue("√");
}
cell = row.GetCell(15);
cell.CellStyle = cellStyle;
if (item.Item13 == true)
{
cell.SetCellValue("√");
}
cell = row.GetCell(16);
cell.CellStyle = cellStyle;
if (item.Item14 == true)
{
cell.SetCellValue("√");
}
cell = row.GetCell(17);
cell.CellStyle = cellStyle;
cell.SetCellValue(item.Remark);
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);
}
else
{
Alert.ShowInTop("当前无记录,无法导出!", MessageBoxIcon.Warning);
}
}
#endregion
}
}
@@ -75,6 +75,15 @@ namespace FineUIPro.Web.TestRun.DriverPrepare {
/// </remarks>
protected global::FineUIPro.Button btnModify;
/// <summary>
/// btnOut 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnOut;
/// <summary>
/// btnDel 控件。
/// </summary>
@@ -28,7 +28,7 @@
TitleToolTip="开车责任分工表" AutoScroll="true">
<Items>
<f:Grid ID="Grid1" ShowBorder="true" ShowHeader="false" Title="开车责任分工表"
EnableCollapse="true" KeepCurrentSelection="true" runat="server" BoxFlex="1"
EnableCollapse="true" runat="server" BoxFlex="1"
DataKeyNames="DutyItemId" AllowColumnLocking="true" EnableColumnLines="true" AllowCellEditing="true" ClicksToEdit="1"
DataIDField="DutyItemId" EnableTextSelection="True" AllowSorting="true" SortField="Code"
SortDirection="ASC" OnSort="Grid1_Sort" AllowPaging="false" IsDatabasePaging="true"
@@ -58,6 +58,90 @@
</f:RenderField>
<f:GroupField ColumnID="c2" HeaderText="责任分工" TextAlign="Center">
<Columns>
<%--<f:TemplateField ColumnID="Item1" Width="60px" HeaderText="技术文件编制" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbItem1" />
</ItemTemplate>
</f:TemplateField>
<f:TemplateField ColumnID="Item2" Width="60px" HeaderText="操作规程编制" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbItem2" />
</ItemTemplate>
</f:TemplateField>
<f:TemplateField ColumnID="Item3" Width="60px" HeaderText="实施方案编制" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbItem3" />
</ItemTemplate>
</f:TemplateField>
<f:TemplateField ColumnID="Item4" Width="60px" HeaderText="技术指导" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbItem4" />
</ItemTemplate>
</f:TemplateField>
<f:TemplateField ColumnID="Item5" Width="60px" HeaderText="临时措施" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbItem5" />
</ItemTemplate>
</f:TemplateField>
<f:TemplateField ColumnID="Item6" Width="60px" HeaderText="组织指挥" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbItem6" />
</ItemTemplate>
</f:TemplateField>
<f:TemplateField ColumnID="Item7" Width="60px" HeaderText="操作执行" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbItem7" />
</ItemTemplate>
</f:TemplateField>
<f:TemplateField ColumnID="Item8" Width="60px" HeaderText="记录报告" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbItem8" />
</ItemTemplate>
</f:TemplateField>
<f:TemplateField ColumnID="Item9" Width="60px" HeaderText="公用工程保障" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbItem9" />
</ItemTemplate>
</f:TemplateField>
<f:TemplateField ColumnID="Item10" Width="60px" HeaderText="原料供应" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbItem10" />
</ItemTemplate>
</f:TemplateField>
<f:TemplateField ColumnID="Item11" Width="60px" HeaderText="分析化验" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbItem11" />
</ItemTemplate>
</f:TemplateField>
<f:TemplateField ColumnID="Item12" Width="60px" HeaderText="保运" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbItem12" />
</ItemTemplate>
</f:TemplateField>
<f:TemplateField ColumnID="Item13" Width="60px" HeaderText="备品备件供应" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbItem13" />
</ItemTemplate>
</f:TemplateField>
<f:TemplateField ColumnID="Item14" Width="60px" HeaderText="产出物料处置" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbItem14" />
</ItemTemplate>
</f:TemplateField>--%>
<f:CheckBoxField Width="60px" RenderAsStaticField="false" ColumnID="Item1" DataField="Item1" HeaderText="技术文件编制" TextAlign="Center" />
<f:CheckBoxField Width="60px" RenderAsStaticField="false" ColumnID="Item2" DataField="Item2" HeaderText="操作规程编制" TextAlign="Center" />
<f:CheckBoxField Width="60px" RenderAsStaticField="false" ColumnID="Item3" DataField="Item3" HeaderText="实施方案编制" TextAlign="Center" />
@@ -83,8 +167,8 @@
</f:GroupField>
</Columns>
<Listeners>
<f:Listener Event="dataload" Handler="onGridDataLoad" />
</Listeners>
<f:Listener Event="dataload" Handler="onGridDataLoad" />
</Listeners>
</f:Grid>
</Items>
</f:Panel>
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using AspNet = System.Web.UI.WebControls;
namespace FineUIPro.Web.TestRun.DriverPrepare
{
@@ -34,6 +35,8 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
}
BindGrid();
}
//Grid1.EnableCheckBoxSelect = true;
//Grid1.CheckBoxSelectOnly = true;
}
}
#endregion
@@ -141,6 +144,46 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
BLL.DriverPrepareDutyItemService.UpdateDutyItem(item);
}
}
//int rowsCount = this.Grid1.Rows.Count;
//foreach (JObject mergedRow in Grid1.GetMergedData())
//{
// int i = mergedRow.Value<int>("index");
// var item = list.FirstOrDefault(x => x.DutyItemId == Grid1.Rows[i].RowID);
// JObject values = mergedRow.Value<JObject>("values");
// AspNet.CheckBox cbItem1 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem1"));
// AspNet.CheckBox cbItem2 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem2"));
// AspNet.CheckBox cbItem3 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem3"));
// AspNet.CheckBox cbItem4 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem4"));
// AspNet.CheckBox cbItem5 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem5"));
// AspNet.CheckBox cbItem6 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem6"));
// AspNet.CheckBox cbItem7 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem7"));
// AspNet.CheckBox cbItem8 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem8"));
// AspNet.CheckBox cbItem9 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem9"));
// AspNet.CheckBox cbItem10 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem10"));
// AspNet.CheckBox cbItem11 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem11"));
// AspNet.CheckBox cbItem12 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem12"));
// AspNet.CheckBox cbItem13 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem13"));
// AspNet.CheckBox cbItem14 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem14"));
// item.Item1 = cbItem1.Checked;
// item.Item2 = cbItem2.Checked;
// item.Item3 = cbItem3.Checked;
// item.Item4 = cbItem4.Checked;
// item.Item5 = cbItem5.Checked;
// item.Item6 = cbItem6.Checked;
// item.Item7 = cbItem7.Checked;
// item.Item8 = cbItem8.Checked;
// item.Item9 = cbItem9.Checked;
// item.Item10 = cbItem10.Checked;
// item.Item11 = cbItem11.Checked;
// item.Item12 = cbItem12.Checked;
// item.Item13 = cbItem13.Checked;
// item.Item14 = cbItem14.Checked;
// item.Remark = values.Value<string>("Remark");
// BLL.DriverPrepareDutyItemService.UpdateDutyItem(item);
//}
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
@@ -34,7 +34,7 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
Model.DriverPrepare_SchemePlanItem newItem = new Model.DriverPrepare_SchemePlanItem();
newItem.SolutionName = this.txtSolutionName.Text.Trim();
Model.DriverPrepare_SchemePlan plan = BLL.DriverPrepareSchemePlanService.GetDriverPlanByProjectId(this.CurrUser.LoginProjectId);
int sortIndex = 21;
int sortIndex = 200;
if (plan != null)
{
var items = BLL.DriverPrepareSchemePlanItemService.GetSchemePlanItemByschemePlanId(plan.SchemePlanId);
@@ -33,11 +33,27 @@
</f:RadioButtonList>
<f:ToolbarFill ID="ToolbarFill1" runat="server">
</f:ToolbarFill>
<f:HiddenField runat="server" ID="hdNames"></f:HiddenField>
<f:Button ID="btnAccept" Icon="Accept" runat="server" Text="确定" ToolTip="确定"
OnClick="btnAccept_Click">
</f:Button>
</Items>
</f:Toolbar>
<f:Toolbar ID="Toolbar2" Position="Top" runat="server" ToolbarAlign="Right">
<Items>
<f:RadioButtonList ID="rblType2" runat="server" AutoPostBack="true" Width="520px"
OnSelectedIndexChanged="TextBox_TextChanged" AutoColumnWidth="true">
<f:RadioItem Value="公用工程" Text="公用工程" Selected="true" />
<f:RadioItem Value="空分" Text="空分" />
<f:RadioItem Value="气化" Text="气化" />
<f:RadioItem Value="净化" Text="净化" />
<f:RadioItem Value="合成" Text="合成" />
<f:RadioItem Value="尿素" Text="尿素" />
</f:RadioButtonList>
<f:ToolbarFill ID="ToolbarFill2" runat="server">
</f:ToolbarFill>
</Items>
</f:Toolbar>
</Toolbars>
<Columns>
<f:RenderField HeaderText="序号" ColumnID="SortIndex"
@@ -27,6 +27,14 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
protected void TextBox_TextChanged(object sender, EventArgs e)
{
if (this.rblType.SelectedValue == "合成氨尿素项目")
{
this.Toolbar2.Hidden = false;
}
else
{
this.Toolbar2.Hidden = true;
}
this.BindGrid();
}
@@ -36,11 +44,26 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
/// </summary>
private void BindGrid()
{
string[] selectRowId = Grid1.SelectedRowIDArray;
foreach (GridRow row in Grid1.Rows)
{
if (selectRowId.Contains(row.RowID))
{
hdNames.Text += row.DataKeys[1].ToString() + ",";
}
}
string strSql = @"SELECT *
FROM dbo.DriverPrepare_SchemePlanItem
WHERE SchemePlanId=@SchemePlanId";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@SchemePlanId", this.rblType.SelectedValue));
if (this.rblType.SelectedValue == "合成氨尿素项目")
{
listStr.Add(new SqlParameter("@SchemePlanId", this.rblType2.SelectedValue));
}
else
{
listStr.Add(new SqlParameter("@SchemePlanId", this.rblType.SelectedValue));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
@@ -109,7 +132,7 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
string[] selectRowId = Grid1.SelectedRowIDArray;
foreach (GridRow row in Grid1.Rows)
{
if (selectRowId.Contains(row.RowID) && !nameLists.Contains(row.DataKeys[1].ToString()))
if (selectRowId.Contains(row.RowID) && !nameLists.Contains(row.DataKeys[1].ToString()) && !hdNames.Text.Contains(row.DataKeys[1].ToString()))
{
Model.DriverPrepare_SchemePlanItem newItem = new Model.DriverPrepare_SchemePlanItem();
newItem.SchemePlanItemId = SQLHelper.GetNewID();
@@ -119,6 +142,23 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
BLL.DriverPrepareSchemePlanItemService.AddSchemePlanItem(newItem);
}
}
if (!string.IsNullOrEmpty(hdNames.Text))
{
string[] names = hdNames.Text.Split(',');
foreach (var item in names)
{
if (!string.IsNullOrEmpty(item) && !nameLists.Contains(item))
{
Model.DriverPrepare_SchemePlanItem newItem = new Model.DriverPrepare_SchemePlanItem();
newItem.SchemePlanItemId = SQLHelper.GetNewID();
newItem.SchemePlanId = newData.SchemePlanId;
newItem.SolutionName = item;
Random ra = new Random();
newItem.SortIndex = ra.Next(20, 200);
BLL.DriverPrepareSchemePlanItemService.AddSchemePlanItem(newItem);
}
}
}
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
@@ -84,6 +84,15 @@ namespace FineUIPro.Web.TestRun.DriverPrepare {
/// </remarks>
protected global::FineUIPro.ToolbarFill ToolbarFill1;
/// <summary>
/// hdNames 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.HiddenField hdNames;
/// <summary>
/// btnAccept 控件。
/// </summary>
@@ -92,5 +101,32 @@ namespace FineUIPro.Web.TestRun.DriverPrepare {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnAccept;
/// <summary>
/// Toolbar2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Toolbar Toolbar2;
/// <summary>
/// rblType2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.RadioButtonList rblType2;
/// <summary>
/// ToolbarFill2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.ToolbarFill ToolbarFill2;
}
}