Browse Source

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

Hcsy 6 years ago
parent
commit
a337bad650
27 changed files with 1539 additions and 224 deletions
  1. 12 2
      UAS-MES/FunctionCode/Special/Special_CancelCollection.cs
  2. 1 12
      UAS-出货标签管理(标签复核)/Login.cs
  3. 42 2
      UAS-出货标签管理(标签复核)/PublicMethod/DataHelper.cs
  4. 34 18
      UAS-出货标签管理(标签复核)/UAS_出货标签管理.cs
  5. 176 0
      UAS-出货标签管理(贸易版)/ExportColumns.Designer.cs
  6. 247 0
      UAS-出货标签管理(贸易版)/ExportColumns.cs
  7. 120 0
      UAS-出货标签管理(贸易版)/ExportColumns.resx
  8. 22 26
      UAS-出货标签管理(贸易版)/ExportExcel.Designer.cs
  9. 11 6
      UAS-出货标签管理(贸易版)/ExportExcel.cs
  10. 0 11
      UAS-出货标签管理(贸易版)/Login.cs
  11. 62 2
      UAS-出货标签管理(贸易版)/PublicMethod/BaseUtil.cs
  12. 25 52
      UAS-出货标签管理(贸易版)/PublicMethod/DataHelper.cs
  13. 30 17
      UAS-出货标签管理(贸易版)/PublicMethod/ExcelHandler.cs
  14. 36 2
      UAS-出货标签管理(贸易版)/PublicMethod/LogicHandler.cs
  15. 333 0
      UAS-出货标签管理(贸易版)/SQL/SQL.txt
  16. 10 0
      UAS-出货标签管理(贸易版)/UAS-出货标签管理(贸易版).csproj
  17. 1 19
      UAS-出货标签管理(贸易版)/UAS_出货标签管理.Designer.cs
  18. 16 28
      UAS-出货标签管理(贸易版)/UAS_出货标签管理.cs
  19. 15 3
      UAS_PRINT/Form2.Designer.cs
  20. 9 1
      UAS_PRINT/Form2.cs
  21. 14 0
      UAS_PRINT/PrintHandler.cs
  22. 61 17
      UAS_PRINT/Properties/Settings.Designer.cs
  23. 17 6
      UAS_PRINT/Properties/Settings.settings
  24. 28 0
      UAS_PRINT/Settings.cs
  25. 3 0
      UAS_PRINT/UAS_PRINT.csproj
  26. 24 0
      UAS_PRINT/app.config
  27. 190 0
      UAS_PRINT/ftpOperater.cs

+ 12 - 2
UAS-MES/FunctionCode/Special/Special_CancelCollection.cs

@@ -90,8 +90,18 @@ namespace UAS_MES.Special
                     sqls.Add("delete from AGINGRECORD where ar_sncode='" + sn_code.Text + "' and ar_macode='" + ms_makecode + "'");
                     //初始化导入数据状态
                     sqls.Add("update makesnlist set msl_status=0 where msl_sncode='" + sn_code.Text + "' and msl_makecode='" + ms_makecode + "' and msl_type='before'");
-                    ////初始化号段状态
-                    sqls.Add("update MAKESNRULEDETAIL set msd_status=0 where msd_sncode='" + sn_code.Text + "' and msd_makecode='" + ms_makecode + "'  and msd_type='before'");
+                    //判断此时SN是否仍处于此工单SN导入范围
+                    if (dh.CheckExist("MAKESNRULE", "MSR_MAKECODE = '" + ms_makecode + "' and '" + sn_code.Text + "' BETWEEN MSR_STARTNO AND MSR_ENDNO AND MSR_TYPE = 'before'"))
+                    {
+                        ////初始化号段状态
+                        sqls.Add("update MAKESNRULEDETAIL set msd_status=0 where msd_sncode='" + sn_code.Text + "' and msd_makecode='" + ms_makecode + "'  and msd_type='before'");
+                    }
+                    //不符合即删除
+                    else
+                    {
+                        ////初始化号段状态
+                        sqls.Add("delete MAKESNRULEDETAIL where msd_sncode='" + sn_code.Text + "' and msd_makecode='" + ms_makecode + "'  and msd_type='before'");
+                    }                   
                     //解除前一工单板的使用
                     sqls.Add("update makeserial set ms_nextmacode='' where ms_sncode='" + sn_code.Text + "' and ms_nextmacode='" + ms_makecode + "'");
                     //清除操作日志

+ 1 - 12
UAS-出货标签管理(标签复核)/Login.cs

@@ -34,20 +34,9 @@ namespace UAS_LabelMachine
             SystemInf.dh = dh;
             //获取账套信息
             dt = (DataTable)dh.ExecuteSql("select ma_function,ms_pwd,ma_user from master ", "select");
-            DataTable MasterDB = dt.Clone();
-            for (int i = 0; i < dt.Rows.Count; i++)
-            {
-                if (DataHelper.Masters.Contains(dt.Rows[i]["ma_user"].ToString()))
-                {
-                    DataRow dr = MasterDB.NewRow();
-                    dr["ma_user"] = dt.Rows[i]["ma_user"];
-                    dr["ma_function"] = dt.Rows[i]["ma_function"];
-                    MasterDB.Rows.Add(dr);
-                }
-            }
             MasterCombox.DisplayMember = "ma_function";
             MasterCombox.ValueMember = "ma_user";
-            MasterCombox.DataSource = MasterDB;
+            MasterCombox.DataSource = dt;
             //读取上次登陆时的用户名和选择的账套
             UserName.Text = Properties.Settings.Default.LastLoginUser;
             MasterCombox.Text = Properties.Settings.Default.LastLoginMaster;

+ 42 - 2
UAS-出货标签管理(标签复核)/PublicMethod/DataHelper.cs

@@ -12,8 +12,8 @@ namespace UAS_LabelMachine
     {
 
         //富为外网地址
-        private readonly string ConnectionStrings = "Data Source=jinhaode.f3322.org/orcl;User ID=HD;PassWord=select!#%*(";
-        private readonly string InnerConnectionStrings = "Data Source=jinhaode.f3322.org/orcl;User ID=HD;PassWord=select!#%*(";
+        private readonly string ConnectionStrings = "Data Source=183.62.139.106/orcl;User ID=HD;PassWord=select!#%*(";
+        private readonly string InnerConnectionStrings = "Data Source=j183.62.139.106/orcl;User ID=HD;PassWord=select!#%*(";
         //富为ERP地址
         public static readonly string ERPAddesss = "http://jinhaode.f3322.org:8099/ERP/";
         //富为FTP
@@ -1104,6 +1104,46 @@ namespace UAS_LabelMachine
             command.Dispose();
         }
 
+        /// <summary>
+        /// 调用存储过程
+        /// </summary>
+        /// <param name="ProcedureName"></param>
+        /// <param name="param"></param>
+        public void CallProcedure(string ProcedureName, DataTable upload)
+        {
+            StringBuilder sql = new StringBuilder();
+            sql.Append("declare barcode BarCodeUpload_arr;begin barcode:=BarCodeUpload_arr(");
+            for (int i = 0; i < upload.Rows.Count; i++)
+            {
+                //特殊语句,传递回拼接的ID给到跟新本地数据
+                sql.Append("BarCodeUpload(");
+                for (int j = 0; j < upload.Columns.Count; j++)
+                {
+                    if(upload.Columns[j].ColumnName=="PIB_ID"|| upload.Columns[j].ColumnName == "PIB_DATECODE"|| upload.Columns[j].ColumnName == "PIB_LOTNO"|| upload.Columns[j].ColumnName == "PIB_IFPICK" || upload.Columns[j].ColumnName == "PIB_IFUPLOAD")
+                    sql.Append("'" + upload.Rows[i][j].ToString() + "',");
+                }
+                sql.Remove(sql.Length - 1, 1);
+                sql.Append("),");
+            }
+            sql.Remove(sql.Length - 1, 1);
+            sql.Append(");sp_uploadbarcode(barcode);END;");
+            command = new OracleCommand();
+            command.Connection = connection;
+            command.CommandText = sql.ToString();
+            try
+            {
+                command.ExecuteNonQuery();
+            }
+            catch (Exception)
+            {
+                connection = new OracleConnection(DBConnectionString);
+                connection.Open();
+                command.Connection = connection;
+                command.ExecuteNonQuery();
+            }
+            command.Dispose();
+        }
+
         /// <summary>
         /// 出现异常进行回滚的执行方法
         /// </summary>

+ 34 - 18
UAS-出货标签管理(标签复核)/UAS_出货标签管理.cs

@@ -38,6 +38,8 @@ namespace UAS_LabelMachine
         /// 当前扫描的所在行
         /// </summary>
         int CurrentRowIndex = 0;
+
+        bool Checking = false;
         /// <summary>
         /// 正则表达式用于项目匹配
         /// </summary>
@@ -63,6 +65,8 @@ namespace UAS_LabelMachine
         //使用二维数组进行排序
         ArrayList<ArrayList<string>> ScanData;
         ArrayList<string> GetData;
+        //用于记录上一个扫描的型号,和当前的不一致则进行弹窗提示
+        string LastSpec = "";
 
         public UAS_出货标签打印(string Master)
         {
@@ -178,10 +182,10 @@ namespace UAS_LabelMachine
         private void SaveGrid_Click(object sender, EventArgs e)
         {
             DataTable savedt = (LabelInf.DataSource as DataTable);
+            savedt.EndInit();
             if (savedt != null && savedt.GetChanges() != null)
             {
-                MidSource.EndEdit();
-                dh.SaveDataTable(savedt.GetChanges(), "ProdioBarCode", "pib_id");
+                dh.CallProcedure("sp_uploadbarcode", savedt.GetChanges());
                 CheckRecheckStatus();
                 MessageBox.Show("保存成功!");
             }
@@ -258,12 +262,6 @@ namespace UAS_LabelMachine
                     return;
                 }
                 CollectInputData();
-                DataTable savedt = (LabelInf.DataSource as DataTable);
-                if (savedt != null && savedt.GetChanges() != null)
-                {
-                    MidSource.EndEdit();
-                    dh.SaveDataTable(savedt.GetChanges(), "ProdioBarCode", "pib_id");
-                }
             }
         }
 
@@ -292,11 +290,13 @@ namespace UAS_LabelMachine
                 for (int j = 0; j < arr.Length; j++)
                 {
                     string orispeccode = LabelInf.Rows[i].Cells["pr_orispeccode"].Value.ToString();
-                    Console.WriteLine((MatchStr(arr[j].ToString(), "MPN")));
-                    Console.WriteLine(MatchStr(arr[j].ToString(), "MPN").Trim().Replace(" ", ""));
                     if ((MatchStr(arr[j].ToString(), "MPN").Contains(orispeccode) || MatchStr(arr[j].ToString(), "MPN").Trim().Replace(" ", "").Contains(orispeccode) || orispeccode == MatchStr(arr[j].ToString(), "MPN") || LabelInf.Rows[i].Cells["pd_custprodcode"].Value.ToString() == MatchStr(arr[j].ToString(), "CPN")) && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() != "True")
                     {
-                        CurrentRowIndex = i;
+                        if (!Checking)
+                        {
+                            CurrentRowIndex = i;
+                            Checking = true;
+                        }
                         if (CurrentRowIndex - 5 > 0)
                             LabelInf.FirstDisplayedScrollingRowIndex = CurrentRowIndex - 5;
                         else
@@ -305,6 +305,18 @@ namespace UAS_LabelMachine
                         if (Brand != "")
                             sg_brand.Text = Brand;
                         FindAutoMatch = true;
+                        if ((MatchStr(arr[j].ToString(), "MPN").Contains(orispeccode) || MatchStr(arr[j].ToString(), "MPN").Trim().Replace(" ", "").Contains(orispeccode) || orispeccode == MatchStr(arr[j].ToString(), "MPN")))
+                        {
+                            if (LastSpec == "")
+                            {
+                                LastSpec = orispeccode;
+                            }
+                            if (LastSpec != orispeccode)
+                            {
+                                LastSpec = orispeccode;
+                                MessageBox.Show("切换扫描型号" + orispeccode);
+                            }
+                        }
                         break;
                     }
                 }
@@ -419,6 +431,8 @@ namespace UAS_LabelMachine
                     dh.ExecuteSql("update prodiobarcode set pib_datecode='" + datecode + "',pib_lotno='" + lotno + "',pib_ifpick=-1 where pib_id='" + pib_id + "'", "update");
                     CheckRecheckStatus();
                     LabelInf.Invalidate();
+                    Checking = false;
+                    ProcessRemind();
                 }
                 //采集未通过的时候
                 else
@@ -481,6 +495,12 @@ namespace UAS_LabelMachine
             }
         }
 
+        private void ProcessRemind()
+        {
+            int Count = dh.getRowCount("prodiobarcode", "pib_piid=" + PI_ID + " and pib_ifpick<>0");
+            CollectedCount.Text = Count.ToString();
+        }
+
         List<string> ErrorType = new List<string>();
         /// <summary>
         /// 自定义函数 将匹配之后的值设置到Cell中,传递引用,每次赋值之后从List中移除已使用过的
@@ -519,7 +539,6 @@ namespace UAS_LabelMachine
                             cell = LabelInf.Rows[CurrentRowIndex].Cells["pr_orispeccode"];
                             Matchstr = MatchStr(data[j], "MPN");
                             //采集的供应商号不匹配的话
