Browse Source

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

caosy 6 years ago
parent
commit
8e6743906c

+ 1 - 1
UAS-出货标签管理(吉利通)/CustomControl/BlurSearch.cs

@@ -214,7 +214,7 @@ namespace UAS_LabelMachine.CustomControl
                 con = Field1 + " like '%" + EnterTextBox.Text + "%' and rownum<=10 and " + condition;
             }
             dt = dh.getFieldsDatasByCondition(TableName1, new string[] { Field1, valueField, "rownum" }, con.ToUpper());
-            if (dt.Rows.Count > 0)
+            if (dt.Rows.Count > 0 && EnterTextBox.Text != "")
             {
                 ListBox.Items.Clear();
                 for (int i = 0; i < dt.Rows.Count; i++)

+ 4 - 5
UAS-出货标签管理(吉利通)/CustomControl/PrinterCombox.Designer.cs

@@ -37,19 +37,18 @@
             this.PrinterList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
             this.PrinterList.FormattingEnabled = true;
             this.PrinterList.Location = new System.Drawing.Point(0, 0);
-            this.PrinterList.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.PrinterList.Name = "PrinterList";
-            this.PrinterList.Size = new System.Drawing.Size(284, 26);
+            this.PrinterList.Size = new System.Drawing.Size(189, 20);
             this.PrinterList.TabIndex = 0;
+            this.PrinterList.SelectedIndexChanged += new System.EventHandler(this.PrinterList_SelectedIndexChanged);
             // 
             // PrinterCombox
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.Controls.Add(this.PrinterList);
-            this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.Name = "PrinterCombox";
-            this.Size = new System.Drawing.Size(284, 28);
+            this.Size = new System.Drawing.Size(189, 19);
             this.Load += new System.EventHandler(this.PrinterCombox_Load);
             this.ResumeLayout(false);
 

+ 13 - 2
UAS-出货标签管理(吉利通)/CustomControl/PrinterCombox.cs

@@ -16,12 +16,15 @@ namespace UAS_LabelMachine.CustomControl
         {
             InitializeComponent();
         }
+        public delegate void OnSelectIndexChange(object sender, EventArgs e);
+
+        public event OnSelectIndexChange UserOnSelectIndexChange;
 
         public override string Text
         {
             get
             {
-                return PrinterList.Text; 
+                return PrinterList.Text;
             }
 
             set
@@ -30,17 +33,25 @@ namespace UAS_LabelMachine.CustomControl
             }
         }
 
+        bool Loading = true;
+
         private void PrinterCombox_Load(object sender, EventArgs e)
         {
             PrintDocument print = new PrintDocument();
             string sDefault = print.PrinterSettings.PrinterName;//默认打印机名
-
             foreach (string sPrint in PrinterSettings.InstalledPrinters)//获取所有打印机名称
             {
                 PrinterList.Items.Add(sPrint);
                 if (sPrint == sDefault)
                     PrinterList.SelectedIndex = PrinterList.Items.IndexOf(sPrint);
             }
+            Loading = false;
+        }
+
+        private void PrinterList_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            if(!Loading)
+            UserOnSelectIndexChange.Invoke(sender, e);
         }
     }
 }

+ 63 - 41
UAS-出货标签管理(吉利通)/PublicMethod/DataHelper.cs

