Browse Source

代码提交

callm 5 years ago
parent
commit
73c720ecdd

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

@@ -65,9 +65,10 @@
             this.groupBox2 = new System.Windows.Forms.GroupBox();
             this.Chinese = new System.Windows.Forms.RadioButton();
             this.English = new System.Windows.Forms.RadioButton();
-            this.RowNum = new UAS_LabelMachine.CustomControl.NumOnlyTextBox();
             this.CH_YIELD = new System.Windows.Forms.CheckBox();
             this.FirstPage_BOXCODE = new System.Windows.Forms.CheckBox();
+            this.BoxSplit = new System.Windows.Forms.RadioButton();
+            this.RowNum = new UAS_LabelMachine.CustomControl.NumOnlyTextBox();
             this.groupBox1.SuspendLayout();
             this.groupBox2.SuspendLayout();
             this.SuspendLayout();
@@ -280,7 +281,7 @@
             // 
             this.BoxCode.AutoSize = true;
             this.BoxCode.Font = new System.Drawing.Font("宋体", 10F);
-            this.BoxCode.Location = new System.Drawing.Point(444, 432);
+            this.BoxCode.Location = new System.Drawing.Point(416, 432);
             this.BoxCode.Margin = new System.Windows.Forms.Padding(4);
             this.BoxCode.Name = "BoxCode";
             this.BoxCode.Size = new System.Drawing.Size(97, 31);
@@ -293,7 +294,7 @@
             this.FixRow.AutoSize = true;
             this.FixRow.Checked = true;
             this.FixRow.Font = new System.Drawing.Font("宋体", 10F);
-            this.FixRow.Location = new System.Drawing.Point(612, 432);
+            this.FixRow.Location = new System.Drawing.Point(541, 430);
             this.FixRow.Margin = new System.Windows.Forms.Padding(4);
             this.FixRow.Name = "FixRow";
             this.FixRow.Size = new System.Drawing.Size(151, 31);
@@ -306,7 +307,7 @@
             // 
             this.label7.AutoSize = true;
             this.label7.Font = new System.Drawing.Font("宋体", 10F);
-            this.label7.Location = new System.Drawing.Point(810, 432);
+            this.label7.Location = new System.Drawing.Point(689, 432);
             this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label7.Name = "label7";
             this.label7.Size = new System.Drawing.Size(134, 27);
@@ -509,16 +510,6 @@
             this.English.Text = "英文";
             this.English.UseVisualStyleBackColor = true;
             // 
-            // RowNum
-            // 
-            this.RowNum.Location = new System.Drawing.Point(960, 428);
-            this.RowNum.Margin = new System.Windows.Forms.Padding(4);
-            this.RowNum.Name = "RowNum";
-            this.RowNum.Negative = false;
-            this.RowNum.Size = new System.Drawing.Size(100, 35);
-            this.RowNum.TabIndex = 30;
-            this.RowNum.Text = "10";
-            // 
             // CH_YIELD
             // 
             this.CH_YIELD.AutoSize = true;
@@ -543,11 +534,35 @@
             this.FirstPage_BOXCODE.Text = "盒号";
             this.FirstPage_BOXCODE.UseVisualStyleBackColor = true;
             // 
+            // BoxSplit
+            // 
+            this.BoxSplit.AutoSize = true;
+            this.BoxSplit.Font = new System.Drawing.Font("宋体", 10F);
+            this.BoxSplit.Location = new System.Drawing.Point(909, 615);
+            this.BoxSplit.Margin = new System.Windows.Forms.Padding(4);
+            this.BoxSplit.Name = "BoxSplit";
+            this.BoxSplit.Size = new System.Drawing.Size(151, 31);
+            this.BoxSplit.TabIndex = 46;
+            this.BoxSplit.Text = "盒号拆批";
+            this.BoxSplit.UseVisualStyleBackColor = true;
+            this.BoxSplit.Visible = false;
+            // 
+            // RowNum
+            // 
+            this.RowNum.Location = new System.Drawing.Point(843, 428);
+            this.RowNum.Margin = new System.Windows.Forms.Padding(4);
+            this.RowNum.Name = "RowNum";
+            this.RowNum.Negative = false;
+            this.RowNum.Size = new System.Drawing.Size(100, 35);
+            this.RowNum.TabIndex = 30;
+            this.RowNum.Text = "10";
+            // 
             // ExportExcel
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1144, 704);
+            this.Controls.Add(this.BoxSplit);
             this.Controls.Add(this.FirstPage_BOXCODE);
             this.Controls.Add(this.CH_YIELD);
             this.Controls.Add(this.groupBox2);
