소스 검색

Merge branch 'master' of ssh://10.10.100.21/source/mes-client

caosy 6 년 전
부모
커밋
4c8930f41b

+ 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, "客户标签");
+                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();

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

@@ -0,0 +1,369 @@
+namespace UAS_LabelMachine
+{
+    partial class ExportExcel
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.Export = new System.Windows.Forms.Button();
+            this.CH_BLUEFILM = new System.Windows.Forms.CheckBox();
+            this.CH_SPLITBATCH = new System.Windows.Forms.CheckBox();
+            this.CH_PBCODE = new System.Windows.Forms.CheckBox();
+            this.CH_REMARK = new System.Windows.Forms.CheckBox();
+            this.ch_code = new System.Windows.Forms.CheckBox();
+            this.CH_WATERID = new System.Windows.Forms.CheckBox();
+            this.label1 = new System.Windows.Forms.Label();
+            this.label2 = new System.Windows.Forms.Label();
+            this.label3 = new System.Windows.Forms.Label();
+            this.label4 = new System.Windows.Forms.Label();
+            this.BVCEO = new System.Windows.Forms.CheckBox();
+            this.TS = new System.Windows.Forms.CheckBox();
+            this.percent = new System.Windows.Forms.CheckBox();
+            this.label5 = new System.Windows.Forms.Label();
+            this.label6 = new System.Windows.Forms.Label();
+            this.BatchCode = new System.Windows.Forms.RadioButton();
+            this.BoxCode = new System.Windows.Forms.RadioButton();
+            this.FixRow = new System.Windows.Forms.RadioButton();
+            this.label7 = new System.Windows.Forms.Label();
+            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
+            // 
+            this.Export.Location = new System.Drawing.Point(479, 576);
+            this.Export.Name = "Export";
+            this.Export.Size = new System.Drawing.Size(189, 49);
+            this.Export.TabIndex = 0;
+            this.Export.Text = "导出";
+            this.Export.UseVisualStyleBackColor = true;
+            this.Export.Click += new System.EventHandler(this.Export_Click);
+            // 
+            // CH_BLUEFILM
+            // 
+            this.CH_BLUEFILM.AutoSize = true;
+            this.CH_BLUEFILM.Checked = true;
+            this.CH_BLUEFILM.CheckState = System.Windows.Forms.CheckState.Checked;
+            this.CH_BLUEFILM.Font = new System.Drawing.Font("宋体", 10F);
+            this.CH_BLUEFILM.Location = new System.Drawing.Point(259, 115);
+            this.CH_BLUEFILM.Name = "CH_BLUEFILM";
+            this.CH_BLUEFILM.Size = new System.Drawing.Size(125, 31);
+            this.CH_BLUEFILM.TabIndex = 1;
+            this.CH_BLUEFILM.Text = "蓝膜号";
+            this.CH_BLUEFILM.UseVisualStyleBackColor = true;
+            // 
+            // CH_SPLITBATCH
+            // 
+            this.CH_SPLITBATCH.AutoSize = true;
+            this.CH_SPLITBATCH.Checked = true;
+            this.CH_SPLITBATCH.CheckState = System.Windows.Forms.CheckState.Checked;
+            this.CH_SPLITBATCH.Font = new System.Drawing.Font("宋体", 10F);
+            this.CH_SPLITBATCH.Location = new System.Drawing.Point(701, 115);
+            this.CH_SPLITBATCH.Name = "CH_SPLITBATCH";
+            this.CH_SPLITBATCH.Size = new System.Drawing.Size(152, 31);
+            this.CH_SPLITBATCH.TabIndex = 3;
+            this.CH_SPLITBATCH.Text = "扩散批号";
+            this.CH_SPLITBATCH.UseVisualStyleBackColor = true;
+            // 
+            // CH_PBCODE
+            // 
+            this.CH_PBCODE.AutoSize = true;
+            this.CH_PBCODE.Checked = true;
+            this.CH_PBCODE.CheckState = System.Windows.Forms.CheckState.Checked;
+            this.CH_PBCODE.Font = new System.Drawing.Font("宋体", 10F);
+            this.CH_PBCODE.Location = new System.Drawing.Point(259, 189);
+            this.CH_PBCODE.Name = "CH_PBCODE";
+            this.CH_PBCODE.Size = new System.Drawing.Size(98, 31);
+            this.CH_PBCODE.TabIndex = 8;
+            this.CH_PBCODE.Text = "盒号";
+            this.CH_PBCODE.UseVisualStyleBackColor = true;
+            // 
+            // CH_REMARK
+            // 
+            this.CH_REMARK.AutoSize = true;
+            this.CH_REMARK.Checked = true;
+            this.CH_REMARK.CheckState = System.Windows.Forms.CheckState.Checked;
+            this.CH_REMARK.Font = new System.Drawing.Font("宋体", 10F);
+            this.CH_REMARK.Location = new System.Drawing.Point(487, 189);
+            this.CH_REMARK.Name = "CH_REMARK";
+            this.CH_REMARK.Size = new System.Drawing.Size(152, 31);
+            this.CH_REMARK.TabIndex = 9;
+            this.CH_REMARK.Text = "芯片备注";
+            this.CH_REMARK.UseVisualStyleBackColor = true;
+            // 
+            // ch_code
+            // 
+            this.ch_code.AutoSize = true;
+            this.ch_code.Checked = true;
+            this.ch_code.CheckState = System.Windows.Forms.CheckState.Checked;
+            this.ch_code.Font = new System.Drawing.Font("宋体", 10F);
+            this.ch_code.Location = new System.Drawing.Point(487, 115);
+            this.ch_code.Name = "ch_code";
+            this.ch_code.Size = new System.Drawing.Size(125, 31);
+            this.ch_code.TabIndex = 10;
+            this.ch_code.Text = "芯片号";
+            this.ch_code.UseVisualStyleBackColor = true;
+            // 
+            // CH_WATERID
+            // 
+            this.CH_WATERID.AutoSize = true;
+            this.CH_WATERID.Checked = true;
+            this.CH_WATERID.CheckState = System.Windows.Forms.CheckState.Checked;
+            this.CH_WATERID.Font = new System.Drawing.Font("宋体", 10F);
+            this.CH_WATERID.Location = new System.Drawing.Point(905, 115);
+            this.CH_WATERID.Name = "CH_WATERID";
+            this.CH_WATERID.Size = new System.Drawing.Size(156, 31);
+            this.CH_WATERID.TabIndex = 11;
+            this.CH_WATERID.Text = "Wafer_ID";
+            this.CH_WATERID.UseVisualStyleBackColor = true;
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("宋体", 10F);
+            this.label1.Location = new System.Drawing.Point(22, 52);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(120, 27);
+            this.label1.TabIndex = 12;
+            this.label1.Text = "打印选项";
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Font = new System.Drawing.Font("宋体", 10F);
+            this.label2.Location = new System.Drawing.Point(22, 119);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(215, 27);
+            this.label2.TabIndex = 13;
+            this.label2.Text = "请选择打印内容:";
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Font = new System.Drawing.Font("宋体", 10F);
+            this.label3.Location = new System.Drawing.Point(22, 261);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(216, 27);
+            this.label3.TabIndex = 14;
+            this.label3.Text = "参数选择(机测):";
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Font = new System.Drawing.Font("宋体", 10F);
+            this.label4.Location = new System.Drawing.Point(22, 351);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(216, 27);
+            this.label4.TabIndex = 15;
+            this.label4.Text = "参数选择(手测):";
+            // 
+            // BVCEO
+            // 
+            this.BVCEO.AutoSize = true;
+            this.BVCEO.Checked = true;
+            this.BVCEO.CheckState = System.Windows.Forms.CheckState.Checked;
+            this.BVCEO.Font = new System.Drawing.Font("宋体", 10F);
+            this.BVCEO.Location = new System.Drawing.Point(487, 347);
+            this.BVCEO.Name = "BVCEO";
+            this.BVCEO.Size = new System.Drawing.Size(114, 31);
+            this.BVCEO.TabIndex = 17;
+            this.BVCEO.Text = "BVCEO";
+            this.BVCEO.UseVisualStyleBackColor = true;
+            // 
+            // TS
+            // 
+            this.TS.AutoSize = true;
+            this.TS.Checked = true;
+            this.TS.CheckState = System.Windows.Forms.CheckState.Checked;
+            this.TS.Font = new System.Drawing.Font("宋体", 10F);
+            this.TS.Location = new System.Drawing.Point(259, 347);
+            this.TS.Name = "TS";
+            this.TS.Size = new System.Drawing.Size(72, 31);
+            this.TS.TabIndex = 18;
+            this.TS.Text = "TS";
+            this.TS.UseVisualStyleBackColor = true;
+            // 
+            // percent
+            // 
+            this.percent.AutoSize = true;
+            this.percent.Checked = true;
+            this.percent.CheckState = System.Windows.Forms.CheckState.Checked;
+            this.percent.Font = new System.Drawing.Font("宋体", 10F);
+            this.percent.Location = new System.Drawing.Point(259, 257);
+            this.percent.Name = "percent";
+            this.percent.Size = new System.Drawing.Size(86, 31);
+            this.percent.TabIndex = 19;
+            this.percent.Text = "HFS";
+            this.percent.UseVisualStyleBackColor = true;
+            // 
+            // label5
+            // 
+            this.label5.AutoSize = true;
+            this.label5.Font = new System.Drawing.Font("宋体", 10F);
+            this.label5.Location = new System.Drawing.Point(22, 508);
+            this.label5.Name = "label5";
+            this.label5.Size = new System.Drawing.Size(188, 27);
+            this.label5.TabIndex = 20;
+            this.label5.Text = "首页打印方式:";
+            // 
+            // label6
+            // 
+            this.label6.AutoSize = true;
+            this.label6.Font = new System.Drawing.Font("宋体", 10F);
+            this.label6.Location = new System.Drawing.Point(22, 433);
+            this.label6.Name = "label6";
+            this.label6.Size = new System.Drawing.Size(188, 27);
+            this.label6.TabIndex = 21;
+            this.label6.Text = "打印分页方式:";
+            // 
+            // BatchCode
+            // 
+            this.BatchCode.AutoSize = true;
+            this.BatchCode.Font = new System.Drawing.Font("宋体", 10F);
+            this.BatchCode.Location = new System.Drawing.Point(259, 431);
+            this.BatchCode.Name = "BatchCode";
+            this.BatchCode.Size = new System.Drawing.Size(124, 31);
+            this.BatchCode.TabIndex = 22;
+            this.BatchCode.Text = "扩散批";
+            this.BatchCode.UseVisualStyleBackColor = true;
+            // 
+            // BoxCode
+            // 
+            this.BoxCode.AutoSize = true;
+            this.BoxCode.Font = new System.Drawing.Font("宋体", 10F);
+            this.BoxCode.Location = new System.Drawing.Point(445, 431);
+            this.BoxCode.Name = "BoxCode";
+            this.BoxCode.Size = new System.Drawing.Size(97, 31);
+            this.BoxCode.TabIndex = 23;
+            this.BoxCode.Text = "盒号";
+            this.BoxCode.UseVisualStyleBackColor = true;
+            // 
+            // FixRow
+            // 
+            this.FixRow.AutoSize = true;
+            this.FixRow.Checked = true;
+            this.FixRow.Font = new System.Drawing.Font("宋体", 10F);
+            this.FixRow.Location = new System.Drawing.Point(611, 431);
+            this.FixRow.Name = "FixRow";
+            this.FixRow.Size = new System.Drawing.Size(151, 31);
+            this.FixRow.TabIndex = 24;
+            this.FixRow.TabStop = true;
+            this.FixRow.Text = "固定行号";
+            this.FixRow.UseVisualStyleBackColor = true;
+            // 
+            // label7
+            // 
+            this.label7.AutoSize = true;
+            this.label7.Font = new System.Drawing.Font("宋体", 10F);
+            this.label7.Location = new System.Drawing.Point(810, 431);
+            this.label7.Name = "label7";
+            this.label7.Size = new System.Drawing.Size(134, 27);
+            this.label7.TabIndex = 25;
+            this.label7.Text = "分页行数:";
+            // 
+            // FirstPage_WID
+            // 
+            this.FirstPage_WID.AutoSize = true;
+            this.FirstPage_WID.Font = new System.Drawing.Font("宋体", 10F);
+            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;
+            this.FirstPage_WID.Text = "打印Wafer id";
+            this.FirstPage_WID.UseVisualStyleBackColor = true;
+            // 
+            // RowNum
+            // 
+            this.RowNum.Location = new System.Drawing.Point(961, 431);
+            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, 675);
+            this.Controls.Add(this.RowNum);
+            this.Controls.Add(this.FirstPage_WID);
+            this.Controls.Add(this.label7);
+            this.Controls.Add(this.FixRow);
+            this.Controls.Add(this.BoxCode);
+            this.Controls.Add(this.BatchCode);
+            this.Controls.Add(this.label6);
+            this.Controls.Add(this.label5);
+            this.Controls.Add(this.percent);
+            this.Controls.Add(this.TS);
+            this.Controls.Add(this.BVCEO);
+            this.Controls.Add(this.label4);
+            this.Controls.Add(this.label3);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.CH_WATERID);
+            this.Controls.Add(this.ch_code);
+            this.Controls.Add(this.CH_REMARK);
+            this.Controls.Add(this.CH_PBCODE);
+            this.Controls.Add(this.CH_SPLITBATCH);
+            this.Controls.Add(this.CH_BLUEFILM);
+            this.Controls.Add(this.Export);
+            this.Name = "ExportExcel";
+            this.Text = "导出数据";
+            this.Load += new System.EventHandler(this.ExportExcel_Load);
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.Button Export;
+        private System.Windows.Forms.CheckBox CH_BLUEFILM;
+        private System.Windows.Forms.CheckBox CH_SPLITBATCH;
+        private System.Windows.Forms.CheckBox CH_PBCODE;
+        private System.Windows.Forms.CheckBox CH_REMARK;
+        private System.Windows.Forms.CheckBox ch_code;
+        private System.Windows.Forms.CheckBox CH_WATERID;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.Label label4;
+        private System.Windows.Forms.CheckBox BVCEO;
+        private System.Windows.Forms.CheckBox TS;
+        private System.Windows.Forms.CheckBox percent;
+        private System.Windows.Forms.Label label5;
+        private System.Windows.Forms.Label label6;
+        private System.Windows.Forms.RadioButton BatchCode;
+        private System.Windows.Forms.RadioButton BoxCode;
+        private System.Windows.Forms.RadioButton FixRow;
+        private System.Windows.Forms.Label label7;
+        private System.Windows.Forms.CheckBox FirstPage_WID;
+        private CustomControl.NumOnlyTextBox RowNum;
+        private System.Windows.Forms.FolderBrowserDialog ExportFileDialog;
+    }
+}

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