@@ -844,20 +844,63 @@ namespace UAS_LabelMachine
             switch (Type.ToUpper())
             {
                 case "SELECT":
-                    result = new DataTable();
-                    OracleDataAdapter ad = new OracleDataAdapter(command);
-                    ad.Fill((DataTable)result);
-                    ad.Dispose();
+                    try
+                    {
+                        result = new DataTable();
+                        OracleDataAdapter ad = new OracleDataAdapter(command);
+                        ad.Fill((DataTable)result);
+                        ad.Dispose();
+                    }
+                    catch (Exception)
+                    {
+                        connection = new OracleConnection(DBConnectionString);
+                        connection.Open();
+                        command.Connection = connection;
+                        result = new DataTable();
+                        OracleDataAdapter ad = new OracleDataAdapter(command);
+                        ad.Fill((DataTable)result);
+                        ad.Dispose();
+                    }
                     //成功执行后将重复连接数置为0
                     break;
                 case "DELETE":
-                    result = command.ExecuteNonQuery();
+                    try
+                    {
+                        result = command.ExecuteNonQuery();
+                    }
+                    catch (Exception)
+                    {
+                        connection = new OracleConnection(DBConnectionString);
+                        connection.Open();
+                        command.Connection = connection;
+                        command.ExecuteNonQuery();
+                    }
                     break;
                 case "UPDATE":
-                    result = command.ExecuteNonQuery();
+                    try
+                    {
+                        result = command.ExecuteNonQuery();
+                    }
+                    catch (Exception)
+                    {
+                        connection = new OracleConnection(DBConnectionString);
+                        connection.Open();
+                        command.Connection = connection;
+                        command.ExecuteNonQuery();
+                    }
                     break;
                 case "INSERT":
-                    command.ExecuteNonQuery();
+                    try
+                    {
+                        result = command.ExecuteNonQuery();
+                    }
+                    catch (Exception)
+                    {
+                        connection = new OracleConnection(DBConnectionString);
+                        connection.Open();
+                        command.Connection = connection;
+                        command.ExecuteNonQuery();
+                    }
                     break;
             }
 
@@ -865,31 +908,6 @@ namespace UAS_LabelMachine
             return result;
         }
 
-        /// <summary>
-        /// 为了同步BS端的条码维护,检测时允许问号的存在,在检测时默认将问号换成:Param参数
-        /// </summary>
-        /// <param name="SQL"></param>
-        public bool CheckSQL(string SQL, out string ErrorMessage)
-        {
-            ErrorMessage = "";
-            try
-            {
-                SQL = SQL.Replace("?", ":Param");
-                command = new OracleCommand(SQL, connection);
-                command.ExecuteNonQuery();
-                command.Dispose();
-                return true;
-            }
-            catch (Exception e)
-            {
-                command.Dispose();
-                ErrorMessage = e.Message;
-                return false;
-            }
-        }
-
-
-
         public int GetDistinctRowCount(string TableName, string Field)
         {
             DataTable dt = new DataTable();
@@ -981,8 +999,9 @@ namespace UAS_LabelMachine
             }
             catch (Exception)
             {
-                command.Connection = new OracleConnection(DBConnectionString);
-                command.Connection.Open();
+                connection= new OracleConnection(DBConnectionString);
+                connection.Open();
+                command.Connection = connection;
                 command.ExecuteNonQuery();
             }
             command.Dispose();
@@ -1120,13 +1139,14 @@ namespace UAS_LabelMachine
             }
             catch (Exception)
             {
-                command.Connection = new OracleConnection(DBConnectionString);
-                command.Connection.Open();
+                connection = new OracleConnection(DBConnectionString);
+                connection.Open();
+                command.Connection = connection;
                 command.ExecuteNonQuery();
             }
             command.Dispose();
         }
-
+        int count = 0;
         /// <summary>
         /// 调用存储过程
         /// </summary>
@@ -1146,8 +1166,9 @@ namespace UAS_LabelMachine
             }
             catch (Exception)
             {
-                command.Connection = new OracleConnection(DBConnectionString);
-                command.Connection.Open();
+                connection = new OracleConnection(DBConnectionString);
+                connection.Open();
+                command.Connection = connection;
                 command.ExecuteNonQuery();
             }
             for (int i = 0; i < command.Parameters.Count; i++)
@@ -1174,8 +1195,9 @@ namespace UAS_LabelMachine
             }
             catch (Exception)
             {
-                command.Connection = new OracleConnection(DBConnectionString);
-                command.Connection.Open();
+                 connection = new OracleConnection(DBConnectionString);
+                connection.Open();
+                command.Connection = connection;
                 command.ExecuteNonQuery();
             }
             command.Dispose();

+ 1 - 29
UAS-出货标签管理(吉利通)/PublicMethod/SqliteDBHelper.cs

@@ -515,38 +515,11 @@ namespace UAS_LabelMachine
         /// <param name="SQL"></param>
         /// <param name="Type"></param>
         /// <returns></returns>
