Browse Source

修改深爱需求,支持首页按照行分页

callm 5 years ago
parent
commit
64d2d96ee3

+ 1 - 1
UAS-出货标签管理(贸易版)/CustomControl/Pagination.cs

@@ -254,7 +254,7 @@ namespace UAS_LabelMachine.CustomControl
                 string FolderPath = folderBrowserDialog1.SelectedPath;
                 ExcelHandler eh = new ExcelHandler();
                 //导出Excel的时候返回一个文件名,用户选择是否打开
-                string filePath = eh.ExportExcel(BaseUtil.GetExportDataTable(Dgv), FolderPath, "客户标签","",100);
+                string filePath = eh.ExportExcel(BaseUtil.GetExportDataTable(Dgv), BaseUtil.GetExportDataTable(Dgv), FolderPath, "客户标签","",100,false);
                 //用户选择导出之后是否立即打开
                 MessageBoxButtons messButton = MessageBoxButtons.YesNo;
                 string openFile = MessageBox.Show(this.ParentForm, "是否打开文件", "提示", messButton).ToString();

+ 3 - 29
UAS-出货标签管理(贸易版)/ExportExcel.Designer.cs

@@ -48,10 +48,9 @@
             this.BoxCode = new System.Windows.Forms.RadioButton();
             this.FixRow = new System.Windows.Forms.RadioButton();
             this.label7 = new System.Windows.Forms.Label();
-            this.FirstPage_Batch = new System.Windows.Forms.CheckBox();
-            this.FirstPage_Row = new System.Windows.Forms.CheckBox();
             this.FirstPage_WID = new System.Windows.Forms.CheckBox();
             this.RowNum = new UAS_LabelMachine.CustomControl.NumOnlyTextBox();
+            this.ExportFileDialog = new System.Windows.Forms.FolderBrowserDialog();
             this.SuspendLayout();
             // 
             // Export
@@ -286,33 +285,11 @@
             this.label7.TabIndex = 25;
             this.label7.Text = "分页行数:";
             // 
-            // FirstPage_Batch
-            // 
-            this.FirstPage_Batch.AutoSize = true;
-            this.FirstPage_Batch.Font = new System.Drawing.Font("宋体", 10F);
-            this.FirstPage_Batch.Location = new System.Drawing.Point(487, 504);
-            this.FirstPage_Batch.Name = "FirstPage_Batch";
-            this.FirstPage_Batch.Size = new System.Drawing.Size(206, 31);
-            this.FirstPage_Batch.TabIndex = 27;
-            this.FirstPage_Batch.Text = "扩散批号分行";
-            this.FirstPage_Batch.UseVisualStyleBackColor = true;
-            // 
-            // FirstPage_Row
-            // 
-            this.FirstPage_Row.AutoSize = true;
-            this.FirstPage_Row.Font = new System.Drawing.Font("宋体", 10F);
-            this.FirstPage_Row.Location = new System.Drawing.Point(259, 504);
-            this.FirstPage_Row.Name = "FirstPage_Row";
-            this.FirstPage_Row.Size = new System.Drawing.Size(206, 31);
-            this.FirstPage_Row.TabIndex = 28;
-            this.FirstPage_Row.Text = "分页汇总分行";
-            this.FirstPage_Row.UseVisualStyleBackColor = true;
-            // 
             // FirstPage_WID
             // 
             this.FirstPage_WID.AutoSize = true;
             this.FirstPage_WID.Font = new System.Drawing.Font("宋体", 10F);
-            this.FirstPage_WID.Location = new System.Drawing.Point(717, 504);
+            this.FirstPage_WID.Location = new System.Drawing.Point(259, 508);
             this.FirstPage_WID.Name = "FirstPage_WID";
             this.FirstPage_WID.Size = new System.Drawing.Size(210, 31);
             this.FirstPage_WID.TabIndex = 29;
@@ -335,8 +312,6 @@
             this.ClientSize = new System.Drawing.Size(1144, 675);
             this.Controls.Add(this.RowNum);
             this.Controls.Add(this.FirstPage_WID);
-            this.Controls.Add(this.FirstPage_Row);
-            this.Controls.Add(this.FirstPage_Batch);
             this.Controls.Add(this.label7);
             this.Controls.Add(this.FixRow);
             this.Controls.Add(this.BoxCode);