@@ -0,0 +1,116 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using UAS_LabelMachine.Entity;
+
+namespace UAS_LabelMachine
+{
+    public partial class ExportExcel : Form
+    {
+        ExcelHandler eh = new ExcelHandler();
+
+        DataHelper dh = SystemInf.dh;
+        string inoutno;
+
+        public ExportExcel(string pi_inoutno)
+        {
+            InitializeComponent();
+            inoutno = pi_inoutno;
+        }
+
+        private void Export_Click(object sender, EventArgs e)
+        {
+            ExportFileDialog.Description = "选择导出的路径";
+            DialogResult result = ExportFileDialog.ShowDialog();
+            if (result == DialogResult.OK)
+            {
+                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);
+            }
+        }
+
+        private void ExportExcel_Load(object sender, EventArgs e)
+        {
+
+        }
+    }
+}

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

@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <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>

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

@@ -824,5 +824,15 @@ namespace UAS_LabelMachine
             }
             return sql.Substring(0, sql.Length - 1);
         }
+
+        public static string GetArrStr(ArrayList<string> arr, string Split)
+        {
+            string Str = "";
+            for (int i = 0; i < arr.ToArray().Length; i++)
+            {
+                Str += arr.ToArray()[i] + Split;
+            }
+            return Str;
+        }
     }
 }