-                            Console.WriteLine(Matchstr.Trim().Replace(" ", ""));
                             if (cell.Value.ToString() == Matchstr || Matchstr.Trim().Replace(" ", "").Contains(cell.Value.ToString()) || Matchstr.Contains(cell.Value.ToString()))
                             {
                                 ErrorType.Add("OK_MPN");
@@ -713,7 +732,7 @@ namespace UAS_LabelMachine
             if (e.KeyCode == Keys.Enter)
             {
                 sql.Clear();
-                sql.Append("select pi_id,pi_cardcode,to_char(pi_date,'yyyymmdd')pi_date,nvl(cu_needrecheck,0)cu_needrecheck from prodinout left join customer on cu_code=pi_cardcode where pi_inoutno='" + pi_inoutno.Text + "' ");
+                sql.Append("select pi_id,pi_cardcode,to_char(pi_date,'yyyymmdd')pi_date,nvl(cu_needrecheck,0)cu_needrecheck from prodinout left join customer on cu_code=pi_cardcode where pi_invoicecode='" + pi_invoicecode.Text + "' ");
                 DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                 ErrorType.Clear();
                 if (dt.Rows.Count > 0)
@@ -775,16 +794,13 @@ namespace UAS_LabelMachine
         private void LoadGridData(object sender, EventArgs e)
         {
             sql.Clear();
-            sql.Append("select 0 choose,pd_custprodcode,pd_custprodspec,pr_orispeccode,pd_pocode,pib_madein,pib_custbarcode,pib_custoutboxcode,pib_id,pib_datecode1,pib_pdid,pib_piid,pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand, pr_vendprodcode,");
-            sql.Append("pib_lotno,pib_datecode,pib_qty,pr_spec,pr_detail,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifpick,0)pib_ifpick,nvl(pib_ifprint,0)pib_ifprint");
-            sql.Append(" from prodiobarcode left join prodiodetail on pib_piid=pd_piid and pd_pdno=pib_pdno and ");
-            sql.Append(" pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join sale on sa_code=pib_ordercode ");
-            sql.Append("where pib_piid='" + PI_ID + "' order by pd_pdno");
+            sql.Append("select * from prodiobarcode_view1 where pib_piid='" + PI_ID + "'");
             dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             MidSource.DataSource = dt;
             BaseUtil.FillDgvWithDataTable(LabelInf, (DataTable)MidSource.DataSource);
             //有数据的话默认取第一条的品牌去取采集策略
             TotalCount.Text = LabelInf.RowCount.ToString();
+            ProcessRemind();
             if (LabelInf.RowCount > 0)
             {
                 Brand = LabelInf.Rows[0].Cells["pib_brand"].FormattedValue.ToString();

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

@@ -0,0 +1,176 @@
+namespace UAS_LabelMachine
+{
+    partial class ExportColumns
+    {
+        /// <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.FirstPage = new System.Windows.Forms.DataGridView();
+            this.DataPage = new System.Windows.Forms.DataGridView();
+            this.label1 = new System.Windows.Forms.Label();
+            this.label2 = new System.Windows.Forms.Label();
+            this.SaveColumns = new System.Windows.Forms.Button();
+            this.ResetColumns = new System.Windows.Forms.Button();
+            this.DeleteColumns = new System.Windows.Forms.Button();
+            this.DeleteDataColumns = new System.Windows.Forms.Button();
+            ((System.ComponentModel.ISupportInitialize)(this.FirstPage)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.DataPage)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // FirstPage
+            // 
+            this.FirstPage.AllowUserToAddRows = false;
+            this.FirstPage.AllowUserToOrderColumns = true;
+            this.FirstPage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+            this.FirstPage.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+            this.FirstPage.Location = new System.Drawing.Point(12, 50);
+            this.FirstPage.Name = "FirstPage";
+            this.FirstPage.ReadOnly = true;
+            this.FirstPage.RowTemplate.Height = 23;
+            this.FirstPage.Size = new System.Drawing.Size(1197, 270);
+            this.FirstPage.TabIndex = 0;
+            // 
+            // DataPage
+            // 
+            this.DataPage.AllowUserToAddRows = false;
+            this.DataPage.AllowUserToOrderColumns = true;
+            this.DataPage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
+            | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+            this.DataPage.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+            this.DataPage.Location = new System.Drawing.Point(12, 365);
+            this.DataPage.Name = "DataPage";
+            this.DataPage.ReadOnly = true;
+            this.DataPage.RowTemplate.Height = 23;
+            this.DataPage.Size = new System.Drawing.Size(1197, 270);
+            this.DataPage.TabIndex = 1;
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("宋体", 10F);
+            this.label1.Location = new System.Drawing.Point(11, 24);
+            this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(77, 14);
+            this.label1.TabIndex = 13;
+            this.label1.Text = "首页列配置";
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Font = new System.Drawing.Font("宋体", 10F);
+            this.label2.Location = new System.Drawing.Point(9, 337);
+            this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(77, 14);
+            this.label2.TabIndex = 14;
+            this.label2.Text = "数据列配置";
+            // 
+            // SaveColumns
+            // 
+            this.SaveColumns.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
+            this.SaveColumns.Location = new System.Drawing.Point(696, 648);
+            this.SaveColumns.Margin = new System.Windows.Forms.Padding(2);
+            this.SaveColumns.Name = "SaveColumns";
+            this.SaveColumns.Size = new System.Drawing.Size(80, 24);
+            this.SaveColumns.TabIndex = 15;
+            this.SaveColumns.Text = "保存";
+            this.SaveColumns.UseVisualStyleBackColor = true;
+            this.SaveColumns.Click += new System.EventHandler(this.SaveColumns_Click);
+            // 
+            // ResetColumns
+            // 
+            this.ResetColumns.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
+            this.ResetColumns.Location = new System.Drawing.Point(613, 648);
+            this.ResetColumns.Margin = new System.Windows.Forms.Padding(2);
+            this.ResetColumns.Name = "ResetColumns";
+            this.ResetColumns.Size = new System.Drawing.Size(80, 24);
+            this.ResetColumns.TabIndex = 16;
+            this.ResetColumns.Text = "重置列";
+            this.ResetColumns.UseVisualStyleBackColor = true;
+            this.ResetColumns.Click += new System.EventHandler(this.ResetColumns_Click);
+            // 
+            // DeleteColumns
+            // 
+            this.DeleteColumns.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
+            this.DeleteColumns.Location = new System.Drawing.Point(449, 648);
+            this.DeleteColumns.Margin = new System.Windows.Forms.Padding(2);
+            this.DeleteColumns.Name = "DeleteColumns";
+            this.DeleteColumns.Size = new System.Drawing.Size(80, 24);
+            this.DeleteColumns.TabIndex = 17;
+            this.DeleteColumns.Text = "移除首页列";
+            this.DeleteColumns.UseVisualStyleBackColor = true;
+            this.DeleteColumns.Click += new System.EventHandler(this.DeleteColumns_Click);
+            // 
+            // DeleteDataColumns
+            // 
+            this.DeleteDataColumns.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
+            this.DeleteDataColumns.Location = new System.Drawing.Point(529, 648);
+            this.DeleteDataColumns.Margin = new System.Windows.Forms.Padding(2);
+            this.DeleteDataColumns.Name = "DeleteDataColumns";
+            this.DeleteDataColumns.Size = new System.Drawing.Size(80, 24);
+            this.DeleteDataColumns.TabIndex = 18;
+            this.DeleteDataColumns.Text = "移除数据列";
+            this.DeleteDataColumns.UseVisualStyleBackColor = true;
+            this.DeleteDataColumns.Click += new System.EventHandler(this.DeleteDataColumns_Click);
+            // 
+            // ExportColumns
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(1221, 681);
+            this.Controls.Add(this.DeleteDataColumns);
+            this.Controls.Add(this.DeleteColumns);
+            this.Controls.Add(this.ResetColumns);
+            this.Controls.Add(this.SaveColumns);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.DataPage);
+            this.Controls.Add(this.FirstPage);
+            this.Name = "ExportColumns";
+            this.Text = "导出列配置";
+            this.Load += new System.EventHandler(this.ExportColumns_Load);
+            ((System.ComponentModel.ISupportInitialize)(this.FirstPage)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.DataPage)).EndInit();
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.DataGridView FirstPage;
+        private System.Windows.Forms.DataGridView DataPage;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Button SaveColumns;
+        private System.Windows.Forms.Button ResetColumns;
+        private System.Windows.Forms.Button DeleteColumns;
+        private System.Windows.Forms.Button DeleteDataColumns;
+    }
+}

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

@@ -0,0 +1,247 @@
+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;
+using UAS_LabelMachine.PublicMethod;
+
+namespace UAS_LabelMachine
+{
+    public partial class ExportColumns : Form
+    {
+        DataHelper dh = SystemInf.dh;
+
+        string inoutno = "";
+        string custcode = "";
+
+        public ExportColumns()
+        {
+            InitializeComponent();
+        }
+
+        public ExportColumns(string IInoutno)
+        {
+            InitializeComponent();
+            inoutno = IInoutno;
+        }
+
+        private void ExportColumns_Load(object sender, EventArgs e)
+        {
+            LoadData();
+        }
+
+        private void SaveColumns_Click(object sender, EventArgs e)
+        {
+            //先删除之前此客户的记录
+            dh.ExecuteSql("delete from CS_EXPORTSETTING where es_custcode='" + custcode + "'", "delete");
+            StringBuilder sql = new StringBuilder();
+            List<string> es_filed = new List<string>();
+            List<string> es_caption = new List<string>();
+            List<string> es_enable = new List<string>();
+            List<string> es_prefix = new List<string>();
+            List<string> es_suffix = new List<string>();
+            List<string> es_detno = new List<string>();
+            List<string> es_filed1 = new List<string>();
+            List<string> es_istitle = new List<string>();
+            //插入首页固定的抬头
+            es_filed.Add("pi_title"); es_caption.Add("客户"); es_enable.Add("-1"); es_prefix.Add("'客户:'"); es_suffix.Add("''"); es_detno.Add("0.1"); es_filed1.Add("pi_title"); es_istitle.Add("-1");
+            es_filed.Add("pi_inoutno"); es_caption.Add("出货单号"); es_enable.Add("-1"); es_prefix.Add("'出货单号:'"); es_suffix.Add("''"); es_detno.Add("0.2"); es_filed1.Add("pi_inoutno"); es_istitle.Add("-1");
+            es_filed.Add("pr_spec"); es_caption.Add("型号"); es_enable.Add("-1"); es_prefix.Add("'型号:'"); es_suffix.Add("''"); es_detno.Add("0.3"); es_filed1.Add("pr_spec"); es_istitle.Add("-1");
+            es_filed.Add("pi_date"); es_caption.Add("销售日期"); es_enable.Add("-1"); es_prefix.Add("'销售日期:'"); es_suffix.Add("'销售部门:市场部'"); es_detno.Add("0.4"); es_filed1.Add("pi_date"); es_istitle.Add("-1");
+            es_filed.Add("pd_ordercode"); es_caption.Add("订单编号"); es_enable.Add("-1"); es_prefix.Add("''"); es_suffix.Add("''"); es_detno.Add("0.5"); es_filed1.Add("pd_ordercode"); es_istitle.Add("-1");
+            //插入首页信息
+            for (int i = 0; i < FirstPage.Columns.Count; i++)
+            {
+                for (int j = 0; j < FirstPage.Columns.Count; j++)
+                {
+                    if (i == FirstPage.Columns[j].DisplayIndex)
+                    {
+                        //pr_spec1 冲突BUG暂时无解,先特殊处理
+                        es_filed.Add(FirstPage.Columns[j].Tag.ToString() == "pr_spec1" ? "pr_spec" : FirstPage.Columns[j].Tag.ToString());
+                        es_caption.Add(FirstPage.Columns[j].DataPropertyName);
+                        es_enable.Add("-1");
+                        es_prefix.Add("''");
+                        es_suffix.Add("''");
+                        es_detno.Add((FirstPage.Columns[j].DisplayIndex + 1).ToString());
+                        es_filed1.Add(FirstPage.Columns[j].Tag.ToString());
+                        es_istitle.Add("");
+                    }
+                }
+            }
+            sql.Clear();
+            sql.Append("insert into CS_EXPORTSETTING(es_type,es_filed,es_caption,es_enable,es_prefix,es_suffix,es_detno,es_filed1,es_custcode,es_istitle)");
+            sql.Append("values('First',:es_filed,:es_caption,:es_enable,:es_prefix,:es_suffix,:es_detno,:es_filed1,'" + custcode + "',:es_istitle)");
+            dh.BatchInsert(sql.ToString(), new string[] { "es_filed", "es_caption", "es_enable", "es_prefix", "es_suffix", "es_detno", "es_filed1", "es_istitle" }, es_filed.ToArray(), es_caption.ToArray(), es_enable.ToArray(), es_prefix.ToArray(), es_suffix.ToArray(), es_detno.ToArray(), es_filed1.ToArray(), es_istitle.ToArray());
+            //清除首页赋的值
+            es_filed.Clear(); es_caption.Clear(); es_enable.Clear(); es_prefix.Clear(); es_suffix.Clear(); es_detno.Clear(); es_filed.Clear(); es_filed1.Clear(); es_istitle.Clear();
+            //新生成Data的抬头
+            es_filed.Add("pi_title"); es_caption.Add("客户"); es_enable.Add("-1"); es_prefix.Add("'客户:'"); es_suffix.Add("''"); es_detno.Add("0.1"); es_filed1.Add("pi_title"); es_istitle.Add("-1");
+            es_filed.Add("pi_inoutno"); es_caption.Add("出货单号"); es_enable.Add("-1"); es_prefix.Add("'出货单号:'"); es_suffix.Add("''"); es_detno.Add("0.2"); es_filed1.Add("pi_inoutno"); es_istitle.Add("-1");
+            es_filed.Add("pr_spec"); es_caption.Add("型号"); es_enable.Add("-1"); es_prefix.Add("'型号:'"); es_suffix.Add("'销售部门:市场部'"); es_detno.Add("0.3"); es_filed1.Add("pr_spec"); es_istitle.Add("-1");
+            es_filed.Add("pi_date"); es_caption.Add("销售日期"); es_enable.Add("-1"); es_prefix.Add("'销售日期:'"); es_suffix.Add("''"); es_detno.Add("0.4"); es_filed1.Add("pi_date"); es_istitle.Add("-1");
+            for (int i = 0; i < DataPage.Columns.Count; i++)
+            {
+                for (int j = 0; j < DataPage.Columns.Count; j++)
+                {
+                    if (i == DataPage.Columns[j].DisplayIndex)
+                    {
+                        //pr_spec1 冲突BUG暂时无解,先特殊处理
+                        es_filed.Add(DataPage.Columns[j].Tag.ToString() == "pr_spec1" ? "pr_spec" : DataPage.Columns[j].Tag.ToString());
+                        es_caption.Add(DataPage.Columns[j].DataPropertyName);
+                        es_enable.Add("-1");
+                        es_prefix.Add("''");
+                        es_suffix.Add("''");
+                        es_detno.Add((DataPage.Columns[j].DisplayIndex + 1).ToString());
+                        es_filed1.Add(DataPage.Columns[j].Tag.ToString());
+                        es_istitle.Add("");
+                    }
+                }
+            }
+            sql.Clear();
+            sql.Append("insert into CS_EXPORTSETTING(es_type,es_filed,es_caption,es_enable,es_prefix,es_suffix,es_detno,es_filed1,es_custcode,es_istitle)");
+            sql.Append("values('DataPage',:es_filed,:es_caption,:es_enable,:es_prefix,:es_suffix,:es_detno,:es_filed1,'" + custcode + "',:es_istitle)");
+            dh.BatchInsert(sql.ToString(), new string[] { "es_filed", "es_caption", "es_enable", "es_prefix", "es_suffix", "es_detno", "es_filed1", "es_istitle" }, es_filed.ToArray(), es_caption.ToArray(), es_enable.ToArray(), es_prefix.ToArray(), es_suffix.ToArray(), es_detno.ToArray(), es_filed1.ToArray(), es_istitle.ToArray());
+            MessageBox.Show("保存成功!");
+        }
+
+        private void ResetColumns_Click(object sender, EventArgs e)
+        {
+            string close = MessageBox.Show(this.ParentForm, "是否重置列", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
+            if (close == "Yes")
+            {
+                dh.ExecuteSql("delete from CS_EXPORTSETTING where es_custcode='" + custcode + "'", "delete");
+                LoadData();
+            }
+        }
+
+        private void DeleteColumns_Click(object sender, EventArgs e)
+        {
+            DataGridViewSelectedCellCollection cl = FirstPage.SelectedCells;
+            List<int> deleteIndex = new List<int>();
+            for (int i = 0; i < cl.Count; i++)
+            {
+                if (!deleteIndex.Contains(cl[i].ColumnIndex))
+                {
+                    deleteIndex.Add(cl[i].ColumnIndex);
+                }
+            }
+            for (int i = FirstPage.Columns.Count - 1; i >= 0; i--)
+            {
+                for (int j = 0; j < deleteIndex.ToArray().Length; j++)
+                {
+                    if (deleteIndex.ToArray()[j] == i)
+                        FirstPage.Columns.RemoveAt(i);
+                }
+            }
+        }
+
+        private void DeleteDataColumns_Click(object sender, EventArgs e)
+        {
+            DataGridViewSelectedCellCollection cl = DataPage.SelectedCells;
+            List<int> deleteIndex = new List<int>();
+            for (int i = 0; i < cl.Count; i++)
+            {
+                if (!deleteIndex.Contains(cl[i].ColumnIndex))
+                {
+                    deleteIndex.Add(cl[i].ColumnIndex);
+                }
+            }
+            for (int i = DataPage.Columns.Count - 1; i >= 0; i--)
+            {
+                for (int j = 0; j < deleteIndex.ToArray().Length; j++)
+                {
+                    if (deleteIndex.ToArray()[j] == i)
+                        DataPage.Columns.RemoveAt(i);
+                }
+            }
+        }
+
+        private void LoadData()
+        {
+            StringBuilder sql = new StringBuilder();
+            custcode = dh.getFieldDataByCondition("prodinout", "pi_cardcode", "pi_inoutno='" + inoutno + "'").ToString();
+            DataTable SQL1_ = (DataTable)dh.ExecuteSql("select es_filed,es_caption,es_prefix,es_suffix,es_filed1 from CS_EXPORTSETTING where es_type='DataPage' and es_enable=-1 and es_custcode='" + custcode + "' and nvl(es_istitle,0)<>-1 order by es_detno", "select");
+            //没有置顶客户的取空的
+            if (SQL1_.Rows.Count == 0)
+            {
+                SQL1_ = (DataTable)dh.ExecuteSql("select es_filed,es_caption,es_prefix,es_suffix,es_filed1 from CS_EXPORTSETTING where es_type='DataPage' and es_enable=-1 and es_custcode is null  and nvl(es_istitle,0)<>-1 order by es_detno", "select");
+            }
+            string es_field1 = "";
+            for (int i = 0; i < SQL1_.Rows.Count; i++)
+            {
+                es_field1 += SQL1_.Rows[i]["es_prefix"].ToString() + "||" + SQL1_.Rows[i]["es_filed"].ToString() + "||" + SQL1_.Rows[i]["es_suffix"].ToString() + ",";
+            }
+            //分页信息的DataTable
+            string datasql = "";
+            LogicHandler.GetDataSQL(inoutno, es_field1.Substring(0, es_field1.Length - 1), out datasql);
+            DataTable dt = (DataTable)dh.ExecuteSql(datasql, "select");
+            for (int i = 0; i < dt.Columns.Count; i++)
+            {
+                if (dt.Columns[i].ColumnName == (SQL1_.Rows[i]["es_prefix"].ToString() + "||" + SQL1_.Rows[i]["es_filed"].ToString() + "||" + SQL1_.Rows[i]["es_suffix"].ToString()).ToUpper())
+                {
+                    dt.Columns[i].Caption = SQL1_.Rows[i]["es_filed1"].ToString();
+                    dt.Columns[i].ColumnName = SQL1_.Rows[i]["es_caption"].ToString();
+                }
+            }
+            //获取首页需要展示的字段
+            DataTable SQL_ = (DataTable)dh.ExecuteSql("select es_filed,es_caption,es_prefix,es_suffix,es_filed1 from CS_EXPORTSETTING where es_type='First' and es_enable=-1 and es_custcode='" + custcode + "' and nvl(es_istitle,0)<>-1 order by es_detno", "select");
+            if (SQL_.Rows.Count == 0)
+            {
+                SQL_ = (DataTable)dh.ExecuteSql("select es_filed,es_caption,es_prefix,es_suffix,es_filed1 from CS_EXPORTSETTING where es_type='First' and es_enable=-1 and es_custcode is null and  nvl(es_istitle,0)<>-1 order by es_detno", "select");
+            }
+            string es_field = "";
+            for (int i = 0; i < SQL_.Rows.Count; i++)
+            {
+                es_field += SQL_.Rows[i]["es_prefix"].ToString() + "||" + SQL_.Rows[i]["es_filed"].ToString() + "||" + SQL_.Rows[i]["es_suffix"].ToString() + ",";
+            }
+            //首页信息的DataTable
+            sql.Clear();
+            sql.Append("select " + es_field.Substring(0, es_field.Length - 1) + "  from FIRSTPAGE_BATCH_VIEW where pi_inoutno='" + inoutno + "'");
+            DataTable dt1 = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
+            for (int i = 0; i < dt1.Columns.Count; i++)
+            {
+                if (dt1.Columns[i].ColumnName == (SQL_.Rows[i]["es_prefix"].ToString() + "||" + SQL_.Rows[i]["es_filed"].ToString() + "||" + SQL_.Rows[i]["es_suffix"].ToString()).ToUpper())
+                {
+                    dt1.Columns[i].Caption = SQL_.Rows[i]["es_filed1"].ToString();
+                    dt1.Columns[i].ColumnName = SQL_.Rows[i]["es_caption"].ToString();
+                }
+            }
+            if (FirstPage.DataSource != null)
+                FirstPage.DataSource = null;
+            if (DataPage.DataSource != null)
+                DataPage.DataSource = null;
+            FirstPage.DataSource = dt1;
+            DataPage.DataSource = dt;
+            //将字段赋值到Tag字段,后续保存的时候取值
+            for (int i = 0; i < FirstPage.Columns.Count; i++)
+            {
+                for (int j = 0; j < dt1.Columns.Count; j++)
+                {
+                    if (FirstPage.Columns[i].Name == dt1.Columns[j].ColumnName)
+                    {
+                        FirstPage.Columns[i].Tag = dt1.Columns[j].Caption;
+                    }
+                }
+            }
+
+            for (int i = 0; i < DataPage.Columns.Count; i++)
+            {
+                for (int j = 0; j < dt.Columns.Count; j++)
+                {
+                    if (DataPage.Columns[i].Name == dt.Columns[j].ColumnName)
+                    {
+                        DataPage.Columns[i].Tag = dt.Columns[j].Caption;
+                    }
+                }
+            }
+            DataPage.Columns["chw_percent1"].HeaderText = "机测1";
+            DataPage.Columns["chw_percent2"].HeaderText = "机测2";
+            DataPage.Columns["chw_itemname1"].Visible = false;
+            DataPage.Columns["chw_itemname2"].Visible = false;
+        }
+    }
+}

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

@@ -0,0 +1,120 @@
+<?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>
+</root>

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

@@ -53,11 +53,12 @@
             this.FirstPage_YIELD = new System.Windows.Forms.CheckBox();
             this.FirstPage_REMARK = new System.Windows.Forms.CheckBox();
             this.RowNum = new UAS_LabelMachine.CustomControl.NumOnlyTextBox();
+            this.ExportSetting = new System.Windows.Forms.Button();
             this.SuspendLayout();
             // 
             // Export
             // 
-            this.Export.Location = new System.Drawing.Point(240, 288);
+            this.Export.Location = new System.Drawing.Point(292, 290);
             this.Export.Margin = new System.Windows.Forms.Padding(2);
             this.Export.Name = "Export";
             this.Export.Size = new System.Drawing.Size(94, 24);
@@ -69,8 +70,6 @@
             // 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(130, 58);
             this.CH_BLUEFILM.Margin = new System.Windows.Forms.Padding(2);
@@ -83,8 +82,6 @@
             // 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(350, 58);
             this.CH_SPLITBATCH.Margin = new System.Windows.Forms.Padding(2);
@@ -97,8 +94,6 @@
             // 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(130, 94);
             this.CH_PBCODE.Margin = new System.Windows.Forms.Padding(2);
@@ -111,8 +106,6 @@
             // 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(244, 94);
             this.CH_REMARK.Margin = new System.Windows.Forms.Padding(2);
@@ -139,8 +132,6 @@
             // 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(452, 58);
             this.CH_WATERID.Margin = new System.Windows.Forms.Padding(2);
@@ -176,7 +167,7 @@
             // 
             this.label3.AutoSize = true;
             this.label3.Font = new System.Drawing.Font("宋体", 10F);
-            this.label3.Location = new System.Drawing.Point(11, 130);
+            this.label3.Location = new System.Drawing.Point(11, 135);
             this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.label3.Name = "label3";
             this.label3.Size = new System.Drawing.Size(112, 14);
@@ -187,7 +178,7 @@
             // 
             this.label4.AutoSize = true;
             this.label4.Font = new System.Drawing.Font("宋体", 10F);
-            this.label4.Location = new System.Drawing.Point(11, 176);
+            this.label4.Location = new System.Drawing.Point(11, 175);
             this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.label4.Name = "label4";
             this.label4.Size = new System.Drawing.Size(112, 14);
@@ -197,10 +188,8 @@
             // 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(244, 174);
+            this.BVCEO.Location = new System.Drawing.Point(244, 173);
             this.BVCEO.Margin = new System.Windows.Forms.Padding(2);
             this.BVCEO.Name = "BVCEO";
             this.BVCEO.Size = new System.Drawing.Size(61, 18);
@@ -211,10 +200,8 @@
             // 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(130, 174);
+            this.TS.Location = new System.Drawing.Point(130, 173);
             this.TS.Margin = new System.Windows.Forms.Padding(2);
             this.TS.Name = "TS";
             this.TS.Size = new System.Drawing.Size(40, 18);
@@ -225,10 +212,8 @@
             // 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(130, 128);
+            this.percent.Location = new System.Drawing.Point(130, 133);
             this.percent.Margin = new System.Windows.Forms.Padding(2);
             this.percent.Name = "percent";
             this.percent.Size = new System.Drawing.Size(47, 18);
@@ -310,8 +295,6 @@
             // FirstPage_WID
             // 
             this.FirstPage_WID.AutoSize = true;
-            this.FirstPage_WID.Checked = true;
-            this.FirstPage_WID.CheckState = System.Windows.Forms.CheckState.Checked;
             this.FirstPage_WID.Font = new System.Drawing.Font("宋体", 10F);
             this.FirstPage_WID.Location = new System.Drawing.Point(130, 254);
             this.FirstPage_WID.Margin = new System.Windows.Forms.Padding(2);
@@ -347,7 +330,7 @@
             // 
             // RowNum
             // 
-            this.RowNum.Location = new System.Drawing.Point(480, 216);
+            this.RowNum.Location = new System.Drawing.Point(480, 214);
             this.RowNum.Margin = new System.Windows.Forms.Padding(2);
             this.RowNum.Name = "RowNum";
             this.RowNum.Negative = false;
@@ -355,11 +338,23 @@
             this.RowNum.TabIndex = 30;
             this.RowNum.Text = "10";
             // 
+            // ExportSetting
+            // 
+            this.ExportSetting.Location = new System.Drawing.Point(201, 290);
+            this.ExportSetting.Margin = new System.Windows.Forms.Padding(2);
+            this.ExportSetting.Name = "ExportSetting";
+            this.ExportSetting.Size = new System.Drawing.Size(80, 24);
+            this.ExportSetting.TabIndex = 33;
+            this.ExportSetting.Text = "导出列配置";
+            this.ExportSetting.UseVisualStyleBackColor = true;
+            this.ExportSetting.Click += new System.EventHandler(this.ExportSetting_Click);
+            // 
             // ExportExcel
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(572, 338);
+            this.ClientSize = new System.Drawing.Size(572, 336);
+            this.Controls.Add(this.ExportSetting);
             this.Controls.Add(this.FirstPage_REMARK);
             this.Controls.Add(this.FirstPage_YIELD);
             this.Controls.Add(this.RowNum);
@@ -420,5 +415,6 @@
         private System.Windows.Forms.FolderBrowserDialog ExportFileDialog;
         private System.Windows.Forms.CheckBox FirstPage_YIELD;
         private System.Windows.Forms.CheckBox FirstPage_REMARK;
+        private System.Windows.Forms.Button ExportSetting;
     }
 }

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

@@ -7,6 +7,7 @@ using System.Linq;
 using System.Text;
 using System.Windows.Forms;
 using UAS_LabelMachine.Entity;
+using UAS_LabelMachine.PublicMethod;
 
 namespace UAS_LabelMachine
 {
@@ -79,12 +80,9 @@ namespace UAS_LabelMachine
                     es_field1 += SQL1_.Rows[i]["es_prefix"].ToString() + "||" + SQL1_.Rows[i]["es_filed"].ToString() + "||" + SQL1_.Rows[i]["es_suffix"].ToString() + ",";
                 }
                 //分页信息的DataTable
-                sql.Clear();
-                sql.Append("select " + es_field1.Substring(0, es_field1.Length - 1) + " from  prodinout left join prodiodetail on pi_id=pd_piid left join ");
-                sql.Append("chip_in_out 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");
-
+                string datasql = "";
+                LogicHandler.GetDataSQL(inoutno, es_field1.Substring(0, es_field1.Length - 1), out datasql);
+                DataTable dt = (DataTable)dh.ExecuteSql(datasql, "select");
                 for (int i = 0; i < dt.Columns.Count; i++)
                 {
                     if (dt.Columns[i].ColumnName == (SQL1_.Rows[i]["es_prefix"].ToString() + "||" + SQL1_.Rows[i]["es_filed"].ToString() + "||" + SQL1_.Rows[i]["es_suffix"].ToString()).ToUpper())
@@ -129,5 +127,12 @@ namespace UAS_LabelMachine
         {
 
         }
+
+        private void ExportSetting_Click(object sender, EventArgs e)
+        {
+            ExportColumns ex = new ExportColumns(inoutno);
+            ex.WindowState = FormWindowState.Maximized;
+            ex.ShowDialog();
+        }
     }
 }

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