-        public object ExecuteSql(string SQL, string Type, params object[] names)
+        public object ExecuteSql(string SQL, string Type)
         {
             object result = null;
             command = new SQLiteCommand(SQL, this._odcConnection);
             Reconnect(command);
-            //用来拼接参数的
-            if (names.Length > 0)
-            {
-                string[] par = SQL.Split(':');
-                //用来存参数的数组
-                StringBuilder[] addpar = new StringBuilder[par.Length - 1];
-                for (int i = 0; i < par.Length - 1; i++)
-                {
-                    //新建一个char类型的数组用来存储每个字节的变量
-                    char[] c = par[i + 1].ToCharArray();
-                    addpar[i] = new StringBuilder();
-                    for (int j = 0; j < c.Length; j++)
-                    {
-                        if (c[j] != ' ' && c[j] != ',' && c[j] != ')')
-                        {
-                            addpar[i].Append(c[j]);
-                        }
-                        else
-                        {
-                            break;
-                        }
-                    }
-                }
-                for (int i = 0; i < addpar.Length; i++)
-                    command.Parameters.Add(new SQLiteParameter(addpar[i].ToString(), names[i]));
-            }
-
             switch (Type.ToUpper())
             {
                 case "SELECT":
@@ -603,7 +576,6 @@ namespace UAS_LabelMachine
                     }
                     break;
             }
-
             return result;
         }
 

File diff suppressed because it is too large
+ 1050 - 1014
UAS-出货标签管理(吉利通)/UAS_出货标签管理.Designer.cs


+ 198 - 142
UAS-出货标签管理(吉利通)/UAS_出货标签管理.cs

@@ -14,6 +14,7 @@ using System.Threading;
 using System.IO;
 using System.IO.Ports;
 using UAS_LabelMachine.CustomControl;
+using System.Reflection;
 
 namespace UAS_LabelMachine
 {
@@ -114,7 +115,14 @@ namespace UAS_LabelMachine
 
         public UAS_出货标签打印(string Master)
         {
+            //设置窗体的双缓冲
+            this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);
+            this.UpdateStyles();
             InitializeComponent();
+            //利用反射设置DataGridView的双缓冲
+            Type dgvType = this.LabelInf.GetType();
+            PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
+            pi.SetValue(this.LabelInf, true, null);
             Text = Text + "-" + Master;
         }
 
@@ -142,8 +150,11 @@ namespace UAS_LabelMachine
             adh = SystemInf.adh;
             back_adh = SystemInf.back_adh;
             CheckForIllegalCrossThreadCalls = false;
+            pi_inoutno.TableName = "prodinout";
+            pi_inoutno.Field = "pi_inoutno";
+            pi_inoutno.ValueField = "pi_inoutno";
+            pi_inoutno.Condition = "pi_class in('出货单','拨出单')";
             pi_inoutno.Focus();
-
             Point pt = new Point();
             //禁止所有列的排序
             foreach (DataGridViewColumn dgv in LabelInf.Columns)
@@ -162,7 +173,7 @@ namespace UAS_LabelMachine
             OutBoxCapacity.Value = Properties.Settings.Default.OutboxCapacity;
             asc.controllInitializeSize(this);
             asc.controlAutoSize(this);
-
+            pi_inoutno.BringToFront();
             //实例化打印进程
             try
             {
@@ -614,7 +625,7 @@ namespace UAS_LabelMachine
             MessageLog.AppendText(msg + "\n");
             string[] msgArr = msg.Split(back_sg_separator.Text.ToCharArray());
             //如果包含则分隔符则需要解析,如果不包含则直接前端解析
-            if (msg.Contains(back_sg_separator.Text))
+            if (!cu_print_checkonly.Checked)
             {
                 //需要校验2项数据,完成校验后此项的值需要为2则表示校验成功
                 List<string> CheckItem = new List<string>();
@@ -890,6 +901,7 @@ namespace UAS_LabelMachine
             if (SingleLabelCombox.Text != "")
             {
                 SingleDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + SingleLabelCombox.Text);
+                SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
                 SingleLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql,lp_valuetype from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + SingleLabelCombox.SelectedValue.ToString().Split('#')[0], "select");
             }
             sql.Clear();
@@ -915,6 +927,7 @@ namespace UAS_LabelMachine
             if (MidLabelCombox.Text != "")
             {
                 MidDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + MidLabelCombox.Text);
+                MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
                 MidLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql,lp_valuetype from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + MidLabelCombox.SelectedValue.ToString().Split('#')[0], "select");
             }
             //缓存中盒参数