@@ -638,5 +653,6 @@
         private System.Windows.Forms.RadioButton English;
         private System.Windows.Forms.CheckBox CH_YIELD;
         private System.Windows.Forms.CheckBox FirstPage_BOXCODE;
+        private System.Windows.Forms.RadioButton BoxSplit;
     }
 }

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

@@ -84,6 +84,10 @@ namespace UAS_LabelMachine
                 {
                     SplitType = BoxCode.Name;
                 }
+                else if (BoxSplit.Checked)
+                {
+                    SplitType = BoxSplit.Name;
+                }
                 string caption = "";
                 if (Chinese.Checked)
                 {

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

@@ -3247,7 +3247,7 @@ namespace UAS_LabelMachine
                                     if (j == 0)
                                     {
                                         row1.CreateCell(j);
-                                        row1.Cells[j].SetCellValue(DataTable.Columns["pr_orispeccode"].Caption + ":" + DataTable.Rows[i]["pr_orispeccode"].ToString() + "  "
+                                        row1.Cells[j].SetCellValue(DataTable.Columns["pr_orispeccode"].Caption + ":" + DataTable.Rows[i]["pr_orispeccode"].ToString() + "_"
                                   + "(" + DataTable.Rows[i]["me_desc"].ToString() + ") " + DataTable.Columns["pi_chipouttype"].Caption + ":" + DataTable.Rows[i]["pi_chipouttype"].ToString());
                                     }
                                     else if (j == ShowSizeIndex)
@@ -3555,7 +3555,7 @@ namespace UAS_LabelMachine
                                     if (j == 0)
                                     {
                                         row1.CreateCell(j);
-                                        row1.Cells[j].SetCellValue(DataTable.Columns["pr_orispeccode"].Caption + ":" + DataTable.Rows[i]["pr_orispeccode"].ToString() + "  "
+                                        row1.Cells[j].SetCellValue(DataTable.Columns["pr_orispeccode"].Caption + ":" + DataTable.Rows[i]["pr_orispeccode"].ToString() + "_"
                                   + "(" + DataTable.Rows[i]["me_desc"].ToString() + ") " + DataTable.Columns["pi_chipouttype"].Caption + ":" + DataTable.Rows[i]["pi_chipouttype"].ToString());
                                     }
                                     else if (j == ShowSizeIndex)
@@ -3761,6 +3761,324 @@ namespace UAS_LabelMachine
                         pib_outboxcode1.Add(BoxCode.ToString());
                     }
                     break;
+                case "BoxSplit":
+                    string LastBoxCode1 = "";
+                    int PageNum2 = 0;
+                    string LastBatch = "";
+                    for (int i = 0; i < rowNum; i++)
+                    {
+                        IRow row1 = sheet.CreateRow(PaintIndex);
+                        PaintIndex = PaintIndex + 1;
+                        row1.HeightInPoints = RowHeight;
+                        //如果批号不相等的时候
+                        if (LastBoxCode1 != "" && LastBoxCode1 != DataTable.Rows[i]["CH_PBCODE"].ToString())
+                        {
+                            BoxCode = BoxCode + 1;
+                            for (int j = 0; j < ShowColumnCount; j++)
+                            {
+                                row1.CreateCell(j);
+                                if (j == 0)
+                                {
+                                    row1.Cells[j].SetCellValue(批小计);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else if (j == ShowPieceIndex)
+                                {
+                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum2 + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else if (j == ShowCountIndex)
+                                {
+                                    row1.Cells[j].SetCellValue(sumCount);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else if (j == ShowBoxIndex - 4)
+                                {
+                                    row1.Cells[j].SetCellValue(LastBox);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else
+                                {
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                            }
+                            row1 = sheet.CreateRow(PaintIndex);
+                            PaintIndex = PaintIndex + 1;
+                            for (int j = 0; j < ShowColumnCount; j++)
+                            {
+                                row1.CreateCell(j);
+                                if (j == 0)
+                                {
+                                    row1.Cells[j].SetCellValue(小计);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else if (j == ShowPieceIndex)
+                                {
+                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum2 + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else if (j == ShowCountIndex)
+                                {
+                                    row1.Cells[j].SetCellValue(sumCount);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else if (j == ShowBoxIndex - 4)
+                                {
+                                    row1.Cells[j].SetCellValue(LastBox);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else
+                                {
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                            }
+                            sumCount = 0;
+                            row1 = sheet.CreateRow(PaintIndex);
+                            sheet.SetRowBreak(PaintIndex - 1);
+                            sheet.Footer.Center = "第&P页,共&N页";
+                            PaintIndex = PaintIndex + 1;
+                            PageNum2 = 0;
+                        }
+                        //每次到了页数开始分页
+                        if (LastBoxCode1 == "" || (LastBoxCode1 != "" && LastBoxCode1 != DataTable.Rows[i]["ch_pbcode"].ToString()) || ((i == rowNum - 1) && (LastBoxCode1 != "" && LastBoxCode1 != DataTable.Rows[i]["ch_pbcode"].ToString())))
+                        {
+                            LastBoxCode1 = DataTable.Rows[i]["CH_PBCODE"].ToString();
+                            //第一行添加客户信息
+                            //if (i != rowNum - 1)
+                            {
+                                for (int j = 0; j < columnNum - 3; j++)
+                                {
+                                    if (j == 0)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Columns["pi_title"].Caption + ":" + DataTable.Rows[i]["pi_title"].ToString() + "  "
+                                           + DataTable.Columns["ch_level"].Caption + ":" + DataTable.Rows[i]["ch_level"].ToString());
+                                    }
+                                    else if (j == ShowDataIndex)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Columns["pi_inoutno"].Caption + ":" + DataTable.Rows[i]["pi_inoutno"].ToString());
+                                    }
+                                    else
+                                    {
+                                        row1.CreateCell(j);
+                                    }
+                                    row1.GetCell(j).CellStyle = style;
+                                }
+                                row1 = sheet.CreateRow(PaintIndex);
+                                PaintIndex = PaintIndex + 1;
+                                //第二行添加型号
+                                for (int j = 0; j < columnNum - 3; j++)
+                                {
+                                    if (j == 0)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Columns["pr_orispeccode"].Caption + ":" + DataTable.Rows[i]["pr_orispeccode"].ToString() + "_"
+                                  + "(" + DataTable.Rows[i]["me_desc"].ToString() + ") " + DataTable.Columns["pi_chipouttype"].Caption + ":" + DataTable.Rows[i]["pi_chipouttype"].ToString());
+                                    }
+                                    else if (j == ShowSizeIndex)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
+                                    }
+                                    else if (j == ShowDataIndex)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Columns["pi_date"].Caption + ":" + DataTable.Rows[i]["pi_date"].ToString());
+                                    }
+                                    else
+                                    {
+                                        row1.CreateCell(j);
+                                    }
+                                }
+                                //添加列名
+                                row1 = sheet.CreateRow(PaintIndex);
+                                PaintIndex = PaintIndex + 1;
+                                int showcount = 0;
+                                for (int j = 4; j < columnNum; j++)
+                                {
+                                    if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1")
+                                    {
+                                        showcount = showcount + 1;
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname1"].ToString());
+                                    }
+                                    else if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2")
+                                    {
+                                        showcount = showcount + 1;
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname2"].ToString());
+                                    }
+                                    else if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent3")
+                                    {
+                                        showcount = showcount + 1;
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname3"].ToString());
+                                    }
+                                    else if ((NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())))
+                                    {
+
+                                    }
+                                    else
+                                    {
+                                        showcount = showcount + 1;
+                                        row1.CreateCell(j - 4);
+                                        row1.Cells[j - 4].CellStyle = ColumnTitleStyle;
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].Caption);
+                                    }
+                                    if (DataTable.Columns[j].ColumnName.ToLower().ToString() == "ch_pbcode")
+                                    {
+                                        ShowBoxIndex = j;
+                                    }
+                                    if (DataTable.Columns[j].ColumnName.ToString() == "io_qty")
+                                    {
+                                        NumIndex = j;
+                                        if (ShowCountIndex == NumIndex - 4)
+                                        {
+                                            ShowCountIndex = ShowCountIndex + 1;
+                                        }
+                                    }
+                                }
+                                ShowColumnCount = showcount;
+                                row1 = sheet.CreateRow(PaintIndex);
+                                PaintIndex = PaintIndex + 1;
+                            }
+                        }
+                        //添加数据内容
+                        for (int j = 4; j < columnNum; j++)
+                        {
+                            string Data = DataTable.Rows[i][j].ToString();
+                            row1.CreateCell(j - 4);
+                            if ((NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())))
+                            {
+
+                            }
+                            else
+                            {
+                                row1.Cells[j - 4].SetCellValue(Data);
+                                row1.GetCell(j - 4).CellStyle = styleborder;
+                            }
+                            if (DataTable.Columns[j].ColumnName == "io_qty")
+                            {
+                                row1.Cells[j - 4].SetCellValue(int.Parse(Data));
+                                sumCount += int.Parse(DataTable.Rows[i][j].ToString());
+                                totalCount += int.Parse(DataTable.Rows[i][j].ToString());
+                            }
+                            if (DataTable.Columns[j].ColumnName == "rownum")
+                            {
+                                row1.Cells[j - 4].SetCellValue(i + 1);
+                            }
+                            if (DataTable.Columns[j].ColumnName == "ch_code")
+                            {
+                                sheet.AutoSizeColumn(j - 4);
+                                sheet.SetColumnWidth(j - 4, sheet.GetColumnWidth(j - 4) + 1000);
+                            }
+                            if (DataTable.Columns[j].ColumnName.ToLower() == "ch_pbcode")
+                            {
+                                LastBox = Data;
+                            }
+                        }
+                        if (i == rowNum - 1)
+                        {
+                            PageNum2 = PageNum2 + 1;
+                            row1 = sheet.CreateRow(PaintIndex);
+                            PaintIndex = PaintIndex + 1;
+                            for (int j = 0; j < ShowColumnCount; j++)
+                            {
+                                row1.CreateCell(j);
+                                if (j == 0)
+                                {
+                                    row1.Cells[j].SetCellValue(批小计);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else if (j == ShowPieceIndex)
+                                {
+                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum2 + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else if (j == ShowCountIndex)
+                                {
+                                    row1.Cells[j].SetCellValue(sumCount);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else if (j == ShowBoxIndex - 4)
+                                {
+                                    row1.Cells[j].SetCellValue(LastBox);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else
+                                {
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                            }
+                            row1 = sheet.CreateRow(PaintIndex);
+                            PaintIndex = PaintIndex + 1;
+                            for (int j = 0; j < ShowColumnCount; j++)
+                            {
+                                row1.CreateCell(j);
+                                if (j == 0)
+                                {
+                                    row1.Cells[j].SetCellValue(小计);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else if (j == ShowPieceIndex)
+                                {
+                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum2 + 片);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else if (j == ShowCountIndex)
+                                {
+                                    row1.Cells[j].SetCellValue(sumCount);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else if (j == ShowBoxIndex - 4)
+                                {
+                                    row1.Cells[j].SetCellValue(LastBox);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else
+                                {
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                            }
+                            row1 = sheet.CreateRow(PaintIndex);
+
+                            for (int j = 0; j < columnNum - 3; j++)
+                            {
+                                if (j == 0)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("备注");
+                                }
+                                else if (j == ShowCountIndex)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(totalCount);
+                                }
+                                else if (j == ShowRemarkPiece)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(rowNum + 片);
+                                }
+                                else
+                                {
+                                    row1.CreateCell(j);
+                                }
+                                row1.Cells[j].CellStyle = style;
+                            }
+                            sheet.SetRowBreak(PaintIndex);
+                            sheet.Footer.Center = "第&P页,共&N页";
+                            PaintIndex = PaintIndex + 1;
+                            PageNum1 = 0;
+                        }
+                        PageNum2 = PageNum2 + 1;
+                        pib_id.Add(DataTable.Rows[i]["pib_id"].ToString());
+                        pib_outboxcode1.Add(BoxCode.ToString());
+                    }
+                    break;
                 default:
                     break;
             }