@@ -39,17 +39,6 @@ namespace UAS_LabelMachine
             }
             //获取账套信息
             Masterdt = (DataTable)dh.ExecuteSql("select ma_function,ms_pwd,ma_user from master ", "select");
-            DataTable MasterDB = Masterdt.Clone();
-            for (int i = 0; i < Masterdt.Rows.Count; i++)
-            {
-                if (DataHelper.Masters.Contains(Masterdt.Rows[i]["ma_user"].ToString()))
-                {
-                    DataRow dr = MasterDB.NewRow();
-                    dr["ma_user"] = Masterdt.Rows[i]["ma_user"];
-                    dr["ma_function"] = Masterdt.Rows[i]["ma_function"];
-                    MasterDB.Rows.Add(dr);
-                }
-            }
             MasterCombox.DisplayMember = "ma_function";
             MasterCombox.ValueMember = "ma_user";
             MasterCombox.DataSource = Masterdt;

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

@@ -9,6 +9,9 @@ using UAS_LabelMachine.CustomControl.GroupBoxWithBorder;
 using static System.Windows.Forms.Control;
 using System.Text.RegularExpressions;
 using Seagull.BarTender.Print;
+using Microsoft.CSharp;
+using System.CodeDom.Compiler;
+using System.Reflection;
 
 namespace UAS_LabelMachine
 {
@@ -879,13 +882,70 @@ namespace UAS_LabelMachine
             {
                 GroupByCondition += "pd_ordercode,";
             }
-            if (iCustProdCode || iCustPo || iDC || iLotNo|| iOrderCode)
+            if (iCustProdCode || iCustPo || iDC || iLotNo || iOrderCode)
             {
                 GroupByCondition = " group by " + (GroupByCondition.Substring(0, GroupByCondition.Length - 1));
             }
             sql.Append("max(pib_id),");
-            Console.WriteLine("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno = '" + pi_inoutno + "' and pib_outboxcode2 = " + (pib_outboxcode2 == "" ? "0" : pib_outboxcode2) + GroupByCondition);
             return "select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno = '" + pi_inoutno + "' and pib_outboxcode2 = " + (pib_outboxcode2 == "" ? "0" : pib_outboxcode2) + GroupByCondition;
         }