@@ -941,6 +954,7 @@ namespace UAS_LabelMachine
             if (OutBoxCombox.Text != "")
             {
                 OutBoxDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + OutBoxCombox.Text);
+                OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
                 OutLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql,lp_valuetype from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + OutBoxCombox.SelectedValue.ToString().Split('#')[0], "select");
             }
             //缓存外箱参数
@@ -1421,7 +1435,6 @@ namespace UAS_LabelMachine
                         MidDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
                 }
             }
-            MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
             MidDoc.PrintDocument();
         }
 
@@ -1511,7 +1524,6 @@ namespace UAS_LabelMachine
                             OutBoxDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
                     }
                 }
-                OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
                 OutBoxDoc.PrintDocument();
             }
         }
@@ -1702,7 +1714,7 @@ namespace UAS_LabelMachine
                     }
                     if (LabelInf.Rows[e.RowIndex].Cells["pib_ifrecheck"].FormattedValue.ToString() == "True")
                     {
-                        if (LabelInf.Columns[e.ColumnIndex].Name == "pib_custbarcode")
+                        if (LabelInf.Columns[e.ColumnIndex].Name == "pib_barcode")
                         {
                             SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
                             e.Graphics.FillRectangle(Brushes.CadetBlue, e.CellBounds);
@@ -1760,6 +1772,14 @@ namespace UAS_LabelMachine
             string close = MessageBox.Show(this.ParentForm, "是否注销", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
             if (close.ToString() == "Yes")
             {
+                if (FrontendCheck.IsOpen)
+                    FrontendCheck.Close();
+                if (BackendCheck.IsOpen)
+                    BackendCheck.Close();
+                if (PLC1.IsOpen)
+                    PLC1.Close();
+                if (ManBackendCheck.IsOpen)
+                    ManBackendCheck.Close();
                 Login login = new Login();
                 //注销的时候需要将拼接的连接字符串置空
                 DataHelper.DBConnectionString = null;
@@ -1913,69 +1933,7 @@ namespace UAS_LabelMachine
 
         private void ButtonSetting_Click(object sender, EventArgs e)
         {
-            ListButtonMenu.BringToFront();
-            ListButtonMenu.Visible = true;
-        }
-
-        private void ListButtonMenu_SelectedIndexChanged(object sender, EventArgs e)
-        {
-            ListButtonMenu.Visible = false;
-            switch (ListButtonMenu.SelectedItem.ToString())
-            {
-                case "采集策略设置":
-                    采集策略_NEW form = new 采集策略_NEW();
-                    form.FormClosed += Form_FormClosed;
-                    BaseUtil.SetFormCenter(form);
-                    form.ShowDialog();
-                    break;
-                case "生成条码":
-                    生成条码 form3 = new 生成条码(pi_inoutno.Text);
-                    form3.FormClosed += Form_FormClosed;
-                    BaseUtil.SetFormCenter(form3);
-                    form3.ShowDialog();
-                    break;
-                case "附加信息设置":
-                    if (pi_cardcode.Text != "")
-                    {
-                        附件内容打印 att = new 附件内容打印(pi_cardcode.Text);
-                        att.FormClosed += Attach_Closed;
-                        att.ShowDialog();
-                    }
-                    else MessageBox.Show("请先获取出库单信息");
-                    break;
-                case "客户标签维护":
-                    客户标签维护 form1 = new 客户标签维护();
-                    form1.FormClosed += Form_FormClosed;
-                    BaseUtil.SetFormCenter(form1);
-                    if (SingleDoc != null)
-                        SingleDoc.Close();
-                    if (MidDoc != null)
-                        MidDoc.Close();
-                    if (OutBoxDoc != null)
-                        OutBoxDoc.Close();
-                    form1.FormClosed += LabelFormClose;
-                    form1.ShowDialog();
-                    break;
-                case "客户采集规则":
-                    CustomerRule cust = new CustomerRule();
-                    cust.FormClosed += Form_FormClosed;
-                    BaseUtil.SetFormCenter(cust);
-                    cust.ShowDialog();
-                    break;
-                case "参数配置":
-                    ParamSetting form2 = new ParamSetting();
-                    form2.FormClosed += Form_FormClosed;
-                    BaseUtil.SetFormCenter(form2);
-                    form2.ShowDialog();
-                    break;
-                case "权限管理":
-                    PowerSetting pws = new PowerSetting();
-                    BaseUtil.SetFormCenter(pws);
-                    pws.ShowDialog();
-                    break;
-                default:
-                    break;
-            }
+            LogMenu.Show(new Point(ButtonSetting.Location.X, ButtonSetting.Location.Y + 20));
         }
 
         private void Form_FormClosed(object sender, FormClosedEventArgs e)
@@ -2031,7 +1989,7 @@ namespace UAS_LabelMachine
         private void PLCStart_Click(object sender, EventArgs e)
         {
             //查询前端检验的端口号
-            DataTable dt = (DataTable)adh.ExecuteSql("select * from cominfo", "select");
+            DataTable dt = (DataTable)adh.ExecuteSql("select comtype,BaudRate,com,datawait,outtime from cominfo", "select");
             DataRow[] dr = dt.Select("comtype='PLC1'");
             if (dr.Length > 0)
             {
@@ -2348,6 +2306,7 @@ namespace UAS_LabelMachine
             {
                 dh.ExecuteSql("delete from prodiobarcode  where pib_inoutno='" + pi_inoutno.Text + "'", "delete");
                 adh.ExecuteSql("delete from prodiobarcode  where pib_inoutno='" + pi_inoutno.Text + "'", "delete");
+                LoadGridData();
             }
         }
 
@@ -2370,171 +2329,176 @@ namespace UAS_LabelMachine
                 }
             }
             catch (Exception) { }
-            int outboxcode1 = int.Parse(Process_midboxcode.Text == "" ? "1" : Process_midboxcode.Text);
-            int outboxcode2 = int.Parse(Process_outboxcode.Text == "" ? "1" : Process_outboxcode.Text);
+            int outboxcode1 = Outbox1;
+            int outboxcode2 = Outbox2;
             string pd_id = LabelInf.Rows[CurrentRowIndex].Cells["pd_id"].Value.ToString();
             //如果满容量获取过箱号就不再重复获取了
-            bool GetBarcode = false;
+            //bool GetBarcode = false;
             //获取当前的行号
-            int CurrentRowNum = int.Parse(LabelInf.Rows[CurrentRowIndex].Cells["rownum"].Value.ToString());
+            decimal CurrentRowNum = decimal.Parse(LabelInf.Rows[CurrentRowIndex].Cells["rownum"].Value.ToString());
             //超过中盒容量中盒号+1
             if (adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1=" + outboxcode1) >= MidBoxCapacity.Value)
             {
                 outboxcode1 = outboxcode1 + 1;
-                GetBarcode = true;
-                LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
-                LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
+                //GetBarcode = true;
+                //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                //LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                //LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
             }
             else if (CurrentRowNum - 1 > 0)
             {
                 //获取上一行的数据
                 DataTable LastRowData = (DataTable)adh.ExecuteSql("select pib_lotno,pib_custmidboxcode,pib_custoutboxcode,pd_pocode,pd_custprodcode,pd_custprodspec,pib_datecode from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and rownum=" + (CurrentRowNum - 1), "select");
-                string custmidboxcode = LastRowData.Rows[0]["pib_custmidboxcode"].ToString();
-                if (custmidboxcode == "")
-                {
-                    LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                    LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
-                }
+                //string custmidboxcode = LastRowData.Rows[0]["pib_custmidboxcode"].ToString();
+                //if (custmidboxcode == "")
+                //{
+                //    LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                //    LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                //}
                 //或者不符合合并条件中盒号+1
                 if (cu_print_midlotno.Checked)
                 {
                     string TempData = LastRowData.Rows[0]["pib_lotno"].ToString();
-                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString() && !GetBarcode)
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString()/* /* && !GetBarcode/)
                     {
-                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                        LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                        //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                        //LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
+                        //LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
                         outboxcode1 = outboxcode1 + 1;
                     }
                 }
                 else if (cu_print_midpo.Checked)
                 {
                     string TempData = LastRowData.Rows[0]["pd_pocode"].ToString();
-                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString() && !GetBarcode)
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString() /* && !GetBarcode*/)
                     {
-                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                        LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                        //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                        //LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
+                        //LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
                         outboxcode1 = outboxcode1 + 1;
                     }
                 }
                 else if (cu_print_midprod.Checked)
                 {
                     string TempData = LastRowData.Rows[0]["pd_custprodcode"].ToString();
-                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString() && !GetBarcode)
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString() /* && !GetBarcode*/)
                     {
-                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                        LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                        //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                        //LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
+                        //LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
                         outboxcode1 = outboxcode1 + 1;
                     }
                 }
                 else if (cu_print_midspec.Checked)
                 {
                     string TempData = LastRowData.Rows[0]["pd_custprodspec"].ToString();
-                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodspec"].Value.ToString() && !GetBarcode)
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodspec"].Value.ToString() /* && !GetBarcode*/)
                     {
-                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                        LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                        //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                        //LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
+                        //LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
                         outboxcode1 = outboxcode1 + 1;
                     }
                 }
                 else if (cu_print_middc.Checked)
                 {
                     string TempData = LastRowData.Rows[0]["pib_datecode"].ToString();
-                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString() && !GetBarcode)
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString() /* && !GetBarcode*/)
                     {
-                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                        LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                        //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                        //LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
+                        //LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
                         outboxcode1 = outboxcode1 + 1;
                     }
                 }