+ 24 - 12
UAS-出货标签管理(贸易版)/PublicMethod/DataHelper.cs

@@ -11,7 +11,19 @@ namespace UAS_LabelMachine
     public class DataHelper
     {
 
-        ////海创外网地址
+        //海创外网地址
+        private readonly string ConnectionStrings = "Data Source=172.16.0.22/orcl;User ID=SZSI_TEST;PassWord=select!#%*(";
+        //海创ERP地址
+        public static readonly string ERPAddesss = "http://172.16.0.20:8099/ERP/";
+        //海创FTP
+        public static readonly string FTPAddress = "ftp://172.16.0.20|vsftpd|shenaftp";
+
+        public static readonly string InnerFTPAddress = "ftp://172.16.0.20|vsftpd|shenaftp";
+        //Oracle端口
+        public static readonly string OraclePort = "1521";
+        //需要显示的账套
+        public static readonly string Masters = "HC_TEST";   //海创外网地址
+
         //private readonly string ConnectionStrings = "Data Source=cmityj.gicp.net/orcl;User ID=HC_TEST;PassWord=select!#%*(";
         ////海创ERP地址
         //public static readonly string ERPAddesss = "http://cmityj.gicp.net:8099/ERP/";
@@ -24,17 +36,17 @@ namespace UAS_LabelMachine
         ////需要显示的账套
         //public static readonly string Masters = "HC_TEST";
 
-        //凯而高地址
-        private readonly string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=KRG_TEST;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=112.25.154.186)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
-        //凯而高ERP地址
-        public static readonly string ERPAddesss = "http://112.25.154.186:8099/ERP/";
-        //凯而高FTP
-        public static readonly string FTPAddress = "ftp://112.25.154.186:21|KEGFTP|Admin1@#";
-        public static readonly string InnerFTPAddress = "ftp://112.25.154.186:21|HCFTP|Admin1@#";
-        //Oracle端口
-        public static readonly string OraclePort = "1521";
-        //需要显示的账套
-        public static readonly string Masters = "GOLDEN";
+        ////凯而高地址
+        //private readonly string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=KRG_TEST;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=112.25.154.186)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        ////凯而高ERP地址
+        //public static readonly string ERPAddesss = "http://112.25.154.186:8099/ERP/";
+        ////凯而高FTP
+        //public static readonly string FTPAddress = "ftp://112.25.154.186:21|KEGFTP|Admin1@#";
+        //public static readonly string InnerFTPAddress = "ftp://112.25.154.186:21|HCFTP|Admin1@#";
+        ////Oracle端口
+        //public static readonly string OraclePort = "1521";
+        ////需要显示的账套
+        //public static readonly string Masters = "GOLDEN";
 
         ////凯而高
         //private readonly string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=KRG_TEST;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.12)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";

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