+
+        public static void CustomerInit(string oContent)
+        {
+            if (oContent == ""|| oContent=="null"|| oContent==" ")
+                return;
+            //创建编译环境实例
+            CSharpCodeProvider objCSharpCodePrivoder = new CSharpCodeProvider();
+            //UAS_LabelMachine
+            CompilerParameters objCompilerParameters = new CompilerParameters();
+            objCompilerParameters.ReferencedAssemblies.Add("System.dll");
+            objCompilerParameters.ReferencedAssemblies.Add("System.Windows.Forms.dll");
+            objCompilerParameters.GenerateExecutable = false;
+            objCompilerParameters.GenerateInMemory = true;
+            Console.WriteLine(oContent);
+            // 4.CompilerResults
+            CompilerResults cr = objCSharpCodePrivoder.CompileAssemblyFromSource(objCompilerParameters, oContent);
+            if (cr.Errors.HasErrors)
+            {
+                foreach (CompilerError err in cr.Errors)
+                {
+                    Console.WriteLine(err.ErrorText);
+                }
+            }
+            else
+            {
+                // 通过反射,调用HelloWorld的实例
+                Assembly objAssembly = cr.CompiledAssembly;
+                object objHelloWorld = objAssembly.CreateInstance("CustInitSpace.CustInitClass", true);
+                MethodInfo objMI = objHelloWorld.GetType().GetMethod("CustInit");
+                try
+                {
+                    Console.WriteLine(objMI.Invoke(objHelloWorld, null));     
+                }
+                catch (Exception ex)
+                {
+                    Console.WriteLine(ex.StackTrace);
+                    Console.WriteLine(ex.Message);
+                }
+            }
+        }
+    }
+
+
+    namespace CustInitSpace
+    {
+        using System;
+        using System.Windows.Forms;
+        public class CustInitClass
+        {
+            public void CustInit()
+            {
+                Form f = Form.ActiveForm;
+                (f.Controls["LabelInf"] as DataGridView).Columns["pib_year"].Visible = false;
+                (f.Controls["LabelInf"] as DataGridView).Columns["pib_month"].Visible = false;
+                (f.Controls["LabelInf"] as DataGridView).Columns["pib_day"].Visible = false;
+                (f.Controls["LabelInf"] as DataGridView).Columns["pib_custoutboxcode"].HeaderText = "芯片号";
+            }
+        }
     }
 }

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

@@ -11,30 +11,30 @@ 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";
+        ////深爱地址
+        //private readonly string ConnectionStrings = "Data Source=172.16.0.22/orcl;User ID=SZSI_TEST;PassWord=select!#%*(";
 
-        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 IPConnectionStrings = "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";
 
-        //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/";
-        ////海创FTP
-        //public static readonly string FTPAddress = "ftp://cmityj.gicp.net|HCFTP|Admin1@#";
-
-        //public static readonly string InnerFTPAddress = "ftp://192.168.1.8|HCFTP|Admin1@#";
+        //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!#%*(";
+
+        private readonly string IPConnectionStrings = "Data Source=183.237.197.78/orcl;User ID=HC_TEST;PassWord=select!#%*(";
+        //海创ERP地址
+        public static readonly string ERPAddesss = "http://cmityj.gicp.net:8099/ERP/";
+        //海创FTP
+        public static readonly string FTPAddress = "ftp://cmityj.gicp.net|HCFTP|Admin1@#";
+
+        public static readonly string InnerFTPAddress = "ftp://192.168.1.8|HCFTP|Admin1@#";
+        //Oracle端口
+        public static readonly string OraclePort = "1521";
 
         ////凯而高地址
         //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)));";
@@ -45,20 +45,6 @@ namespace UAS_LabelMachine
         //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)));";
-        ////凯而高ERP地址
-        //public static readonly string ERPAddesss = "http://192.168.100.11:8099/ERP/";
-        ////凯而高FTP
-        //public static readonly string InnerFTPAddress = "ftp://192.168.100.11:21|KEGFTP|Admin1@#";
-        //public static readonly string FTPAddress = "ftp://192.168.100.11:21|KEGFTP|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=DATACENTER;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=183.238.39.179)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
@@ -69,8 +55,6 @@ namespace UAS_LabelMachine
         //public static readonly string FTPAddress = "ftp://183.238.39.179:21|GOLDENMES|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=DATACENTER;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=sz.hi-mantech.com)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
@@ -80,8 +64,6 @@ namespace UAS_LabelMachine
         //public static readonly string FTPAddress = "ftp://sz.hi-mantech.com:46688|yhndftp|Stga28ytG8";
         ////Oracle端口
         //public static readonly string OraclePort = "1521";
-        ////需要显示的账套
-        //public static readonly string Masters = "YHND_SZ,YHND_HK,DATACENTER";
 
         ////华商龙外网地址
         //private readonly string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=YITOA_DATACENTER;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=218.18.115.198)(PORT=1523)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
@@ -91,19 +73,7 @@ namespace UAS_LabelMachine
         //public static readonly string FTPAddress = "ftp://218.18.115.198:21|Print|Administrator1@#";
         ////Oracle端口
         //public static readonly string OraclePort = "1523";
-        ////需要显示的账套
-        //public static readonly string Masters = "XSQ,N_YITOA_YWC,ZXN,N_YITOA_LHCT,N_YITOA_CT,N_CHL,N_YITOA_HK,N_HUASL_SHTL,N_WILICHK,N_WILIC,N_E_SHINE_SH,N_SHBJ,N_BJKG,N_HUASL,N_HUASL_QD,N_HUASL_XM,N_HUASL_SZ";
 
-        ////UAS测试地址
-        //private readonly string ConnectionStrings = "Data Source=192.168.253.6/orcl;User ID=UAS_TEST;PassWord=select!#%*(";
-        ////UAS测试地址
-        //public static readonly string ERPAddesss = "http://192.168.253.6/uas_test/";
-        ////UAS测试FTP
-        //public static readonly string FTPAddress = "ftp://192.168.253.9/PrintFile|mesconfig|Administrator1@#";
-        ////Oracle端口
-        //public static readonly string OraclePort = "1521";
-        ////需要显示的账套
-        //public static readonly string Masters = "UAS_TEST";
         public static string DBConnectionString;
         static OracleConnection connection = null;
         static OracleCommand command = null;
@@ -130,7 +100,10 @@ namespace UAS_LabelMachine
                 }
                 connection.Open();
             }
-            catch (Exception e) { LogManager.DoLog(e.Message); }
+            catch (Exception e) {
+                connection = new OracleConnection(IPConnectionStrings);
+                connection.Open();
+                LogManager.DoLog(e.Message); }
         }
 
         /// <summary>