@@ -387,9 +362,8 @@
         private System.Windows.Forms.RadioButton BoxCode;
         private System.Windows.Forms.RadioButton FixRow;
         private System.Windows.Forms.Label label7;
-        private System.Windows.Forms.CheckBox FirstPage_Batch;
-        private System.Windows.Forms.CheckBox FirstPage_Row;
         private System.Windows.Forms.CheckBox FirstPage_WID;
         private CustomControl.NumOnlyTextBox RowNum;
+        private System.Windows.Forms.FolderBrowserDialog ExportFileDialog;
     }
 }

+ 79 - 56
UAS-出货标签管理(贸易版)/ExportExcel.cs

@@ -25,64 +25,87 @@ namespace UAS_LabelMachine
 
         private void Export_Click(object sender, EventArgs e)
         {
-            StringBuilder sql = new StringBuilder();
-            string SqlField = "";
-            if (CH_BLUEFILM.Checked)
+            ExportFileDialog.Description = "选择导出的路径";
+            DialogResult result = ExportFileDialog.ShowDialog();
+            if (result == DialogResult.OK)
             {
-                SqlField += "CH_BLUEFILM " + CH_BLUEFILM.Text + ",";
-            }
-            if (CH_PBCODE.Checked)
-            {
-                SqlField += "CH_PBCODE " + CH_PBCODE.Text + ",";
-            }
-            if (CH_REMARK.Checked)
-            {
-                SqlField += "CH_REMARK " + CH_REMARK.Text + ",";
-            }
-            if (CH_SPLITBATCH.Checked)
-            {
-                SqlField += "CH_SPLITBATCH " + CH_SPLITBATCH.Text + ",";
-            }
-            if (CH_WATERID.Checked)
-            {
-                SqlField += "CH_WATERID " + CH_WATERID.Text + ",";
-            }
-            if (ch_code.Checked)
-            {
-                SqlField += "ch_code " + ch_code.Text + ",";
-            }
-            if (percent.Checked)
-            {
-                SqlField += "chw_percent1,chw_percent2,chw_itemname1,chw_itemname2,";
-            }
-            if (TS.Checked)
-            {
-                SqlField += "TS1,TS2,TS3,";
-            }
-            if (BVCEO.Checked)
-            {
-                SqlField += "BVCEO1,BVCEO2,BVCEO3,";
-            }
-            string SplitType = "";
-            if (FixRow.Checked)
-            {
-                SplitType = FixRow.Name;
-            }
-            else if (BatchCode.Checked)
-            {
-                SplitType = BatchCode.Name;
-            }
-            else if (BoxCode.Checked)
-            {
-                SplitType = BoxCode.Name;
+                StringBuilder sql = new StringBuilder();
+                string SqlField = "";
+                if (!CH_PBCODE.Checked && BoxCode.Checked)
+                {
+                    MessageBox.Show("勾选盒号分页,打印内容请勾选盒号");
+                    return;
+                }
+                if (!CH_SPLITBATCH.Checked && BatchCode.Checked)
+                {
+                    MessageBox.Show("勾选扩撒批分页,打印内容请勾选扩撒批号");
+                    return;
+                }
+                if (CH_BLUEFILM.Checked)
+                {
+                    SqlField += "CH_BLUEFILM " + CH_BLUEFILM.Text + ",";
+                }
+                if (CH_PBCODE.Checked)
+                {
+                    SqlField += "CH_PBCODE " + CH_PBCODE.Text + ",";
+                }
+                if (CH_REMARK.Checked)
+                {
+                    SqlField += "CH_REMARK " + CH_REMARK.Text + ",";
+                }
+                if (CH_SPLITBATCH.Checked)
+                {
+                    SqlField += "CH_SPLITBATCH " + CH_SPLITBATCH.Text + ",";
+                }
+                if (CH_WATERID.Checked)
+                {
+                    SqlField += "CH_WATERID " + CH_WATERID.Text + ",";
+                }
+                if (ch_code.Checked)
+                {
+                    SqlField += "ch_code " + ch_code.Text + ",";
+                }
+                if (percent.Checked)
+                {
+                    SqlField += "chw_percent1,chw_percent2,chw_itemname1,chw_itemname2,";
+                }
+                if (TS.Checked)
+                {
+                    SqlField += "TS1,TS2,TS3,";
+                }
+                if (BVCEO.Checked)
+                {
+                    SqlField += "BVCEO1,BVCEO2,BVCEO3,";
+                }
+                SqlField += "pd_ordercode,pr_spec,";
+                string SplitType = "";
+                if (FixRow.Checked)
+                {
+                    SplitType = FixRow.Name;
+                }
+                else if (BatchCode.Checked)
+                {
+                    SplitType = BatchCode.Name;
+                }
+                else if (BoxCode.Checked)
+                {
+                    SplitType = BoxCode.Name;
+                }
+
+                //分页信息的DataTable
+                sql.Clear();
+                sql.Append("select '客户:'||pi_title,'出货单号:'||pi_inoutno,'型号'||pr_spec||' 销售类型:市场部','销售日期:'||pi_date,rownum 序号,io_qty,");
+                sql.Append("" + SqlField.Substring(0, SqlField.Length - 1) + " from  prodinout left join prodiodetail on pi_id=pd_piid left join chip_in_out ");
+                sql.Append("on pd_id=io_pdid left join chip on ch_code=io_chipcode left join CHIP_WAFERTEST_VIEW on ch_code=chw_chipcode ");
+                sql.Append("left join CHIP_EDCDATA_VIEW on che_chipcode=ch_code left join product on pr_code=pd_prodcode where pi_inoutno='" + inoutno + "' order by io_detno");
+                DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
+                //首页信息的DataTable
+                sql.Clear();
+                sql.Append("select '客户:'||pi_title 客户,'出货单号:'||pi_inoutno 出货单号,'型号'||pr_spec||' 销售类型:市场部' 型号,");
+                sql.Append("'销售日期:'||pi_date 销售日期,pd_ordercode,pr_spec,ch_splitbatch,ch_waterid,num,io_qty from FIRSTPAGE_BATCH_VIEW where pi_inoutno='" + inoutno + "'");
+                DataTable dt1 = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
+                eh.ExportExcel(dt1, dt, ExportFileDialog.SelectedPath, inoutno, SplitType, int.Parse(RowNum.Text), FirstPage_WID.Checked);
             }
-            sql.Clear();
-            sql.Append("select '客户:'||pi_title,'出货单号:'||pi_inoutno,'型号'||pr_spec||' 销售类型:市场部','销售日期:'||pi_date,rownum 序号,io_qty,");
-            sql.Append("" + SqlField.Substring(0, SqlField.Length - 1) + " from  prodinout left join prodiodetail on pi_id=pd_piid left join chip_in_out ");
-            sql.Append("on pd_id=io_pdid left join chip on ch_code=io_chipcode left join CHIP_WAFERTEST_VIEW on ch_code=chw_chipcode ");
-            sql.Append("left join CHIP_EDCDATA_VIEW on che_chipcode=ch_code left join product on pr_code=pd_prodcode where pi_inoutno='" + inoutno + "' order by io_detno");
-            DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
-            eh.ExportExcel(dt, @"C:\Users\callm\Desktop", "test",SplitType ,int.Parse(RowNum.Text));
         }
 
         private void ExportExcel_Load(object sender, EventArgs e)