@@ -17,11 +17,11 @@ namespace UAS_LabelMachine
         /// <summary>
         /// 导出Excel,返回文件在客户端的路径
         /// </summary>
-        public string ExportExcel(DataTable dt, string FolderPath, string FileName)
+        public string ExportExcel(DataTable firstsdt, DataTable dt, string FolderPath, string FileName, string Type, int PageSize, bool PrintWID)
         {
             //创建一个内存流,用来接收转换成Excel的内容
             MemoryStream ms;
-            ms = DataTableToExcel(dt);
+            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);
@@ -34,6 +34,8 @@ namespace UAS_LabelMachine
             return filePath;
         }
 
+
+
         /// <summary>
         /// 导入Excel
         /// </summary>
@@ -164,6 +166,7 @@ namespace UAS_LabelMachine
             }
         }
 
+
         /// <summary>
         /// 将DataTable形式的数据转成Excel格式的,然后用字节流的形式写入文件
         /// </summary>
@@ -188,12 +191,12 @@ namespace UAS_LabelMachine
                 if (DataTable.Rows[0][i].ToString().Length < DataTable.Columns[i].ColumnName.Length)
                 {
                     dataLength = DataTable.Columns[i].ColumnName.Length;
-                    dataLength = dataLength * 600;
+                    dataLength = dataLength * 300;
                 }
                 else
                 {
                     dataLength = DataTable.Rows[0][i].ToString().Length;
-                    dataLength = dataLength * 500;
+                    dataLength = dataLength * 300;
                 }
                 sheet.SetColumnWidth(i, dataLength);
             }
@@ -239,5 +242,869 @@ namespace UAS_LabelMachine
             book.Write(ms);
             return ms;
         }