@@ -851,7 +824,7 @@ namespace UAS_LabelMachine
         {
             object result = null;
             command = new OracleCommand(SQL, connection);
-            Console.WriteLine(SQL);
+            //Console.WriteLine(SQL);
             //用来拼接参数的
             if (names.Length > 0)
             {

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

@@ -9,6 +9,7 @@ using UAS_LabelMachine.Entity;
 using UAS_LabelMachine.PublicMethod;
 using System.Collections.Generic;
 using System.Windows.Forms;
+using System.Text.RegularExpressions;
 
 namespace UAS_LabelMachine
 {
@@ -43,7 +44,7 @@ namespace UAS_LabelMachine
         {
             //创建一个内存流,用来接收转换成Excel的内容
             MemoryStream ms;
-            ms = DataTableToExcel1(firstsdt, dt, Type, PageSize, conditionbox);
+            ms = DataTableToExcel1(firstsdt, dt, Type, FileName, PageSize, conditionbox);
             //以系统当前时间命名文件,FileMode.Create表示创建文件,FileAccess.Write表示拥有写的权限
             string filePath = @FolderPath + "\\" + FileName + ".xls";
             FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
@@ -228,10 +229,10 @@ namespace UAS_LabelMachine
             style.FillPattern = FillPattern.BigSpots;
             style.FillBackgroundColor = HSSFColor.LightGreen.Index;
             //设置边框
-            style.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thick;
-            style.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thick;
-            style.BorderRight = NPOI.SS.UserModel.BorderStyle.Thick;
-            style.BorderTop = NPOI.SS.UserModel.BorderStyle.Thick;
+            style.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
+            style.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
+            style.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
+            style.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
             row.HeightInPoints = 20;
             //固定第一行
             //row.RowStyle.IsLocked=true;
@@ -267,7 +268,7 @@ namespace UAS_LabelMachine
         /// </summary>
         /// <param name="DataTable"></param>
         /// <returns></returns>
-        public MemoryStream DataTableToExcel1(DataTable FirstDT, DataTable DataTable, string Type, int PageSize, List<CheckBox> conditionbox)
+        public MemoryStream DataTableToExcel1(DataTable FirstDT, DataTable DataTable, string Type,string Inoutno, int PageSize, List<CheckBox> conditionbox)
         {
             //转换为序列
             CheckBox[] box = conditionbox.ToArray();
@@ -278,17 +279,24 @@ namespace UAS_LabelMachine
             //Excel中的Sheet
             ISheet sheet = book.CreateSheet("分页");
 
+            //更新箱号
+            List<string> ch_code = new List<string>();
+            //系统打印箱号
+            List<string> pib_outboxcode1 = new List<string>();
+
+            int BoxCode = 1;
             ICellStyle style = book.CreateCellStyle();
             style.VerticalAlignment = VerticalAlignment.Center;
             style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left;
 
             ICellStyle styleborder = book.CreateCellStyle();
-            styleborder.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thick;
-            styleborder.BorderTop = NPOI.SS.UserModel.BorderStyle.Thick;
-            styleborder.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thick;
-            styleborder.BorderRight = NPOI.SS.UserModel.BorderStyle.Thick;
+            styleborder.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
+            styleborder.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
+            styleborder.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
+            styleborder.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
             styleborder.VerticalAlignment = VerticalAlignment.Center;
             styleborder.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left;
+            string pi_inoutno = "";
             //设置列的宽度,根据首行的列的内容的长度来设置
             for (int i = DataTable.Columns.Count - 1; i > 0; i--)
             {
@@ -375,13 +383,7 @@ namespace UAS_LabelMachine
             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;
@@ -433,6 +435,7 @@ namespace UAS_LabelMachine
                             DataRow dr = FirstDT.NewRow();
                             dr["pr_spec"] = DataTable.Rows[i]["pr_spec"].ToString();
                             dr["pi_inoutno"] = DataTable.Rows[i]["pi_inoutno"].ToString();
+                            pi_inoutno = DataTable.Rows[i]["pi_inoutno"].ToString();
                             dr["pi_title"] = DataTable.Rows[i]["pi_title"].ToString();
                             dr["pi_date"] = DataTable.Rows[i]["pi_date"].ToString();
                             dr["pd_ordercode"] = First_OrderCode;
@@ -446,6 +449,7 @@ namespace UAS_LabelMachine
                             First_Prspec = "";
                             First_Batch = "";
                             First_WID.Clear();
+                            BoxCode = BoxCode + 1;
                             for (int j = 0; j < columnNum - 4; j++)
                             {
                                 if (j == 0)
@@ -640,6 +644,8 @@ namespace UAS_LabelMachine
                                 row1.Cells[j].CellStyle = style;
                             }
                         }
+                        ch_code.Add(DataTable.Rows[i]["ch_code"].ToString());
+                        pib_outboxcode1.Add(BoxCode.ToString());
                     }
                     for (int i = 0; i < sheet.LastRowNum; i++)
                     {
@@ -660,6 +666,7 @@ namespace UAS_LabelMachine
                         //如果批号不相等的时候
                         if (LastBatchCode != "" && LastBatchCode != DataTable.Rows[i]["ch_splitbatch"].ToString())
                         {
+                            BoxCode = BoxCode + 1;
                             for (int j = 0; j < columnNum - 4; j++)
                             {
                                 if (j == 0)
@@ -830,6 +837,8 @@ namespace UAS_LabelMachine
                                 row1.Cells[j].CellStyle = style;
                             }
                         }
+                        ch_code.Add(DataTable.Rows[i]["ch_code"].ToString());
+                        pib_outboxcode1.Add(BoxCode.ToString());
                     }
                     for (int i = 0; i < sheet.LastRowNum; i++)
                     {
@@ -850,6 +859,7 @@ namespace UAS_LabelMachine
                         //如果批号不相等的时候
                         if (LastBoxCode != "" && LastBoxCode != DataTable.Rows[i]["CH_PBCODE"].ToString())
                         {
+                            BoxCode = BoxCode + 1;
                             for (int j = 0; j < columnNum - 4; j++)
                             {
                                 if (j == 0)
@@ -1031,6 +1041,8 @@ namespace UAS_LabelMachine
                                 row1.Cells[j].CellStyle = style;
                             }
                         }
+                        ch_code.Add(DataTable.Rows[i]["ch_code"].ToString());
+                        pib_outboxcode1.Add(BoxCode.ToString());
                     }
                     for (int i = 0; i < sheet.LastRowNum; i++)
                     {
@@ -1044,6 +1056,7 @@ namespace UAS_LabelMachine
                 default:
                     break;
             }
+            dh.BatchInsert("update prodiobarcode set pib_outboxcode1=:pib_outboxcode1 where pib_inoutno='"+ Inoutno + "' and pib_custbarcode=:pib_custbarcode",new string[] { "pib_outboxcode1", "pib_custbarcode" },pib_outboxcode1.ToArray(), ch_code.ToArray());
             //填充首页
             sumCount = 0;
             totalCount = 0;

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

@@ -75,6 +75,26 @@ namespace UAS_LabelMachine.PublicMethod
             oSQL = param[1];
         }
 
+        /// <summary>
+        /// 自定义界面代码
+        /// </summary>
+        /// <param name="iPiId"></param>
+        public static void CustInit(string iPiId)
+        {
+            string oContent = "";
+            try
+            {
+                string[] param = new string[] { iPiId, oContent };
+                dh.CallProcedure("SP_CUSTINIT", ref param);
+                oContent = param[1];
+            }
+            catch (Exception)
+            {
+
+            }
+            BaseUtil.CustomerInit(oContent);
+        }
+
         /// <summary>
         /// 获取生成条码的SQL,目前添加用户海创和凯而高,凯而高有特殊定制逻辑
         /// </summary>
@@ -151,6 +171,7 @@ namespace UAS_LabelMachine.PublicMethod
                 MessageBox.Show("文件" + iFileName + "被占用或者格式不正确");
                 return;
             }
+            dt = BaseUtil.filterDataTable(dt, "规格型号 <>''");
             string outsql = "";
             GenerateBarCode(iPiID, iCustCode, out outsql);
             sql.Clear();
@@ -195,8 +216,14 @@ namespace UAS_LabelMachine.PublicMethod
                 //累计Excel该型号的数量
                 sumqty[pr_spec] += decimal.Parse(qty);
             }
-            dt.DefaultView.Sort = "箱号,DC ";
-            dt = dt.DefaultView.ToTable();
+            DataTable temp = dt.Clone();
+            temp.Columns["箱号"].DataType = typeof(int);
+            foreach (DataRow s in dt.Rows)
+            {
+                temp.ImportRow(s);//导入旧数据
+            }
+            temp.DefaultView.Sort = "箱号,DC ";
+            dt = temp.DefaultView.ToTable();
             for (int i = 0; i < dt1.Rows.Count; i++)
             {
                 //不包含型号则进行添加
@@ -454,5 +481,12 @@ namespace UAS_LabelMachine.PublicMethod
             UAS_出货标签打印.custserialnum = UAS_出货标签打印.custserialnum + 1;
             return str;
         }
+
+        public static void GetDataSQL(string iInoutno,string iText,out string oSQL) {
+            oSQL = "";
+            string[] param = new string[] { iInoutno, iText, oSQL };
+            dh.CallProcedure("SP_GETDATASQL", ref param);
+            oSQL = param[2];
+        }
     }
 }

+ 333 - 0
UAS-出货标签管理(贸易版)/SQL/SQL.txt