+ 3 - 0
UAS-出货标签管理(贸易版)/ExportExcel.resx

@@ -117,4 +117,7 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <metadata name="ExportFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
 </root>

+ 222 - 8
UAS-出货标签管理(贸易版)/PublicMethod/ExcelHandler.cs

@@ -17,11 +17,11 @@ namespace UAS_LabelMachine
         /// <summary>
         /// 导出Excel,返回文件在客户端的路径
         /// </summary>
-        public string ExportExcel(DataTable dt, string FolderPath, string FileName, string Type, int PageSize)
+        public string ExportExcel(DataTable firstsdt, DataTable dt, string FolderPath, string FileName, string Type, int PageSize, bool PrintWID)
         {
             //创建一个内存流,用来接收转换成Excel的内容
             MemoryStream ms;
-            ms = DataTableToExcel1(dt, Type, PageSize);
+            ms = DataTableToExcel1(firstsdt, dt, Type, PageSize, PrintWID);
             //以系统当前时间命名文件,FileMode.Create表示创建文件,FileAccess.Write表示拥有写的权限
             string filePath = @FolderPath + "\\" + FileName + ".xls";
             FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
@@ -249,14 +249,14 @@ namespace UAS_LabelMachine
         /// </summary>
         /// <param name="DataTable"></param>
         /// <returns></returns>
-        public MemoryStream DataTableToExcel1(DataTable DataTable, string Type, int PageSize)
+        public MemoryStream DataTableToExcel1(DataTable FirstDT, DataTable DataTable, string Type, int PageSize, bool PrintWID)
         {
             //创建内存流
             MemoryStream ms = new MemoryStream();
             //创建一个Book,相当于一个Excel文件
             HSSFWorkbook book = new HSSFWorkbook();
             //Excel中的Sheet
-            ISheet sheet = book.CreateSheet("sheet1");
+            ISheet sheet = book.CreateSheet("分页");
             //获取行数量和列数量
             int rowNum = DataTable.Rows.Count;
             int columnNum = DataTable.Columns.Count;
@@ -333,13 +333,57 @@ namespace UAS_LabelMachine
             switch (Type)
             {
                 case "FixRow":
+                 
+                    BaseUtil.CleanDataTableData(FirstDT);
+
+                    //首页参数拼接
+                    string First_OrderCode = "";
+                    string First_Prspec = "";
+                    string First_Batch = "";
+                    string First_WID = "";
                     for (int i = 0; i < rowNum; i++)
                     {
                         IRow row1 = sheet.CreateRow(PaintIndex);
                         PaintIndex = PaintIndex + 1;
                         row1.HeightInPoints = 20;
+                        //不包含的订单号
+                        if (!First_OrderCode.Contains(DataTable.Rows[i]["pd_ordercode"].ToString()))
+                        {
+                            First_OrderCode += DataTable.Rows[i]["pd_ordercode"].ToString() + " ";
+                        }
+                        //不包含的物料型号
+                        if (!First_Prspec.Contains(DataTable.Rows[i]["pr_spec"].ToString()))
+                        {
+                            First_Prspec += DataTable.Rows[i]["pr_spec"].ToString() + " ";
+                        }
+                        //不包含扩撒批号
+                        if (!First_Batch.Contains(DataTable.Rows[i]["扩散批号"].ToString()))
+                        {
+                            First_Batch += DataTable.Rows[i]["扩散批号"].ToString() + " ";
+                        }
+                        //不包含Wafer_id
+                        if (!First_WID.Contains(DataTable.Rows[i]["Wafer_ID"].ToString()))
+                        {
+                            First_WID += DataTable.Rows[i]["Wafer_ID"].ToString() + " ";
+                        }
                         if (i / PageSize >= 1 && i % PageSize == 0)
                         {
+                            DataRow dr = FirstDT.NewRow();
+                            dr["型号"] = DataTable.Rows[i]["型号"].ToString();
+                            dr["出货单号"] = DataTable.Rows[i]["出货单号"].ToString();
+                            dr["客户"] = DataTable.Rows[i]["客户"].ToString();
+                            dr["销售日期"] = DataTable.Rows[i]["销售日期"].ToString();
+                            dr["pd_ordercode"] = First_OrderCode;
+                            dr["pr_spec"] = First_Prspec;
+                            dr["ch_splitbatch"] = First_Batch;
+                            dr["ch_waterid"] = First_WID;
+                            dr["num"] = PageSize;
+                            dr["io_qty"] = sumCount;
+                            FirstDT.Rows.Add(dr);
+                            First_OrderCode = "";
+                            First_Prspec = "";
+                            First_Batch = "";
+                            First_WID = "";
                             for (int j = 0; j < columnNum - 4; j++)
                             {
                                 if (j == 0)
@@ -424,7 +468,8 @@ namespace UAS_LabelMachine
                                     }
                                     else
                                         row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].ColumnName);
-                                    if (DataTable.Columns[j].ColumnName.ToLower().Contains("chw_itemname"))
+                                    //如果chw_itemname1的值为空,则值为100和0,其中一列不显示,不显示
+                                    if (DataTable.Columns[j].ColumnName.ToLower().Contains("chw_itemname") || DataTable.Columns[j].ColumnName.ToLower().Contains("pr_spec") || DataTable.Columns[j].ColumnName.ToLower().Contains("pd_ordercode"))
                                     {
                                         sheet.SetColumnHidden(j - 4, true);
                                     }
@@ -452,6 +497,18 @@ namespace UAS_LabelMachine
                         }
                         if (i == rowNum - 1)
                         {
+                            DataRow dr = FirstDT.NewRow();
+                            dr["型号"] = DataTable.Rows[i]["型号"].ToString();
+                            dr["出货单号"] = DataTable.Rows[i]["出货单号"].ToString();
+                            dr["客户"] = DataTable.Rows[i]["客户"].ToString();
+                            dr["销售日期"] = DataTable.Rows[i]["销售日期"].ToString();
+                            dr["pd_ordercode"] = First_OrderCode;
+                            dr["pr_spec"] = First_Prspec;
+                            dr["ch_splitbatch"] = First_Batch;
+                            dr["ch_waterid"] = First_WID;
+                            dr["num"] =(i% PageSize)+1;
+                            dr["io_qty"] = sumCount;
+                            FirstDT.Rows.Add(dr);
                             row1 = sheet.CreateRow(PaintIndex);
                             PaintIndex = PaintIndex + 1;
                             for (int j = 0; j < columnNum - 4; j++)
@@ -609,7 +666,7 @@ namespace UAS_LabelMachine
                                     }
                                     else
                                         row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].ColumnName);