+
+
+        /// <summary>
+        /// 将DataTable形式的数据转成Excel格式的,然后用字节流的形式写入文件
+        /// </summary>
+        /// <param name="DataTable"></param>
+        /// <returns></returns>
+        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("分页");
+            //获取行数量和列数量
+            int rowNum = DataTable.Rows.Count;
+            int columnNum = DataTable.Columns.Count;
+
+            ICellStyle style = book.CreateCellStyle();
+            style.VerticalAlignment = VerticalAlignment.Center;
+            style.Alignment = HorizontalAlignment.Left;
+
+            ICellStyle styleborder = book.CreateCellStyle();
+            styleborder.BorderBottom = BorderStyle.Thick;
+            styleborder.BorderTop = BorderStyle.Thick;
+            styleborder.BorderLeft = BorderStyle.Thick;
+            styleborder.BorderRight = BorderStyle.Thick;
+            styleborder.VerticalAlignment = VerticalAlignment.Center;
+            styleborder.Alignment = HorizontalAlignment.Left;
+            //设置列的宽度,根据首行的列的内容的长度来设置
+            for (int i = 0; i < columnNum; i++)
+            {
+                if (DataTable.Columns[i].ColumnName.Contains("客户"))
+                {
+                    DataTable.Columns[i].ColumnName = "客户";
+                }
+                if (DataTable.Columns[i].ColumnName.Contains("出货单号"))
+                {
+                    DataTable.Columns[i].ColumnName = "出货单号";
+                }
+                if (DataTable.Columns[i].ColumnName.Contains("型号"))
+                {
+                    DataTable.Columns[i].ColumnName = "型号";
+                }
+                if (DataTable.Columns[i].ColumnName.Contains("销售日期"))
+                {
+                    DataTable.Columns[i].ColumnName = "销售日期";
+                }
+                if (DataTable.Columns[i].ColumnName.ToLower().Contains("rownum"))
+                {
+                    DataTable.Columns[i].ColumnName = "序号";
+                }
+                if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_code"))
+                {
+                    DataTable.Columns[i].ColumnName = "芯片号";
+                }
+                if (DataTable.Columns[i].ColumnName.ToLower().Contains("pib_lotno"))
+                {
+                    DataTable.Columns[i].ColumnName = "LotNo";
+                }
+                if (DataTable.Columns[i].ColumnName.ToLower().Contains("io_qty"))
+                {
+                    DataTable.Columns[i].ColumnName = "数量";
+                }
+            }
+            //首先画好第一行带颜色的,单独写出来,避免写在循环里面
+            IRow row = sheet.CreateRow(0);
+            //冻结第一行
+            sheet.CreateFreezePane(0, 1, 0, 1);
+            //style.FillPattern = FillPattern.BigSpots;
+            //style.FillBackgroundColor = HSSFColor.LightGreen.Index;
+            //设置边框
+            //style.BorderBottom = BorderStyle.Thick;
+            //style.BorderLeft = BorderStyle.Thick;
+            //style.BorderRight = BorderStyle.Thick;
+            //style.BorderTop = BorderStyle.Thick;
+            row.HeightInPoints = 20;
+            //固定第一行
+            //row.RowStyle.IsLocked=true;
+            //给第一行的标签赋值样式和值
+            row.CreateCell(0);
+            row.Cells[0].SetCellValue("                     深爱半导体有限公司芯片出货清单");
+            row.GetCell(0).CellStyle = style;
+            //开始绘制的Index
+            int PaintIndex = 1;
+            int sumCount = 0;
+            int totalCount = 0;
+            switch (Type)
+            {
+                case "FixRow":
+                    //清理系统取出来的数据
+                    BaseUtil.CleanDataTableData(FirstDT);
+                    //首页参数拼接
+                    string First_OrderCode = "";
+                    string First_Prspec = "";
+                    string First_Batch = "";
+                    ArrayList<string> First_WID = new ArrayList<string>();
+                    for (int i = 0; i < rowNum; i++)
+                    {
+                        IRow row1 = sheet.CreateRow(PaintIndex);
+                        PaintIndex = PaintIndex + 1;
+                        row1.HeightInPoints = 20;
+                        //不包含的订单号
+                        if (DataTable.Columns.Contains("pd_ordercode") && !First_OrderCode.Contains(DataTable.Rows[i]["pd_ordercode"].ToString()))
+                        {
+                            First_OrderCode += DataTable.Rows[i]["pd_ordercode"].ToString() + " ";
+                        }
+                        //不包含的物料型号
+                        if (DataTable.Columns.Contains("pr_spec") && !First_Prspec.Contains(DataTable.Rows[i]["pr_spec"].ToString()))
+                        {
+                            First_Prspec += DataTable.Rows[i]["pr_spec"].ToString() + " ";
+                        }
+                        //不包含扩撒批号
+                        if (DataTable.Columns.Contains("扩散批号") && !First_Batch.Contains(DataTable.Rows[i]["扩散批号"].ToString()))
+                        {
+                            First_Batch += DataTable.Rows[i]["扩散批号"].ToString() + " ";
+                        }
+                        //不包含Wafer_id
+                        if (DataTable.Columns.Contains("Wafer_ID") &&!First_WID.Contains(DataTable.Rows[i]["Wafer_ID"].ToString()))
+                        {
+                            First_WID.Add(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"] = BaseUtil.GetArrStr(First_WID," ");
+                            dr["num"] = PageSize;
+                            dr["io_qty"] = sumCount;
+                            FirstDT.Rows.Add(dr);
+                            First_OrderCode = "";
+                            First_Prspec = "";
+                            First_Batch = "";
+                            First_WID.Clear();
+                            for (int j = 0; j < columnNum - 4; j++)
+                            {
+                                if (j == 0)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("小计");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(sumCount);
+                                }
+                                else
+                                {
+                                    row1.CreateCell(j);
+                                }
+                                row1.Cells[j].CellStyle = styleborder;
+                            }
+                            sumCount = 0;
+                            row1 = sheet.CreateRow(PaintIndex);
+                            PaintIndex = PaintIndex + 1;
+                        }
+                        //每次到了页数开始分页
+                        if (i % PageSize == 0 || i == rowNum - 1)
+                        {
+                            //第一行添加客户信息   rownum只有一行的情
+                            if (i != rowNum - 1 || rowNum == 1)
+                            {
+                                for (int j = 0; j < columnNum - 3; j++)
+                                {
+                                    if (j == 0)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["客户"].ToString());
+                                    }
+                                    else if (j == columnNum - 4)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["出货单号"].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.Rows[i]["型号"].ToString());
+                                    }
+                                    else if (j == columnNum - 4)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["销售日期"].ToString());
+                                    }
+                                    else
+                                    {
+                                        row1.CreateCell(j);
+                                    }
+                                    row1.GetCell(j).CellStyle = style;
+                                }
+                                //添加列名
+                                row1 = sheet.CreateRow(PaintIndex);
+                                PaintIndex = PaintIndex + 1;
+                                for (int j = 4; j < columnNum; j++)
+                                {
+                                    row1.CreateCell(j - 4);
+                                    row1.Cells[j - 4].CellStyle = styleborder;
+                                    if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1")
+                                    {
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname1"].ToString());
+                                    }
+                                    else if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2")
+                                    {
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname2"].ToString());
+                                    }
+                                    else
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].ColumnName);
+                                    //如果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);
+                                    }
+                                }
+                                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);
+                            row1.Cells[j - 4].SetCellValue(Data);
+                            row1.GetCell(j - 4).CellStyle = styleborder;
+                            if (DataTable.Columns[j].ColumnName == "数量")
+                            {
+                                sumCount += int.Parse(DataTable.Rows[i][j].ToString());
+                                totalCount += int.Parse(DataTable.Rows[i][j].ToString());
+                            }
+                            if (DataTable.Columns[j].ColumnName == "序号")
+                            {
+                                row1.Cells[j - 4].SetCellValue(i + 1);
+                            }
+                        }
+                        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"] = BaseUtil.GetArrStr(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++)
+                            {
+                                if (j == 0)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("小计");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(sumCount);
+                                }
+                                else
+                                {
+                                    row1.CreateCell(j);
+                                }
+                                row1.Cells[j].CellStyle = styleborder;
+                            }
+
+                            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("备注");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(totalCount);
+                                }
+                                //原本是j == columnNum - 5因为还有spec和order两列隐藏列,所以需要在往后移动
+                                else if (j == columnNum - 7)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(rowNum);
+                                }
+                                else if (j == columnNum - 4)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("片");
+                                }
+                                else
+                                {
+                                    row1.CreateCell(j);
+                                }
+                                row1.Cells[j].CellStyle = style;
+                            }
+                        }
+                    }
+                    for (int i = 0; i < sheet.LastRowNum; i++)
+                    {
+                        if (i != 0)
+                        {
+                            sheet.AutoSizeColumn(i);
+                            sheet.SetColumnWidth(i, sheet.GetColumnWidth(i) + 1000);
+                        }
+                    }
+                    break;
+                case "BatchCode":
+                    string LastBatchCode = "";
+                    for (int i = 0; i < rowNum; i++)
+                    {
+                        IRow row1 = sheet.CreateRow(PaintIndex);
+                        PaintIndex = PaintIndex + 1;
+                        row1.HeightInPoints = 20;
+                        //如果批号不相等的时候
+                        if (LastBatchCode != "" && LastBatchCode != DataTable.Rows[i]["扩散批号"].ToString())
+                        {
+                            for (int j = 0; j < columnNum - 4; j++)
+                            {
+                                if (j == 0)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("小计");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(sumCount);
+                                }
+                                else
+                                {
+                                    row1.CreateCell(j);
+                                }
+                                row1.Cells[j].CellStyle = styleborder;
+                            }
+                            sumCount = 0;
+                            row1 = sheet.CreateRow(PaintIndex);
+                            PaintIndex = PaintIndex + 1;
+                        }
+                        //每次到了页数开始分页
+                        if (LastBatchCode == "" || (LastBatchCode != "" && LastBatchCode != DataTable.Rows[i]["扩散批号"].ToString()) || i == rowNum - 1)
+                        {
+                            LastBatchCode = DataTable.Rows[i]["扩散批号"].ToString();
+                            //第一行添加客户信息
+                            if (i != rowNum - 1)
+                            {
+                                for (int j = 0; j < columnNum - 3; j++)
+                                {
+                                    if (j == 0)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["客户"].ToString());
+                                    }
+                                    else if (j == columnNum - 4)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["出货单号"].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.Rows[i]["型号"].ToString());
+                                    }
+                                    else if (j == columnNum - 4)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["销售日期"].ToString());
+                                    }
+                                    else
+                                    {
+                                        row1.CreateCell(j);
+                                    }
+                                    row1.GetCell(j).CellStyle = style;
+                                }
+                                //添加列名
+                                row1 = sheet.CreateRow(PaintIndex);
+                                PaintIndex = PaintIndex + 1;
+                                for (int j = 4; j < columnNum; j++)
+                                {
+                                    row1.CreateCell(j - 4);
+                                    row1.Cells[j - 4].CellStyle = styleborder;
+                                    if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1")
+                                    {
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname1"].ToString());
+                                    }
+                                    else if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2")
+                                    {
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname2"].ToString());
+                                    }
+                                    else
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].ColumnName);
+                                    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);
+                                    }
+                                }
+                                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);
+                            row1.Cells[j - 4].SetCellValue(Data);
+                            row1.GetCell(j - 4).CellStyle = styleborder;
+                            if (DataTable.Columns[j].ColumnName == "数量")
+                            {
+                                sumCount += int.Parse(DataTable.Rows[i][j].ToString());
+                                totalCount += int.Parse(DataTable.Rows[i][j].ToString());
+                            }
+                            if (DataTable.Columns[j].ColumnName == "序号")
+                            {
+                                row1.Cells[j - 4].SetCellValue(i + 1);
+                            }
+                        }
+                        if (i == rowNum - 1)
+                        {
+                            row1 = sheet.CreateRow(PaintIndex);
+                            PaintIndex = PaintIndex + 1;
+                            for (int j = 0; j < columnNum - 4; j++)
+                            {
+                                if (j == 0)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("小计");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(sumCount);
+                                }
+                                else
+                                {
+                                    row1.CreateCell(j);
+                                }
+                                row1.Cells[j].CellStyle = styleborder;
+                            }
+
+                            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("备注");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(totalCount);
+                                }
+                                else if (j == columnNum - 7)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(rowNum);
+                                }
+                                else if (j == columnNum - 4)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("片");
+                                }
+                                else
+                                {
+                                    row1.CreateCell(j);
+                                }
+                                row1.Cells[j].CellStyle = style;
+                            }
+                        }
+                    }
+                    for (int i = 0; i < sheet.LastRowNum; i++)
+                    {
+                        if (i != 0)
+                        {
+                            sheet.AutoSizeColumn(i);
+                            sheet.SetColumnWidth(i, sheet.GetColumnWidth(i) + 1000);
+                        }
+                    }
+                    break;
+                case "BoxCode":
+                    string LastBoxCode = "";
+                    for (int i = 0; i < rowNum; i++)
+                    {
+                        IRow row1 = sheet.CreateRow(PaintIndex);
+                        PaintIndex = PaintIndex + 1;
+                        row1.HeightInPoints = 20;
+                        //如果批号不相等的时候
+                        if (LastBoxCode != "" && LastBoxCode != DataTable.Rows[i]["盒号"].ToString())
+                        {
+
+                            for (int j = 0; j < columnNum - 4; j++)
+                            {
+                                if (j == 0)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("小计");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(sumCount);
+                                }
+                                else
+                                {
+                                    row1.CreateCell(j);
+                                }
+                                row1.Cells[j].CellStyle = styleborder;
+                            }
+                            sumCount = 0;
+                            row1 = sheet.CreateRow(PaintIndex);
+                            PaintIndex = PaintIndex + 1;
+                        }
+                        //每次到了页数开始分页
+                        if (LastBoxCode == "" || (LastBoxCode != "" && LastBoxCode != DataTable.Rows[i]["盒号"].ToString()) || i == rowNum - 1)
+                        {
+                            LastBoxCode = DataTable.Rows[i]["盒号"].ToString();
+                            //第一行添加客户信息
+                            if (i != rowNum - 1)
+                            {
+                                for (int j = 0; j < columnNum - 3; j++)
+                                {
+                                    if (j == 0)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["客户"].ToString());
+                                    }
+                                    else if (j == columnNum - 4)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["出货单号"].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.Rows[i]["型号"].ToString());
+                                    }
+                                    else if (j == columnNum - 4)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["销售日期"].ToString());
+                                    }
+                                    else
+                                    {
+                                        row1.CreateCell(j);
+                                    }
+                                    row1.GetCell(j).CellStyle = style;
+                                }
+                                //添加列名
+                                row1 = sheet.CreateRow(PaintIndex);
+                                PaintIndex = PaintIndex + 1;
+                                for (int j = 4; j < columnNum; j++)
+                                {
+                                    row1.CreateCell(j - 4);
+                                    row1.Cells[j - 4].CellStyle = styleborder;
+                                    if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1")
+                                    {
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname1"].ToString());
+                                    }
+                                    else if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2")
+                                    {
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Rows[i]["chw_itemname2"].ToString());
+                                    }
+                                    else
+                                        row1.Cells[j - 4].SetCellValue(DataTable.Columns[j].ColumnName);
+                                    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);
+                                    }
+                                }
+                                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);
+                            row1.Cells[j - 4].SetCellValue(Data);
+                            row1.GetCell(j - 4).CellStyle = styleborder;
+                            if (DataTable.Columns[j].ColumnName == "数量")
+                            {
+                                sumCount += int.Parse(DataTable.Rows[i][j].ToString());
+                                totalCount += int.Parse(DataTable.Rows[i][j].ToString());
+                            }
+                            if (DataTable.Columns[j].ColumnName == "序号")
+                            {
+                                row1.Cells[j - 4].SetCellValue(i + 1);
+                            }
+                        }
+                        if (i == rowNum - 1)
+                        {
+                            row1 = sheet.CreateRow(PaintIndex);
+                            PaintIndex = PaintIndex + 1;
+                            for (int j = 0; j < columnNum - 4; j++)
+                            {
+                                if (j == 0)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("小计");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(sumCount);
+                                }
+                                else
+                                {
+                                    row1.CreateCell(j);
+                                }
+                                row1.Cells[j].CellStyle = styleborder;
+                            }
+
+                            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("备注");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(totalCount);
+                                }
+                                else if (j == columnNum - 7)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue(rowNum);
+                                }
+                                else if (j == columnNum - 4)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("片");
+                                }
+                                else
+                                {
+                                    row1.CreateCell(j);
+                                }
+                                row1.Cells[j].CellStyle = style;
+                            }
+                        }
+                    }
+                    for (int i = 0; i < sheet.LastRowNum; i++)
+                    {
+                        if (i != 0)
+                        {
+                            sheet.AutoSizeColumn(i);
+                            sheet.SetColumnWidth(i, sheet.GetColumnWidth(i) + 1000);
+                        }
+                    }
+                    break;
+                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)
         {

+ 9 - 0
UAS-出货标签管理(贸易版)/UAS-出货标签管理(贸易版).csproj

@@ -241,6 +241,12 @@
     </Compile>
     <Compile Include="Entity\SystemInf.cs" />
     <Compile Include="Entity\User.cs" />
+    <Compile Include="ExportExcel.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="ExportExcel.Designer.cs">
+      <DependentUpon>ExportExcel.cs</DependentUpon>
+    </Compile>
     <Compile Include="Login.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -361,6 +367,9 @@
     <EmbeddedResource Include="DbFind.resx">
       <DependentUpon>DbFind.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="ExportExcel.resx">
+      <DependentUpon>ExportExcel.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="Login.resx">
       <DependentUpon>Login.cs</DependentUpon>
     </EmbeddedResource>

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

@@ -2325,48 +2325,51 @@ namespace UAS_LabelMachine
                     form1.ShowDialog();
                     break;
                 case "导出数据":
-                    ExportFileDialog.Description = "选择导出的路径";
-                    result = ExportFileDialog.ShowDialog();
-                    if (result == DialogResult.OK)
-                    {
-                        ExcelHandler eh = new ExcelHandler();
-                        dt = ((DataTable)LabelInf.DataSource).Copy();
-                        for (int i = dt.Columns.Count - 1; i >= 0; i--)
-                        {
-                            for (int j = 0; j < LabelInf.Columns.Count; j++)
-                            {
-                                //去除ID列
-                                if (dt.Columns[i].ColumnName.ToLower().Contains("id") || dt.Columns[i].ColumnName.ToLower() == "pib_barcode" || dt.Columns[i].ColumnName.ToLower() == "pib_pdno" || dt.Columns[i].ColumnName.ToLower() == "pib_ifpick" || dt.Columns[i].ColumnName.ToLower() == "pib_ifprint" || dt.Columns[i].ColumnName.ToLower() == "pib_datecode1" || dt.Columns[i].ColumnName.ToLower() == "pr_vendprodcode")
-                                {
-                                    dt.Columns.RemoveAt(i);
-                                    break;
-                                }
-                                switch (dt.Columns[i].ColumnName.ToLower())
-                                {
-                                    case "pib_lotno":
-                                        dt.Columns[i].ColumnName = "批次号";
-                                        break;
-                                    case "pib_datecode":
-                                        dt.Columns[i].ColumnName = "生产日期";
-                                        break;
-                                    case "pib_custbarcode":
-                                        dt.Columns[i].ColumnName = "最小产品包装条码";
-                                        break;
-                                    default:
-                                        break;
-                                }
-                                if (dt.Columns[i].ColumnName.ToLower() == LabelInf.Columns[j].DataPropertyName.ToLower())
-                                {
-                                    dt.Columns[i].ColumnName = LabelInf.Columns[j].HeaderText;
-                                    break;
-                                }
-                            }
-                        }
-                        eh.ExportExcel(dt, ExportFileDialog.SelectedPath, pi_date.Text + "-" + pi_inoutno.Text);
-                        string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
-                        if (close.ToString() == "Yes")
-                            System.Diagnostics.Process.Start(ExportFileDialog.SelectedPath + "\\" + pi_date.Text + "-" + pi_inoutno.Text + ".xls");
-                    }
+                    ExportExcel ex = new ExportExcel(pi_inoutno.Text);
+                    ex.StartPosition = FormStartPosition.CenterScreen;
+                    ex.ShowDialog();
+                    //ExportFileDialog.Description = "选择导出的路径";
+                    //result = ExportFileDialog.ShowDialog();
+                    //if (result == DialogResult.OK)
+                    //{
+                    //    ExcelHandler eh = new ExcelHandler();
+                    //    dt = ((DataTable)LabelInf.DataSource).Copy();
+                    //    for (int i = dt.Columns.Count - 1; i >= 0; i--)
+                    //    {
+                    //        for (int j = 0; j < LabelInf.Columns.Count; j++)
+                    //        {
+                    //            //去除ID列
+                    //            if (dt.Columns[i].ColumnName.ToLower().Contains("id") || dt.Columns[i].ColumnName.ToLower() == "pib_barcode" || dt.Columns[i].ColumnName.ToLower() == "pib_pdno" || dt.Columns[i].ColumnName.ToLower() == "pib_ifpick" || dt.Columns[i].ColumnName.ToLower() == "pib_ifprint" || dt.Columns[i].ColumnName.ToLower() == "pib_datecode1" || dt.Columns[i].ColumnName.ToLower() == "pr_vendprodcode")
+                    //            {
+                    //                dt.Columns.RemoveAt(i);
+                    //                break;
+                    //            }
+                    //            switch (dt.Columns[i].ColumnName.ToLower())
+                    //            {
+                    //                case "pib_lotno":
+                    //                    dt.Columns[i].ColumnName = "批次号";
+                    //                    break;
+                    //                case "pib_datecode":
+                    //                    dt.Columns[i].ColumnName = "生产日期";
+                    //                    break;
+                    //                case "pib_custbarcode":
+                    //                    dt.Columns[i].ColumnName = "最小产品包装条码";
+                    //                    break;
+                    //                default:
+                    //                    break;
+                    //            }
+                    //            if (dt.Columns[i].ColumnName.ToLower() == LabelInf.Columns[j].DataPropertyName.ToLower())
+                    //            {
+                    //                dt.Columns[i].ColumnName = LabelInf.Columns[j].HeaderText;
+                    //                break;
+                    //            }
+                    //        }
+                    //    }
+                    //    eh.ExportExcel(dt, ExportFileDialog.SelectedPath, pi_date.Text + "-" + pi_inoutno.Text);
+                    //    string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
+                    //    if (close.ToString() == "Yes")
+                    //        System.Diagnostics.Process.Start(ExportFileDialog.SelectedPath + "\\" + pi_date.Text + "-" + pi_inoutno.Text + ".xls");
+                    //}
                     break;
                 case "权限设置":
                     PowerSetting pw = new PowerSetting();
@@ -2540,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