@@ -0,0 +1,333 @@
+/*上传数据的存储过程*/
+create or replace procedure sp_uploadbarcode(barcode in BarCodeUpload_arr)
+as
+begin 
+   for i in 1 .. barcode.count loop 
+      update prodiobarcode set pib_lotno=barcode(i).pib_lotno,
+      pib_datecode=barcode(i).pib_datecode,pib_outboxcode1=barcode(i).pib_outboxcode1,
+      pib_outboxcode2=barcode(i).pib_outboxcode2,pib_custmidboxcode=barcode(i).pib_custmidboxcode,
+      pib_custoutboxcode=barcode(i).pib_custoutboxcode,
+      pib_ifupload=barcode(i).pib_ifupload,pib_ifpick=barcode(i).pib_ifpick,
+      pib_ifprint=barcode(i).pib_ifprint
+      where pib_id=barcode(i).pib_id;
+   end loop;
+end;
+
+/*创建上传的类型*/
+create or replace type BarCodeUpload_arr as table of BarCodeUpload;
+
+/*上传的对象实体*/
+create or replace type BarCodeUpload as object(
+  pib_id varchar2(20),
+  pib_outboxcode1 varchar2(20),
+  pib_outboxcode2 varchar2(20),
+  pib_custmidboxcode varchar2(20),
+  pib_custoutboxcode varchar2(20),
+  pib_lotno varchar2(20),
+  pib_datecode varchar2(20),
+  pib_ifupload varchar2(20),
+  pib_ifpick varchar2(20),
+  pib_ifprint varchar2(20)
+);
+
+/*获取数据的视图*/
+CREATE OR REPLACE FORCE VIEW "PRODIOBARCODE_VIEW" as
+select 0 choose,pib_ordercode,pib_weight,pib_prdetail,pib_size,pd_ordercode,nvl(pr_midboxcapacity_user,0)pr_midboxcapacity_user,pi_cardcode,pr_madein,pr_vendcode,
+pib_year,pib_month,pib_day,pd_whcode,pd_batchcode,pr_barcode,pd_pdno,pr_brand,pr_detail,pd_orderdetno,pib_custoutboxcode,pib_datecode1,pd_remark,pib_custmidboxcode,
+pr_orispeccode,pi_maitou_user,pd_custprodcode,pib_indate,pi_date,pib_inoutno,pd_custprodspec,nvl(pib_ifrecheck,0)pib_ifrecheck,nvl(pib_ifupload,0)pib_ifupload,
+nvl(pib_ifmodify,0)pib_ifmodify,pd_pocode,pib_madein,pib_custbarcode,pib_id,pib_pdid,pib_piid,pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand,
+pr_vendprodcode,pib_lotno,pib_datecode,pib_qty,pr_spec,pi_title,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifpick,0)pib_ifpick,nvl
+(pib_ifprint,0)pib_ifprint,pd_outerboxgw,pd_outerboxnw from prodiobarcode left join prodinout on pib_piid=pi_id left join prodiodetail on pib_piid=pd_piid and  
+pd_id=pib_pdid left join product on pr_code=pib_prodcode left join sale on sa_code=pib_ordercode  order by to_number(pib_outboxcode2),pib_custoutboxcode;
+
+/*自动生成条码的存储过程*/
+create or replace PROCEDURE "GETCUSTBARCODE" 
+-- =============================================
+-- Author:    <zhangz>
+-- Create date: <2018-06-12>
+-- Description:  <出货单-过账-自动生成条码-自定义客户条码>
+-- =============================================
+(KEYVALUE in varchar2,ICID in varchar2,V_ERRORMSG OUT varchar2)
+AS
+   v_custcode varchar2(50);   --客户编号
+   v_nrcode varchar2(20);     --编码规则编号
+   v_nrddetno number;         --编码明细序号
+   v_nrdname varchar(20);     --编码明细名称
+   v_nrdtype varchar(20);     --编码明细类型
+   v_nrdsql varchar(500);     --编码明细SQL
+   v_serialindex number;      --流水所在索引
+   v_nrdlength number;        --编码明细流水长度
+   v_seriallen number;        --流水长度
+   v_sqltemp varchar(50);     --SQL查询出来的临时变量
+   v_prefix varchar(50);      --流水前面的前缀(临时)
+   v_v_prefix varchar(50);    --拼接时前缀
+   v_suffix varchar(50);      --流水的后缀
+   v_maxnum varchar(50);      --当前编号+前缀最大的流水
+   v_inoutno varchar(30);     --出货单号
+   v_getcustrule number:=0;      --是否维护了客户自定义规则
+   v_pi_id               ProdInout.pi_id%type;
+   v_p_piclass           ProdInout.pi_class%type;
+   v_p_piinoutno         ProdInout.pi_inoutno%type;
+   v_p_commitname        EMPLOYEE.EM_NAME%TYPE;
+   v_pi_inoutman         ProdInout.pi_inoutman%type;
+   v_pd_ordercode        prodiodetail.pd_ordercode%type;
+   v_pd_prodCode         prodiodetail.pd_prodcode%type;
+   v_pd_thisqty          prodiodetail.pd_outqty%type; 
+   v_pd_outqty           prodiodetail.pd_outqty%type; 
+   v_pd_id               ProdioDetail.pd_id%type;
+   v_pd_piclass          ProdioDetail.pd_piclass%type;
+   v_pd_pdno             ProdioDetail.pd_pdno%type;
+   v_max_barcode         prodiobarcode.pib_barcode%type;
+   v_max_outboxcode      prodiobarcode.pib_outboxcode1%type;
+   v_max_prodcode        prodiobarcode.pib_prodcode%type;
+   v_max_custpo          prodiobarcode.PIB_CUSTPO%type;
+   v_pib_barcode         prodiobarcode.pib_barcode%type;
+   v_pib_custbarcode     prodiobarcode.pib_custbarcode%type;
+   v_pr_zxbzs            product.pr_zxbzs%type;
+   v_pr_id               product.pr_id%type;
+   v_sa_pocode           sale.sa_pocode%type;
+   v_bar_num             NUMBER(8,0);
+   v_box_num             NUMBER(8,0); 
+   v_barcount            NUMBER:=0;  --条码数量
+   v_restqty             FLOAT:=0;  --尾盘数量
+   -- 默认箱内容量 :3,7,10. 默认最优分配箱内容量
+   --最小包装数为1的暂时不自动生成条码
+   CURSOR c_PDIOBarCur IS
+     select pd_id,pd_pdno,pd_prodcode,pd_totalqty pd_outqty,pr_zxbzs,pd_qty pd_thisqty ,pr_id,pd_piclass, pd_ordercode,sa_pocode 
+     from PRODIOBARCODE_VIEW left join sale on sa_code=pd_ordercode 
+     where pd_piid=v_pi_id and pd_qty>0 and pr_zxbzs>1 order by pd_prodcode,pd_id;
+   --存在客户编号的时候
+   CURSOR NR IS 
+     select nrd_detno,nrd_name,nrd_type,nrd_sql,nrd_length,nr_code from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode=v_custcode order by nrd_detno;
+   --不存在客户编号取默认公用规则
+   CURSOR NR_Default IS 
+     select nrd_detno,nrd_name,nrd_type,nrd_sql,nrd_length,nr_code from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode is null and nr_isdefault <> 0 order by nrd_detno;
+   BEGIN 
+       BEGIN
+            select pi_id,pi_inoutno,pi_class,pi_inoutman,pi_cardcode 
+            into v_pi_id,v_p_piinoutno,v_p_piclass,v_pi_inoutman,v_custcode
+            from prodinout where  pi_id=KEYVALUE;
+       EXCEPTION
+           WHEN NO_DATA_FOUND THEN
+              V_ERRORMSG := '没有当前出入库记录!' ;
+            RETURN;
+        END; 
+        select pi_inoutno into v_inoutno from prodinout where pi_id=KEYVALUE;
+        IF(v_p_piclass='出货单') THEN  --目前只先针对出货单自动生成条码
+          --单据不存在判断
+              /*SELECT  count(1) into v_recordcount
+              FROM   prodiodetail
+              WHERE  pd_piid=v_pi_id and pd_status=0;
+              IF v_recordcount >0 THEN
+                 v_return_string := '数据错误,单据未过账成功!' ;
+                 RETURN;
+              END IF;
+              --有过一条记录就不给生成
+              select count(1)  into v_recordcount from PRODIOBARCODE where PIB_PIID=v_pi_id;
+               IF v_recordcount >0 THEN                     
+                  RETURN;
+               END IF;*/
+              --修改20170724 根据客户需求如果记录清空,重新生成,以免用户生成之后又修改数据,导致打印不了
+            delete from PRODIOBARCODE where PIB_PIID=v_pi_id;
+            OPEN NR; 
+            LOOP 
+            FETCH NR INTO v_nrddetno,v_nrdname,v_nrdtype,v_nrdsql,v_nrdlength,v_nrcode;
+            IF NR%ROWCOUNT =0 THEN
+               v_getcustrule:=1;
+            END IF;
+            --使用用户指定的规则
+            EXIT WHEN NR%NOTFOUND;
+            IF v_nrdtype='SQL' THEN  --如果是SQL则取出
+                 BEGIN
+                    v_nrdsql:=regexp_replace(v_nrdsql,'{\w+}',''''||v_inoutno||'''');
+                    execute IMMEDIATE  v_nrdsql into v_sqltemp;
+                    v_prefix:=v_prefix || v_sqltemp;
+                    v_suffix:=v_suffix || v_sqltemp;
+                 EXCEPTION
+                 WHEN OTHERS THEN
+                    BEGIN
+                      v_sqltemp:='';
+                      v_prefix:=v_prefix || v_sqltemp;
+                      v_suffix:=v_suffix || v_sqltemp;
+                    END;
+                 END;
+              END IF;
+              IF v_nrdtype='常量' THEN
+                v_prefix :=v_prefix || v_nrdsql;
+                v_suffix :=v_suffix || v_nrdsql;
+              END IF;
+              IF v_nrdtype='流水' THEN
+                --前缀和后缀正常拼接,如果中间含有流水则清除后缀的值,拼接后缀的值
+                v_nrdsql :='';
+                v_serialindex :=v_nrddetno;
+                v_suffix :='';
+                v_v_prefix :=v_prefix;
+                v_seriallen:=v_nrdlength;
+              END IF;
+            END LOOP;
+            CLOSE NR;
+            IF v_getcustrule<>0 THEN
+              OPEN NR_Default; 
+            LOOP 
+            FETCH NR_Default INTO v_nrddetno,v_nrdname,v_nrdtype,v_nrdsql,v_nrdlength,v_nrcode;
+            --使用用户指定的规则
+            EXIT WHEN NR_Default%NOTFOUND;
+            IF v_nrdtype='SQL' THEN  --如果是SQL则取出
+                 BEGIN
+                    v_nrdsql:=regexp_replace(v_nrdsql,'{\w+}',''''||v_inoutno||'''');
+                    execute IMMEDIATE  v_nrdsql into v_sqltemp;
+                    v_prefix:=v_prefix || v_sqltemp;
+                    v_suffix:=v_suffix || v_sqltemp;
+                 EXCEPTION
+                 WHEN OTHERS THEN
+                    BEGIN
+                      v_sqltemp:='';
+                      v_prefix:=v_prefix || v_sqltemp;
+                      v_suffix:=v_suffix || v_sqltemp;
+                    END;
+                 END;
+              END IF;
+              IF v_nrdtype='常量' THEN
+                v_prefix :=v_prefix || v_nrdsql;
+                v_suffix :=v_suffix || v_nrdsql;
+              END IF;
+              IF v_nrdtype='流水' THEN
+                --前缀和后缀正常拼接,如果中间含有流水则清除后缀的值,拼接后缀的值
+                v_nrdsql :='';
+                v_serialindex :=v_nrddetno;
+                v_suffix :='';
+                v_v_prefix :=v_prefix;
+                v_seriallen:=v_nrdlength;
+              END IF;
+            END LOOP;
+            CLOSE NR_Default;
+            END IF;
+            BEGIN 
+               select rmn_maxnumber into v_maxnum from RuleMaxNum  where rmn_nrcode=v_nrcode and rmn_prefix=v_prefix;
+            EXCEPTION 
+            WHEN OTHERS THEN
+              BEGIN
+                v_maxnum:=1;
+                insert into RuleMaxNum(rmn_id,rmn_maxnumber,rmn_nrcode,rmn_prefix)values(RuleMaxNum_seq.nextval,1,v_nrcode,v_prefix);
+              END;
+            END;
+            OPEN c_PDIOBarCur ;
+            LOOP  
+            FETCH c_PDIOBarCur into v_pd_id,v_pd_pdno,v_pd_prodcode,v_pd_outqty,v_pr_zxbzs,v_pd_thisqty,v_pr_id,v_pd_piclass,v_pd_ordercode,v_sa_pocode ;
+            exit when c_PDIOBarCur%NOTFOUND;               
+               -- 查询当前物料的最大的条码和箱号流水
+               select max(pib_barcode) into v_max_barcode from PRODIOBARCODE where pib_piid=v_pi_id and pib_prodcode=v_pd_prodcode;
+
+               --获取该单据的最大箱号(在同一个单据内中盒号是唯一的)
+               select max(to_number(pib_outboxcode1))into v_max_outboxcode  from prodiobarcode where pib_piid=v_pi_id;
+               IF(nvl(v_max_outboxcode,' ')<>' ')THEN 
+                      select max(PIB_PRODCODE),MAX(PIB_CUSTPO) INTO v_max_prodcode,v_max_custpo from prodiobarcode where pib_piid=v_pi_id and pib_outboxcode1=v_max_outboxcode;
+               END IF;
+
+               if(nvl(v_max_barcode,' ')<>' ') then  --计算条码流水                
+                  v_bar_num := to_number(LTRIM(substr(v_max_barcode,-4),'0'))+1;  --截取后四位,去掉前面的0,转成数字+1,可能会抛异常,无法转成数字
+               else 
+                  v_bar_num := 1;
+               end if;
+
+               --出货单最大箱号
+               if(nvl(v_max_outboxcode,' ')<>' ' and (v_max_prodcode=v_pd_prodcode and nvl(v_max_custpo,' ')=nvl(v_sa_pocode,' '))) then   --箱号
+                    v_box_num := to_number(v_max_outboxcode);                
+               else if (nvl(v_max_outboxcode,' ')<>' ') then
+                     v_box_num := to_number(v_max_outboxcode)+1; 
+                   else 
+                     v_box_num := 1;
+                   end if;
+               end if;
+
+               v_barcount := floor(v_pd_thisqty/v_pr_zxbzs);  ---获取最小包装数整数倍的条码个数
+               v_restqty  := v_pd_thisqty - v_barcount*v_pr_zxbzs; -- 取尾数箱条码数量
+               if(v_restqty >0) then 
+                  v_barcount := v_barcount+1;
+               end if ;  
+
+               for i in 1..v_barcount Loop    
+                     --判断一盒是否已经装满 ,循环查询速度很慢
+                      /*select count(1) into v_recordcount from prodiobarcode  where pib_piid=v_pi_id and PIB_OUTBOXCODE1=v_box_num ;--and pib_prodcode<>v_pd_prodcode;
+                      if(v_recordcount=10) then                           
+                            v_box_num := v_box_num+1;                     
+                      end if;*/                  
+                      v_pib_barcode := v_pd_id||'-'||v_pr_id||'-'||trim(to_char(v_bar_num,'0999')); --流水四位   pd_id-pr_id-四位流水(0001) 如  123-2345-0002格式   
+                      select replace(lpad(v_maxnum,v_seriallen),' ','0') into v_maxnum from dual ;                                                      
+                      v_pib_custbarcode := v_v_prefix || v_maxnum || v_suffix;
+                      if(i = v_barcount and v_restqty>0) then  --尾数盒
+                          insert into prodiobarcode(PIB_ID,PIB_PRODCODE,PIB_INDATE,PIB_INOUTNO,PIB_PIID,PIB_PDNO, PIB_PDID,PIB_PICLASS,
+                          PIB_BARCODE,PIB_CUSTBARCODE,PIB_QTY,PIB_PRODID,PIB_OUTBOXCODE1,PIB_IFPRINT,PIB_IFPICK,PIB_ORDERCODE,PIB_CUSTPO)
+                          values(prodiobarcode_seq.nextval,v_pd_prodcode,sysdate,v_p_piinoutno,v_pi_id,v_pd_pdno,v_pd_id,v_pd_piclass,
+                          v_pib_barcode,v_pib_custbarcode,v_restqty,v_pr_id,v_box_num,0,0,v_pd_ordercode,v_sa_pocode); 
+                      else 
+                          insert into prodiobarcode(PIB_ID,PIB_PRODCODE,PIB_INDATE,PIB_INOUTNO,PIB_PIID,PIB_PDNO, PIB_PDID,PIB_PICLASS,
+                          PIB_BARCODE,PIB_CUSTBARCODE,PIB_QTY,PIB_PRODID,PIB_OUTBOXCODE1,PIB_IFPRINT,PIB_IFPICK,PIB_ORDERCODE,PIB_CUSTPO)
+                          values(prodiobarcode_seq.nextval,v_pd_prodcode,sysdate,v_p_piinoutno,v_pi_id,v_pd_pdno,v_pd_id,v_pd_piclass,
+                          v_pib_barcode,v_pib_custbarcode,v_pr_zxbzs,v_pr_id,v_box_num,0,0,v_pd_ordercode,v_sa_pocode);
+                      end if;
+
+                      if(MOD(i,10) = 0 and i<>v_barcount)then  --箱号加1
+                         v_box_num := v_box_num+1;
+                      end if;                       
+                      v_bar_num := v_bar_num+1 ; --条码号加1
+                      v_maxnum := v_maxnum+1;
+                end loop;              
+            END LOOP;
+            <<Exitlabel>>
+            CLOSE c_PDIOBarCur;           
+            update RuleMaxNum set rmn_maxnumber=v_maxnum where rmn_nrcode=v_nrcode and rmn_prefix=v_prefix;
+            --记录操作日志
+            insert into messagelog (ml_id,ml_date,ml_man,ml_content,ml_result,ml_search)
+            values(messagelog_seq.nextval,sysdate,v_p_commitname,'过账自动生成条码','生成条码成功','ProdInOut!Sale|pi_id='||v_pi_id);       
+        END IF;      
+   EXCEPTION
+      WHEN OTHERS THEN
+      V_ERRORMSG :=SQLERRM || dbms_utility.format_error_backtrace();
+   END;
+
+/*自定义代码,根据不同客户进行页面设置*/
+create or replace PROCEDURE sp_custinit(
+  KeyValue in varchar2,
+  content out varchar2
+)as
+begin
+declare 
+  v_custcode varchar2(20);
+  begin
+    select pi_cardcode into v_custcode from prodinout where pi_id=KeyValue;
+      content:='
+using System; 
+ using System.Windows.Forms; 
+namespace CustInitSpace 
+{    public class CustInitClass
+    {
+        public void CustInit()  
+        {
+          Form f=Form.ActiveForm; 
+          if(f.Controls["cu_code"].Text=="C000027")
+          {
+             (f.Controls["OutBoxLabel"].Controls["DiffCustOutBoxCode"] as CheckBox).Checked = false;
+          }else
+          {
+            (f.Controls["OutBoxLabel"].Controls["DiffCustOutBoxCode"] as CheckBox).Checked = true;
+          }
+        }
+    }
+}';
+  end;
+end;
+
+
+/*获取数据页数据的SQL*/
+create or replace PROCEDURE sp_getDataSql(
+  v_inoutno in varchar2,
+  v_text in varchar2,
+  v_sql out varchar2
+)as 
+begin
+  v_sql:='select' ||v_text|| ' from  prodinout left join prodiodetail 
+  on pi_id=pd_piid left join chip_in_out on io_piid=pi_id and pd_id=io_pdid left join chip on ch_code=io_chipcode left join CHIP_WAFERTEST_VIEW on ch_code=chw_chipcode 
+  left join CHIP_EDCDATA_VIEW on che_chipcode=ch_code left join product on pr_code=pd_prodcode left join prodiobarcode on 
+  pib_piid=pi_id and pib_custbarcode=ch_code where pi_inoutno='''||v_inoutno||''' order by ch_code';
+end;

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

@@ -241,6 +241,12 @@
     </Compile>
     <Compile Include="Entity\SystemInf.cs" />
     <Compile Include="Entity\User.cs" />
+    <Compile Include="ExportColumns.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="ExportColumns.Designer.cs">
+      <DependentUpon>ExportColumns.cs</DependentUpon>
+    </Compile>
     <Compile Include="ExportExcel.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -367,6 +373,9 @@
     <EmbeddedResource Include="DbFind.resx">
       <DependentUpon>DbFind.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="ExportColumns.resx">
+      <DependentUpon>ExportColumns.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="ExportExcel.resx">
       <DependentUpon>ExportExcel.cs</DependentUpon>
     </EmbeddedResource>
@@ -808,6 +817,7 @@
       <Generator>WCF Proxy Generator</Generator>
       <LastGenOutput>Reference.cs</LastGenOutput>
     </None>
+    <Content Include="SQL\SQL.txt" />
     <Content Include="tool\Analysis.dll" />
     <Content Include="tool\DataHelper.dll" />
     <Content Include="tool\NPOI.dll" />

+ 1 - 19
UAS-出货标签管理(贸易版)/UAS_出货标签管理.Designer.cs

@@ -95,11 +95,9 @@
             this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
             this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
             this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
-            this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
             this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem();
             this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripMenuItem();
             this.下载模板ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
-            this.客户合并规则ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.流水调整ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.ImportExcel = new System.Windows.Forms.OpenFileDialog();
             this.pi_class = new System.Windows.Forms.Label();
@@ -775,15 +773,13 @@
             this.toolStripMenuItem1,
             this.toolStripMenuItem2,
             this.toolStripMenuItem3,
-            this.toolStripMenuItem4,
             this.toolStripMenuItem5,
             this.toolStripMenuItem6,
             this.下载模板ToolStripMenuItem,
-            this.客户合并规则ToolStripMenuItem,
             this.流水调整ToolStripMenuItem});
             this.Menu.Name = "Menu";
             this.Menu.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;