-                                    if (DataTable.Columns[j].ColumnName.ToLower().Contains("chw_itemname"))
+                                    if (DataTable.Columns[j].ColumnName.ToLower().Contains("chw_itemname") || DataTable.Columns[j].ColumnName.ToLower().Contains("pr_spec") || DataTable.Columns[j].ColumnName.ToLower().Contains("pd_ordercode"))
                                     {
                                         sheet.SetColumnHidden(j - 4, true);
                                     }
@@ -795,7 +852,7 @@ namespace UAS_LabelMachine
                                     }
                                     else
                                         row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].ColumnName);
-                                    if (DataTable.Columns[j].ColumnName.ToLower().Contains("chw_itemname"))
+                                    if (DataTable.Columns[j].ColumnName.ToLower().Contains("chw_itemname") || DataTable.Columns[j].ColumnName.ToLower().Contains("pr_spec") || DataTable.Columns[j].ColumnName.ToLower().Contains("pd_ordercode"))
                                     {
                                         sheet.SetColumnHidden(j - 4, true);
                                     }
@@ -888,9 +945,166 @@ namespace UAS_LabelMachine
                 default:
                     break;
             }
+            //填充首页
+            sumCount = 0;
+            totalCount = 0;
+            PaintIndex = 1;
+            ISheet sheet2 = book.CreateSheet("首页");
+            row = sheet2.CreateRow(0);
+            row.CreateCell(0);
+            row.Cells[0].SetCellValue("                     深爱半导体有限公司芯片出货清单");
+            row.GetCell(0).CellStyle = style;
+            rowNum = FirstDT.Rows.Count;
+            columnNum = FirstDT.Columns.Count;
+
+            for (int i = 0; i < columnNum; i++)
+            {
+                if (FirstDT.Columns[i].ColumnName.ToLower().Contains("pd_ordercode"))
+                {
+                    FirstDT.Columns[i].ColumnName = "订单号";
+                }
+                if (FirstDT.Columns[i].ColumnName.ToLower().Contains("pr_spec"))
+                {
+                    FirstDT.Columns[i].ColumnName = "产品型号";
+                }
+                if (FirstDT.Columns[i].ColumnName.ToLower().Contains("ch_splitbatch"))
+                {
+                    FirstDT.Columns[i].ColumnName = "批号";
+                }
+                if (FirstDT.Columns[i].ColumnName.ToLower().Contains("ch_waterid"))
+                {
+                    FirstDT.Columns[i].ColumnName = "片号";
+                }
+                if (FirstDT.Columns[i].ColumnName.ToLower().Contains("num"))
+                {
+                    FirstDT.Columns[i].ColumnName = "片数";
+                }
+                if (FirstDT.Columns[i].ColumnName.ToLower().Contains("io_qty"))
+                {
+                    FirstDT.Columns[i].ColumnName = "管芯数";
+                }
+            }
+
+            for (int i = 0; i < rowNum; i++)
+            {
+                IRow row1 = sheet2.CreateRow(PaintIndex);
+                PaintIndex = PaintIndex + 1;
+                row1.HeightInPoints = 20;
+                //只需要绘制一行
+                if (i == 0)
+                {
+                    for (int j = 0; j < columnNum - 3; j++)
+                    {
+                        if (j == 0)
+                        {
+                            row1.CreateCell(j);
+                            row1.Cells[j].SetCellValue(FirstDT.Rows[i]["客户"].ToString());
+                        }
+                        else if (j == columnNum - 4)
+                        {
+                            row1.CreateCell(j);
+                            row1.Cells[j].SetCellValue(FirstDT.Rows[i]["出货单号"].ToString());
+                        }
+                        else
+                        {
+                            row1.CreateCell(j);
+                        }
+                        row1.GetCell(j).CellStyle = style;
+                    }
+                    row1 = sheet2.CreateRow(PaintIndex);
+                    PaintIndex = PaintIndex + 1;
+                    //第二行添加型号
+                    for (int j = 0; j < columnNum - 3; j++)
+                    {
+                        if (j == 0)
+                        {
+                            row1.CreateCell(j);
+                            row1.Cells[j].SetCellValue(FirstDT.Rows[i]["型号"].ToString());
+                        }
+                        else if (j == columnNum - 4)
+                        {
+                            row1.CreateCell(j);
+                            row1.Cells[j].SetCellValue(FirstDT.Rows[i]["销售日期"].ToString());
+                        }
+                        else
+                        {
+                            row1.CreateCell(j);
+                        }
+                        row1.GetCell(j).CellStyle = style;
+                    }
+                    row1 = sheet2.CreateRow(PaintIndex);
+                    PaintIndex = PaintIndex + 1;
+                    //添加列名
+                    for (int j = 4; j < columnNum; j++)
+                    {
+                        row1.CreateCell(j - 4);
+                        row1.Cells[j - 4].CellStyle = styleborder;
+                        row1.Cells[j - 4].SetCellValue(FirstDT.Columns[j].ColumnName);
+                    }
+                    row1 = sheet2.CreateRow(PaintIndex);
+                    PaintIndex = PaintIndex + 1;
+                }
+                //添加数据内容
+                for (int j = 4; j < columnNum; j++)
+                {
+                    string Data = FirstDT.Rows[i][j].ToString();
+                    row1.CreateCell(j - 4);
+                    row1.Cells[j - 4].SetCellValue(Data);
+                    row1.GetCell(j - 4).CellStyle = styleborder;
+                    if (FirstDT.Columns[j].ColumnName == "片数")
+                    {
+                        sumCount += int.Parse(Data);
+                    }
+                    if (FirstDT.Columns[j].ColumnName == "管芯数")
+                    {
+                        totalCount += int.Parse(Data);
+                    }
+                }
+                //添加总计行
+                if (i == rowNum - 1)
+                {
+                    row1 = sheet2.CreateRow(PaintIndex);
+                    PaintIndex = PaintIndex + 1;
+                    for (int j = 0; j < columnNum - 4; j++)
+                    {
+                        if (j == 0)
+                        {
+                            row1.CreateCell(j);
+                            row1.Cells[j].CellStyle = styleborder;
+                            row1.Cells[j].SetCellValue("总计");
+                        }
+                        else if (j == columnNum - 6)
+                        {
+                            row1.CreateCell(j);
+                            row1.Cells[j].CellStyle = styleborder;
+                            row1.Cells[j].SetCellValue(sumCount);
+                        }
+                        else if (j == columnNum - 5)
+                        {
+                            row1.CreateCell(j);
+                            row1.Cells[j].CellStyle = styleborder;
+                            row1.Cells[j].SetCellValue(totalCount);
+                        }
+                        else
+                        {
+                            row1.CreateCell(j);
+                            row1.Cells[j].CellStyle = styleborder;
+                        }
+                    }
+                }
+            }
+            for (int i = 0; i < sheet2.LastRowNum; i++)
+            {
+                if (i != 0)
+                {
+                    sheet2.AutoSizeColumn(i);
+                    sheet2.SetColumnWidth(i, sheet2.GetColumnWidth(i) + 1000);
+                }
+            }
+
             //将book的内容写入内存流中返回
             book.Write(ms);
             return ms;
         }
     }