-                if (LastRowData.Rows[0]["pib_custmidboxcode"].ToString() == MidBoxBarCode)
-                    LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = LastRowData.Rows[0]["pib_custmidboxcode"].ToString();
-                else
-                    LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                //if (LastRowData.Rows[0]["pib_custmidboxcode"].ToString() == MidBoxBarCode)
+                //    LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = LastRowData.Rows[0]["pib_custmidboxcode"].ToString();
+                //else
+                //    LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
             }
             else
             {
-                LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                //LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
             }
-            GetBarcode = false;
+            //GetBarcode = false;
             if (adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2=" + outboxcode2) >= OutBoxCapacity.Value)
             {
-                GetBarcode = true;
+                //GetBarcode = true;
                 outboxcode2 = outboxcode2 + 1;
-                LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                //LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
             }
             else if (CurrentRowNum - 1 > 0)
             {
                 //获取上一行数据
                 DataTable LastRowData = (DataTable)adh.ExecuteSql("select pib_lotno,pib_custmidboxcode,pib_custoutboxcode,pd_pocode,pd_custprodcode,pd_custprodspec,pib_datecode from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and rownum=" + (CurrentRowNum - 1), "select");
-                string custoutboxcode = LastRowData.Rows[0]["pib_custoutboxcode"].ToString();
-                if (custoutboxcode == "")
-                {
-                    LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                    LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
-                }
+                //string custoutboxcode = LastRowData.Rows[0]["pib_custoutboxcode"].ToString();
+                //if (custoutboxcode == "")
+                //{
+                //    LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                //    LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                //}
                 //或者不符合合并条件中盒号+1
                 if (cu_print_outlotno.Checked)
                 {
                     string TempData = LastRowData.Rows[0]["pib_lotno"].ToString();
-                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString() && !GetBarcode)
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString() /* && !GetBarcode*/)
                     {
-                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                        //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                        //LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                        outboxcode2 = outboxcode2 + 1;
                     }
                 }
                 else if (cu_print_outpo.Checked)
                 {
                     string TempData = LastRowData.Rows[0]["pd_pocode"].ToString();
-                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString() && !GetBarcode)
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString() /* && !GetBarcode*/)
                     {
-                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                        //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                        //LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                        outboxcode2 = outboxcode2 + 1;
                     }
                 }
                 else if (cu_print_outprod.Checked)
                 {
                     string TempData = LastRowData.Rows[0]["pd_custprodcode"].ToString();
-                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString() && !GetBarcode)
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString() /* && !GetBarcode*/)
                     {
-                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                        //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                        //LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                        outboxcode2 = outboxcode2 + 1;
                     }
                 }
                 else if (cu_print_outspec.Checked)
                 {
                     string TempData = LastRowData.Rows[0]["pd_custprodspec"].ToString();
-                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodspec"].Value.ToString() && !GetBarcode)
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodspec"].Value.ToString() /* && !GetBarcode*/)
                     {
-                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                        //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                        //LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                        outboxcode2 = outboxcode2 + 1;
                     }
                 }
                 else if (cu_print_outdc.Checked)
                 {
                     string TempData = LastRowData.Rows[0]["pib_datecode"].ToString();
-                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString() && !GetBarcode)
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString() /* && !GetBarcode*/)
                     {
-                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                        //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                        //LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                        outboxcode2 = outboxcode2 + 1;
                     }
                 }