-            this.Menu.Size = new System.Drawing.Size(149, 202);
+            this.Menu.Size = new System.Drawing.Size(149, 158);
             this.Menu.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.Menu_ItemClicked);
             // 
             // toolStripMenuItem1
@@ -804,12 +800,6 @@
             this.toolStripMenuItem3.Size = new System.Drawing.Size(148, 22);
             this.toolStripMenuItem3.Text = "导出数据";
             // 
-            // toolStripMenuItem4
-            // 
-            this.toolStripMenuItem4.Name = "toolStripMenuItem4";
-            this.toolStripMenuItem4.Size = new System.Drawing.Size(148, 22);
-            this.toolStripMenuItem4.Text = "权限设置";
-            // 
             // toolStripMenuItem5
             // 
             this.toolStripMenuItem5.Name = "toolStripMenuItem5";
@@ -828,12 +818,6 @@
             this.下载模板ToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
             this.下载模板ToolStripMenuItem.Text = "下载模板";
             // 
-            // 客户合并规则ToolStripMenuItem
-            // 
-            this.客户合并规则ToolStripMenuItem.Name = "客户合并规则ToolStripMenuItem";
-            this.客户合并规则ToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
-            this.客户合并规则ToolStripMenuItem.Text = "客户合并规则";
-            // 
             // 流水调整ToolStripMenuItem
             // 
             this.流水调整ToolStripMenuItem.Name = "流水调整ToolStripMenuItem";
@@ -2200,7 +2184,6 @@
         private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
         private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
         private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3;
-        private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4;
         private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem5;
         private System.Windows.Forms.OpenFileDialog ImportExcel;
         private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem6;
@@ -2211,7 +2194,6 @@
         private System.Windows.Forms.CheckBox cu_print_outdc;
         private System.Windows.Forms.CheckBox cu_print_outlotno;
         private System.Windows.Forms.CheckBox cu_print_outpo;
-        private System.Windows.Forms.ToolStripMenuItem 客户合并规则ToolStripMenuItem;
         private System.Windows.Forms.Button CustBarCode;
         private System.Windows.Forms.ToolStripMenuItem 流水调整ToolStripMenuItem;
         private System.Windows.Forms.Button GetMidBoxCode;

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

@@ -105,7 +105,7 @@ namespace UAS_LabelMachine
         /// </summary>
         LabelFormatDocument MidFormat;
         /// <summary>
-        /// BarTender外箱
+        /// BarTender外箱 
         /// </summary>
         LabelFormatDocument OutFormat;
 
@@ -172,27 +172,6 @@ namespace UAS_LabelMachine
             PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
             pi.SetValue(this.LabelInf, true, null);
             Text = Text + "-" + Master;
-            InitCustView();
-        }
-
-        public void InitCustView()
-        {
-            switch (SystemInf.Master)
-            {
-                case "N_HC":
-                    DiffCustOutBoxCode.Checked = true;
-                    break;
-                case "SZSI_TEST":
-                    BaseUtil.SetControlsVisible(pib_year, pib_month, pib_day, pib_custoutboxcode);
-                    pib_custbarcode.HeaderText = "芯片号";
-                    break;
-                case "SZSI":
-                    BaseUtil.SetControlsVisible(pib_year, pib_month, pib_day, pib_custoutboxcode);
-                    pib_custbarcode.HeaderText = "芯片号";
-                    break;
-                default:
-                    break;
-            }
         }
 
         protected override void WndProc(ref System.Windows.Forms.Message m)
@@ -1223,6 +1202,7 @@ namespace UAS_LabelMachine
                     stw = new SetLoadingWindow(thread, "正在获取打印标签");
                     BaseUtil.SetFormCenter(stw);
                     stw.ShowDialog();
+                    LogicHandler.CustInit(PI_ID);
                     //重置采集项次
                     LogManager.DoLog("输入单号【" + pi_inoutno.Text + "】");
                 }
@@ -1586,27 +1566,29 @@ namespace UAS_LabelMachine
                         {
                             GetCustRule();
                             string custoutboxcode = LogicHandler.BarcodeMethod1(Prefix, Suffix, SerialNumIndex, SerialNumLength, Radix);
+                            string updateCondition = "";
                             //勾选了这些参数并且打印的时候需要才进行更新
                             if (cu_print_outprod.Checked && dt.Columns.Contains("pd_custprodcode"))
                             {
-                                dh.ExecuteSql("update prodiobarcode set pib_custoutboxcode='" + custoutboxcode + "' where pib_id in(select pib_id from prodiobarcode left join prodinout on pib_inoutno=pi_inoutno left join prodiodetail on pd_piid=pi_id and pib_prodcode=pd_prodcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + pib_outboxcode2 + "' and pd_custprodcode='" + dt.Rows[i]["pd_custprodcode"].ToString() + "')", "update");
+                                updateCondition += " and pd_custprodcode='" + dt.Rows[i]["pd_custprodcode"].ToString() + "'";
                             }
                             if (cu_print_outpo.Checked && dt.Columns.Contains("pd_pocode"))
                             {
-                                dh.ExecuteSql("update prodiobarcode set pib_custoutboxcode='" + custoutboxcode + "' where pib_id in(select pib_id from prodiobarcode left join prodinout on pib_inoutno=pi_inoutno left join prodiodetail on pd_piid=pi_id and pib_prodcode=pd_prodcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + pib_outboxcode2 + "' and pd_pocode='" + dt.Rows[i]["pd_pocode"].ToString() + "')", "update");
+                                updateCondition += " and pd_pocode='" + dt.Rows[i]["pd_pocode"].ToString() + "'";
                             }
                             if (cu_print_ordercode.Checked && dt.Columns.Contains("pd_ordercode"))
                             {
-                                dh.ExecuteSql("update prodiobarcode set pib_custoutboxcode='" + custoutboxcode + "' where pib_id in(select pib_id from prodiobarcode left join prodinout on pib_inoutno=pi_inoutno left join prodiodetail on pd_piid=pi_id and pib_prodcode=pd_prodcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + pib_outboxcode2 + "' and pd_ordercode='" + dt.Rows[i]["pd_ordercode"].ToString() + "')", "update");
+                                updateCondition += " and pd_ordercode='" + dt.Rows[i]["pd_ordercode"].ToString() + "'";
                             }
                             if (cu_print_outdc.Checked && dt.Columns.Contains("pib_datecode"))
                             {
-                                dh.ExecuteSql("update prodiobarcode set pib_custoutboxcode='" + custoutboxcode + "' where pib_id in(select pib_id from prodiobarcode left join prodinout on pib_inoutno=pi_inoutno left join prodiodetail on pd_piid=pi_id and pib_prodcode=pd_prodcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + pib_outboxcode2 + "' and pib_datecode='" + dt.Rows[i]["pib_datecode"].ToString() + "')", "update");
+                                updateCondition += " and pib_datecode='" + dt.Rows[i]["pib_datecode"].ToString() + "'";
                             }
                             if (cu_print_outlotno.Checked && dt.Columns.Contains("pib_lotno"))
                             {
-                                dh.ExecuteSql("update prodiobarcode set pib_custoutboxcode='" + custoutboxcode + "' where pib_id in(select pib_id from prodiobarcode left join prodinout on pib_inoutno=pi_inoutno left join prodiodetail on pd_piid=pi_id and pib_prodcode=pd_prodcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + pib_outboxcode2 + "' and pib_lotno='" + dt.Rows[i]["pib_lotno"].ToString() + "')", "update");
+                                updateCondition += " and pib_lotno='" + dt.Rows[i]["pib_lotno"].ToString() + "'";
                             }
+                            dh.ExecuteSql("update prodiobarcode set pib_custoutboxcode='" + custoutboxcode + "' where pib_id in(select pib_id from prodiobarcode left join prodinout on pib_inoutno=pi_inoutno left join prodiodetail on pd_piid=pi_id and pib_prodcode=pd_prodcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + pib_outboxcode2 + "' "+ updateCondition + " )", "update");
                             dh.UpdateByCondition("RuleMaxNum", "rmn_maxnumber='" + custserialnum + "'", "rmn_nrcode='" + NrCode + "' and rmn_prefix='" + Prefix + "'");
                         }
                     }
@@ -1750,7 +1732,7 @@ namespace UAS_LabelMachine
                 sdh.BatchInsert("prodiobarcode", LabelInfDataTable);
             }
             sql.Clear();
-            sql.Append("select * from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by pib_id");
+            sql.Append("select * from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "'");
             LabelInfDataTable = (DataTable)sdh.ExecuteSql(sql.ToString(), "select");
             bindingsource(LabelInf, LabelInfDataTable);
             //有数据的话默认取第一条的品牌去取采集策略
@@ -2383,6 +2365,7 @@ namespace UAS_LabelMachine
                     break;
                 case "导出数据":
                     ExportExcel ex = new ExportExcel(pi_inoutno.Text);
+                    ex.FormClosed += Ex_FormClosed;
                     switch (SystemInf.Master)
                     {
                         case "SZSI_TEST":
@@ -2486,6 +2469,11 @@ namespace UAS_LabelMachine
             }
         }
 
+        private void Ex_FormClosed(object sender, FormClosedEventArgs e)
+        {
+            LoadGridData(false);
+        }
+
         private void Att_FormClosed(object sender, FormClosedEventArgs e)
         {
             Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql from LabelAttachPARAMETER where lap_custcode='" + cu_code.Text + "'", "select");

+ 15 - 3
UAS_PRINT/Form2.Designer.cs

@@ -34,6 +34,7 @@
             this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
             this.打开根目录ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.退出ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.FTPtoolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.contextMenuStrip1.SuspendLayout();
             this.SuspendLayout();
             // 
@@ -48,24 +49,34 @@
             // 
             this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.打开根目录ToolStripMenuItem,
+            this.FTPtoolStripMenuItem,
             this.退出ToolStripMenuItem});
             this.contextMenuStrip1.Name = "contextMenuStrip1";
-            this.contextMenuStrip1.Size = new System.Drawing.Size(137, 48);
+            this.contextMenuStrip1.ShowCheckMargin = true;
+            this.contextMenuStrip1.Size = new System.Drawing.Size(175, 92);
             // 
             // 打开根目录ToolStripMenuItem
             // 
             this.打开根目录ToolStripMenuItem.Name = "打开根目录ToolStripMenuItem";
-            this.打开根目录ToolStripMenuItem.Size = new System.Drawing.Size(136, 22);
+            this.打开根目录ToolStripMenuItem.Size = new System.Drawing.Size(174, 22);
             this.打开根目录ToolStripMenuItem.Text = "打开根目录";
             this.打开根目录ToolStripMenuItem.Click += new System.EventHandler(this.打开根目录ToolStripMenuItem_Click);
             // 
             // 退出ToolStripMenuItem
             // 
             this.退出ToolStripMenuItem.Name = "退出ToolStripMenuItem";
-            this.退出ToolStripMenuItem.Size = new System.Drawing.Size(136, 22);
+            this.退出ToolStripMenuItem.Size = new System.Drawing.Size(174, 22);
             this.退出ToolStripMenuItem.Text = "退出";
             this.退出ToolStripMenuItem.Click += new System.EventHandler(this.退出ToolStripMenuItem_Click);
             // 
+            // FTPtoolStripMenuItem
+            // 
+            this.FTPtoolStripMenuItem.CheckOnClick = true;
+            this.FTPtoolStripMenuItem.Name = "FTPtoolStripMenuItem";
+            this.FTPtoolStripMenuItem.Size = new System.Drawing.Size(174, 22);
+            this.FTPtoolStripMenuItem.Text = "是否启动FTP";
+            this.FTPtoolStripMenuItem.Click += new System.EventHandler(this.FTPtoolStripMenuItem_Click);
+            // 
             // Form2
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -89,5 +100,6 @@
         private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
         private System.Windows.Forms.ToolStripMenuItem 退出ToolStripMenuItem;
         private System.Windows.Forms.ToolStripMenuItem 打开根目录ToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem FTPtoolStripMenuItem;
     }
 }

+ 9 - 1
UAS_PRINT/Form2.cs

@@ -12,6 +12,7 @@ using System.Net;
 using System.Text;
 using System.Threading;
 using System.Windows.Forms;
+using UAS_PRINT.Properties;
 
 namespace UAS_PRINT
 {
@@ -21,7 +22,6 @@ namespace UAS_PRINT
         {
             InitializeComponent();
         }
-
         private static HttpListener httpPostRequest = new HttpListener();
         private Thread ThrednHttpPostRequest;
         private void Form2_Load(object sender, EventArgs e)
@@ -39,6 +39,8 @@ namespace UAS_PRINT
             ThrednHttpPostRequest.Start();
             提示.ShowBalloonTip(30, "提示", "程序启动", ToolTipIcon.Info);
 
+            FTPtoolStripMenuItem.Checked = Settings.Default.ifuseftp;
+
             //string req = File.ReadAllText(@"C:\Users\Hcsy\Documents\Tencent Files\814802334\FileRecv\4.txt", Encoding.UTF8);
             //if (req.Contains("\"" + "chooseprintername" + "\""))
             //{
@@ -182,5 +184,11 @@ namespace UAS_PRINT
         {
             Visible = false;
         }
+
+        private void FTPtoolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            Settings.Default.ifuseftp = FTPtoolStripMenuItem.Checked;
+            Settings.Default.Save();
+        }
     }
 }