-}
+}

+ 36 - 0
UAS-出货标签管理(贸易版)/PublicMethod/LogicHandler.cs

@@ -98,11 +98,47 @@ namespace UAS_LabelMachine.PublicMethod
                 case "N_HC":
                     ImportExcel_HC(iFileName, iPiID, iInOutNo, iCustCode);
                     break;
+                case "SZSI_TEST":
+                    ImportExcel_SZSI(iFileName, iPiID, iInOutNo, iCustCode);
+                    break;
                 default:
                     break;
             }
         }
 
+        public static void ImportExcel_SZSI(string iFileName, string iPiID, string iInOutNo, string iCustCode)
+        {
+            StringBuilder sql = new StringBuilder();
+            //获取最大的流水号
+            DataTable dt = ExcelHandler.ExcelToDataTable(iFileName, true);
+            if (dt == null)
+            {
+                MessageBox.Show("文件" + iFileName + "被占用或者格式不正确");
+                return;
+            }
+            ArrayList<string> detno = new ArrayList<string>();
+            ArrayList<string> batch = new ArrayList<string>();
+            ArrayList<string> gk = new ArrayList<string>();
+            ArrayList<string> weigh = new ArrayList<string>();
+            ArrayList<string> qty = new ArrayList<string>();
+            ArrayList<string> outboxcode1 = new ArrayList<string>();
+            string prcode = dh.getFieldDataByCondition("prodiodetail", "pd_prodcode", "pd_piid=" + iPiID).ToString();
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                if (dt.Columns.Contains("序号")) { detno.Add(dt.Rows[i]["序号"]); } else detno.Add("");
+                if (dt.Columns.Contains("批号")) { batch.Add(dt.Rows[i]["批号"]); } else batch.Add("");
+                if (dt.Columns.Contains("g/K")) { gk.Add(dt.Rows[i]["g/K"]); } else gk.Add("");
+                if (dt.Columns.Contains("净重(g)")) { weigh.Add(dt.Rows[i]["净重(g)"]); } else weigh.Add("");
+                if (dt.Columns.Contains("数量")) { qty.Add(dt.Rows[i]["数量"]); } else qty.Add("");
+                if (dt.Columns.Contains("盒号")) { outboxcode1.Add(dt.Rows[i]["盒号"]); } else outboxcode1.Add("");
+            }
+            sql.Clear();
+            sql.Append("insert into prodiobarcode (pib_id,pib_piid,pib_inoutno,pib_pdno,pib_custbarcode,pib_gk,pib_weigh,pib_qty,pib_outboxcode1,pib_prodcode) values(prodiobarcode_seq.nextval,'" + iPiID + "',");
+            sql.Append("'" + iInOutNo + "',:pib_pdno,:pib_lotno,:pib_gk,:pib_weiht,:pib_qty,:pib_outboxcode1,'" + prcode + "')");
+            dh.BatchInsert(sql.ToString(), new string[] { "pib_pdno", "pib_lotno", "pib_gk", "pib_weiht", "pib_qty", "pib_outboxcode1" }, detno.ToArray(), batch.ToArray(), gk.ToArray(), weigh.ToArray(), qty.ToArray(), outboxcode1.ToArray());
+
+        }
+
         //海创的导入方法
         public static void ImportExcel_HC(string iFileName, string iPiID, string iInOutNo, string iCustCode)
         {

+ 6 - 0
UAS-出货标签管理(贸易版)/UAS_出货标签管理.cs

@@ -2326,6 +2326,7 @@ namespace UAS_LabelMachine
                     break;
                 case "导出数据":
                     ExportExcel ex = new ExportExcel(pi_inoutno.Text);
+                    ex.StartPosition = FormStartPosition.CenterScreen;
                     ex.ShowDialog();
                     //ExportFileDialog.Description = "选择导出的路径";
                     //result = ExportFileDialog.ShowDialog();
@@ -2542,8 +2543,13 @@ namespace UAS_LabelMachine
             string maxnum = dh.getFieldDataByCondition("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + NrCode + "' and rmn_prefix='" + Prefix + "'").ToString();
             if (maxnum == "")
             {
+
                 dh.ExecuteSql("insert into RuleMaxNum(rmn_id,rmn_nrcode,rmn_prefix,rmn_maxnumber) values(RuleMaxNum_seq.nextval,'" + NrCode + "','" + Prefix + "','1')", "insert");
                 maxnum = dh.getFieldDataByCondition("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + NrCode + "' and rmn_prefix='" + Prefix + "'").ToString();
+                if (maxnum == "")
+                {
+                    maxnum = "0";
+                }
                 custserialnum = int.Parse(maxnum);
             }//如果流水号不为空则取当前流水
             else