-                if (OutBoxBarCode == LastRowData.Rows[0]["pib_custoutboxcode"].ToString())
-                    LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = LastRowData.Rows[0]["pib_custoutboxcode"].ToString();
-                else
-                    LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                //if (OutBoxBarCode == LastRowData.Rows[0]["pib_custoutboxcode"].ToString())
+                //    LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = LastRowData.Rows[0]["pib_custoutboxcode"].ToString();
+                //else
+                //    LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
             }
             else
             {
-                LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                //LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
             }
             //设置中盒外箱号
             LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode1"].Value = outboxcode1;
@@ -2600,7 +2564,6 @@ namespace UAS_LabelMachine
                         SingleDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
                 }
             }
-            SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
             SingleDoc.PrintDocument();
             LogicHandler.UpdateRowPrinted(pib_id);
         }
@@ -2646,5 +2609,98 @@ namespace UAS_LabelMachine
                 }
             }
         }
+
+        int Outbox1;
+        int Outbox2;
+        private void Process_midboxcode_TextChanged(object sender, EventArgs e)
+        {
+            int.TryParse(Process_midboxcode.Text, out Outbox1);
+        }
+
+        private void Process_outboxcode_TextChanged(object sender, EventArgs e)
+        {
+            int.TryParse(Process_outboxcode.Text, out Outbox2);
+        }
+
+        private void LabelPrinter_UserOnSelectIndexChange(object sender, EventArgs e)
+        {
+            switch ((sender as Control).Parent.Name)
+            {
+                case "SingleLabelPrinter":
+                    if (SingleDoc != null)
+                        SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
+                    break;
+                case "MidLabelPrinter":
+                    if (MidDoc != null)
+                        MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
+                    break;
+                case "OutBoxPrinter":
+                    if (OutBoxDoc != null)
+                        OutBoxDoc.Printer.SwitchTo(OutBoxLabelPrint.Text);
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        private void LogMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
+        {
+            switch (e.ClickedItem.Text)
+            {
+                case "采集策略设置":
+                    采集策略_NEW form = new 采集策略_NEW();
+                    form.FormClosed += Form_FormClosed;
+                    BaseUtil.SetFormCenter(form);
+                    form.ShowDialog();
+                    break;
+                case "生成条码":
+                    生成条码 form3 = new 生成条码(pi_inoutno.Text);
+                    form3.FormClosed += Form_FormClosed;
+                    BaseUtil.SetFormCenter(form3);
+                    form3.ShowDialog();
+                    break;
+                case "附加信息设置":
+                    if (pi_cardcode.Text != "")
+                    {
+                        附件内容打印 att = new 附件内容打印(pi_cardcode.Text);
+                        att.FormClosed += Attach_Closed;
+                        att.ShowDialog();
+                    }
+                    else MessageBox.Show("请先获取出库单信息");
+                    break;
+                case "客户标签维护":
+                    客户标签维护 form1 = new 客户标签维护();
+                    form1.FormClosed += Form_FormClosed;
+                    BaseUtil.SetFormCenter(form1);
+                    if (SingleDoc != null)
+                        SingleDoc.Close();
+                    if (MidDoc != null)
+                        MidDoc.Close();
+                    if (OutBoxDoc != null)
+                        OutBoxDoc.Close();
+                    form1.FormClosed += LabelFormClose;
+                    form1.ShowDialog();
+                    break;
+                case "客户采集规则":
+                    CustomerRule cust = new CustomerRule();
+                    cust.FormClosed += Form_FormClosed;
+                    BaseUtil.SetFormCenter(cust);
+                    cust.ShowDialog();
+                    break;
+                case "参数配置":
+                    ParamSetting form2 = new ParamSetting();
+                    form2.FormClosed += Form_FormClosed;
+                    BaseUtil.SetFormCenter(form2);
+                    form2.ShowDialog();
+                    break;
+                case "权限管理":
+                    PowerSetting pws = new PowerSetting();
+                    BaseUtil.SetFormCenter(pws);
+                    pws.ShowDialog();
+                    break;
+                default:
+                    break;
+            }
+        }
     }
 }

BIN
UAS-出货标签管理(吉利通)/tool/LabelPrint.db3


Some files were not shown because too many files changed in this diff