+ 14 - 0
UAS_PRINT/PrintHandler.cs

@@ -8,6 +8,7 @@ using System.Text;
 using System.Text.RegularExpressions;
 using System.Windows.Forms;
 using System.Drawing.Printing;
+using UAS_PRINT.Properties;
 
 namespace UAS_PRINT
 {
@@ -18,6 +19,7 @@ namespace UAS_PRINT
         static List<Bitmap> bitmaps = new List<Bitmap>();
         static DataTable dt = new DataTable();
      
+
         public static void zplprint(string str, string PrinterName)
         {
             Dictionary<string, object> data = PrintHelper.ToDictionary(str);
@@ -116,6 +118,18 @@ namespace UAS_PRINT
                 MessageBox.Show("未获取到标签名称,请联系管理员进行处理", "提示");
                 return;
             }
+            if (Settings.Default.ifuseftp)
+            {
+                ftpOperater frp = new ftpOperater(true);
+                try
+                {
+                    frp.Download(label_name + ".frx", DateTime.Now);
+                }
+                catch (Exception ex)
+                {
+                    MessageBox.Show("标签文件更新失败" + ex.Message);
+                }
+            }
             try
             {
                 Report.Load(System.AppDomain.CurrentDomain.BaseDirectory + label_name+".frx");

+ 61 - 17
UAS_PRINT/Properties/Settings.Designer.cs

@@ -1,30 +1,74 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
-//     This code was generated by a tool.
-//     Runtime Version:4.0.30319.42000
+//     此代码由工具生成。
+//     运行时版本:4.0.30319.42000
 //
-//     Changes to this file may cause incorrect behavior and will be lost if
-//     the code is regenerated.
+//     对此文件的更改可能会导致不正确的行为,并且如果
+//     重新生成代码,这些更改将会丢失。
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-namespace UAS_PRINT.Properties
-{
-
-
+namespace UAS_PRINT.Properties {
+    
+    
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
-    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
-    {
-
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+        
         private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
-        public static Settings Default
-        {
-            get
-            {
+        
+        public static Settings Default {
+            get {
                 return defaultInstance;
             }
         }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("ftp://172.16.0.20")]
+        public string ftpaddress {
+            get {
+                return ((string)(this["ftpaddress"]));
+            }
+            set {
+                this["ftpaddress"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("vsftpd")]
+        public string ftpuser {
+            get {
+                return ((string)(this["ftpuser"]));
+            }
+            set {
+                this["ftpuser"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("shenaftp")]
+        public string ftppassword {
+            get {
+                return ((string)(this["ftppassword"]));
+            }
+            set {
+                this["ftppassword"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]
+        public bool ifuseftp {
+            get {
+                return ((bool)(this["ifuseftp"]));
+            }
+            set {
+                this["ifuseftp"] = value;
+            }
+        }
     }
 }

+ 17 - 6
UAS_PRINT/Properties/Settings.settings

@@ -1,7 +1,18 @@
 <?xml version='1.0' encoding='utf-8'?>
-<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
-  <Profiles>
-    <Profile Name="(Default)" />
-  </Profiles>
-  <Settings />
-</SettingsFile>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="UAS_PRINT.Properties" GeneratedClassName="Settings">
+  <Profiles />
+  <Settings>
+    <Setting Name="ftpaddress" Type="System.String" Scope="User">
+      <Value Profile="(Default)">ftp://172.16.0.20</Value>
+    </Setting>
+    <Setting Name="ftpuser" Type="System.String" Scope="User">
+      <Value Profile="(Default)">vsftpd</Value>
+    </Setting>
+    <Setting Name="ftppassword" Type="System.String" Scope="User">
+      <Value Profile="(Default)">shenaftp</Value>
+    </Setting>
+    <Setting Name="ifuseftp" Type="System.Boolean" Scope="User">
+      <Value Profile="(Default)">False</Value>
+    </Setting>
+  </Settings>
+</SettingsFile>

+ 28 - 0
UAS_PRINT/Settings.cs

@@ -0,0 +1,28 @@
+namespace UAS_PRINT.Properties {
+    
+    
+    // 通过此类可以处理设置类的特定事件: 
+    //  在更改某个设置的值之前将引发 SettingChanging 事件。
+    //  在更改某个设置的值之后将引发 PropertyChanged 事件。
+    //  在加载设置值之后将引发 SettingsLoaded 事件。
+    //  在保存设置值之前将引发 SettingsSaving 事件。
+    internal sealed partial class Settings {
+        
+        public Settings() {
+            // // 若要为保存和更改设置添加事件处理程序,请取消注释下列行: 
+            //
+            // this.SettingChanging += this.SettingChangingEventHandler;
+            //
+            // this.SettingsSaving += this.SettingsSavingEventHandler;
+            //
+        }
+        
+        private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
+            // 在此处添加用于处理 SettingChangingEvent 事件的代码。
+        }
+        
+        private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
+            // 在此处添加用于处理 SettingsSaving 事件的代码。
+        }
+    }
+}

+ 3 - 0
UAS_PRINT/UAS_PRINT.csproj

@@ -69,6 +69,7 @@
     <Compile Include="Form2.Designer.cs">
       <DependentUpon>Form2.cs</DependentUpon>
     </Compile>
+    <Compile Include="ftpOperater.cs" />
     <Compile Include="PrinterList.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -79,6 +80,7 @@
     <Compile Include="PrintHelper.cs" />
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Settings.cs" />
     <EmbeddedResource Include="Form2.resx">
       <DependentUpon>Form2.cs</DependentUpon>
     </EmbeddedResource>
@@ -94,6 +96,7 @@
       <AutoGen>True</AutoGen>
       <DependentUpon>Resources.resx</DependentUpon>
     </Compile>
+    <None Include="app.config" />
     <None Include="packages.config" />
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>

+ 24 - 0
UAS_PRINT/app.config

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <configSections>
+        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
+            <section name="UAS_PRINT.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
+        </sectionGroup>
+    </configSections>
+    <userSettings>
+        <UAS_PRINT.Properties.Settings>
+            <setting name="ftpaddress" serializeAs="String">
+                <value>ftp://172.16.0.20</value>
+            </setting>
+            <setting name="ftpuser" serializeAs="String">
+                <value>vsftpd</value>
+            </setting>
+            <setting name="ftppassword" serializeAs="String">
+                <value>shenaftp</value>
+            </setting>
+            <setting name="ifuseftp" serializeAs="String">
+                <value>False</value>
+            </setting>
+        </UAS_PRINT.Properties.Settings>
+    </userSettings>
+</configuration>

+ 190 - 0
UAS_PRINT/ftpOperater.cs

@@ -0,0 +1,190 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Windows.Forms;
+using UAS_PRINT.Properties;
+
+namespace UAS_PRINT
+{
+    class ftpOperater
+    {
+       // public static string FTPAddress = "ftp://172.16.0.20|vsftpd|shenaftp";
+
+        public static bool Inner = false;
+
+        public static string DownLoadTo = AppDomain.CurrentDomain.BaseDirectory;
+
+        private string ftpServerIP;
+        private string ftpUser;
+        private string ftpPwd;
+
+        public ftpOperater(bool PortModel)
+        {
+            //if (!Inner)
+            //{
+            //    FTPInf = FTPAddress.Split('|');
+            //}
+            //else
+            //{
+            //    FTPInf = FTPAddress.Split('|');
+            //}
+
+            this.ftpServerIP = Settings.Default.ftpaddress;
+            this.ftpUser = Settings.Default.ftpuser;
+            this.ftpPwd = Settings.Default.ftppassword;
+        } 
+
+        public void UpLoadFile(string filepath, string filename)
+        {
+            //上传之前判断文件是否存在
+            string[] filelist = GetFileList();
+            if (filelist != null)
+                for (int i = 0; i < filelist.Length; i++)
+                {
+                    if (filelist[i] == filename)
+                    {
+                        //string upload = MessageBox.Show("已存在同名文件,是否覆盖", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
+                        //if (upload.ToString() != "Yes")
+                        //{
+                        //    return;
+                        //}
+                    }
+                }
+            FtpWebRequest reqFTP;
+            reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + "/" + filename));
+            reqFTP.UseBinary = true;
+            reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
+            reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
+            FileInfo file = new FileInfo(filepath + "/" + filename);
+            const int BufferSize = 2048;
+            byte[] content = new byte[BufferSize - 1 + 1];
+            int dataRead;
+            using (FileStream fs = file.OpenRead())
+            {
+                //把上传的文件写入流
+                using (Stream rs = reqFTP.GetRequestStream())
+                {
+                    do
+                    {
+                        //每次读文件流的2KB
+                        dataRead = fs.Read(content, 0, BufferSize);
+                        rs.Write(content, 0, dataRead);
+                    } while (!(dataRead < BufferSize));
+                    rs.Close();
+                }
+                fs.Close();
+            }
+        }
+
+        /// <summary>
+        /// 获取ftp服务器上的文件信息
+        /// </summary>
+        /// <returns>存储了所有文件信息的字符串数组</returns>
+        public string[] GetFileList()
+        {
+            string[] downloadFiles;
+            StringBuilder result = new StringBuilder();
+            FtpWebRequest reqFTP;
+            try
+            {
+                reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + "/"));
+                reqFTP.UseBinary = true;
+                reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
+                reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
+                WebResponse response = reqFTP.GetResponse();
+                StreamReader reader = new StreamReader(response.GetResponseStream());
+
+                string line = reader.ReadLine();
+                while (line != null)
+                {
+                    result.Append(line);
+                    result.Append("\n");
+                    line = reader.ReadLine();
+                }
+                result.Remove(result.ToString().LastIndexOf('\n'), 1);
+                reader.Close();
+                response.Close();
+
+                return result.ToString().Split('\n');
+            }
+            catch (Exception ex)
+            {
+                System.Windows.Forms.MessageBox.Show("获取文件信息失败:" + ex.Message, "操作失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                downloadFiles = null;
+                return downloadFiles;
+            }
+        }
+
+        /// <summary>
+        /// 获取FTP上指定文件的大小
+        /// </summary>
+        /// <param name="filename">文件名</param>
+        /// <returns>文件大小</returns>
+        public long GetFileSize(string filename)
+        {
+            FtpWebRequest reqFTP;
+            long fileSize = 0;
+            try
+            {
+                reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + "/" + filename));
+                reqFTP.Method = WebRequestMethods.Ftp.GetFileSize;
+                reqFTP.UseBinary = true;
+                reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
+                FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
+                Stream ftpStream = response.GetResponseStream();
+                fileSize = response.ContentLength;
+                ftpStream.Close();
+                response.Close();
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show("获取文件大小时,出现异常:\n" + ex.Message, "获取文件大小失败!", MessageBoxButtons.OK, MessageBoxIcon.Error);
+            }
+            return fileSize;
+        }
+
+        /// <summary>
+        /// 实现ftp下载操作
+        /// </summary>
+        /// <param name="fileName">远程文件名</param>
+        public string Download(string fileName, DateTime time)
+        {
+            FtpWebRequest reqFTP;
+            try
+            {
+                FileStream outputStream = new FileStream(DownLoadTo + @"\" + fileName, FileMode.Create);
+                reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + "/" + fileName));
+                reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
+                reqFTP.UseBinary = true;
+                reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
+                FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
+                Stream ftpStream = response.GetResponseStream();
+                long cl = response.ContentLength;
+                int bufferSize = 4096;
+                int readCount;
+                byte[] buffer = new byte[bufferSize];
+                readCount = ftpStream.Read(buffer, 0, bufferSize);
+                while (readCount > 0)
+                {
+                    outputStream.Write(buffer, 0, readCount);
+                    readCount = ftpStream.Read(buffer, 0, bufferSize);
+                }
+                ftpStream.Close();
+                outputStream.Close();
+                response.Close();
+                //设置最后修改文件时间为服务器时间
+                FileInfo f = new FileInfo(DownLoadTo + @"\" + fileName);
+                f.LastWriteTime = time;
+                return DownLoadTo + @"\" + fileName;
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);
+                return "";
+            }
+        }
+    }
+}