Pārlūkot izejas kodu

添加日志显示

callm 4 gadi atpakaļ
vecāks
revīzija
248cc5a14e

+ 29 - 29
UAS-出货标签管理(泽天)/PublicMethod/DataHelper.cs

@@ -66,7 +66,7 @@ namespace UAS_LabelMachine
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
             ad.Dispose();
-            command.Dispose();
+            
             return dt;
         }
 
@@ -80,10 +80,10 @@ namespace UAS_LabelMachine
             if (dt.Rows.Count > 0)
             {
                 ad.Dispose();
-                command.Dispose();
+                
                 return dt.Rows[0][0];
             }
-            else { command.Dispose(); return ""; }
+            else {  return ""; }
         }
 
         /// <summary>
@@ -111,7 +111,7 @@ namespace UAS_LabelMachine
                 ad.Fill(dt);
             }
             ad.Dispose();
-            command.Dispose();
+            
             if (dt.Rows.Count > 0)
             {
                 return dt.Rows[0][0];
@@ -152,7 +152,7 @@ namespace UAS_LabelMachine
                 DataTable dt = new DataTable();
                 ad.Fill(dt);
                 ad.Dispose();
-                command.Dispose();
+                
                 return dt;
             }
             return "参数错误,请检查SQL语句";
@@ -170,7 +170,7 @@ namespace UAS_LabelMachine
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
             int count = int.Parse(dt.Rows[0][0].ToString());
-            command.Dispose();
+            
             return count;
         }
 
@@ -187,7 +187,7 @@ namespace UAS_LabelMachine
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
             int count = int.Parse(dt.Rows[0][0].ToString());
-            command.Dispose();
+            
             return count;
         }
 
@@ -203,7 +203,7 @@ namespace UAS_LabelMachine
             command = new OracleCommand(sql, connection);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
-            command.Dispose();
+            
             return dt;
         }
 
@@ -216,7 +216,7 @@ namespace UAS_LabelMachine
             command = new OracleCommand(sql, connection);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
-            command.Dispose();
+            
             return dt;
         }
 
@@ -277,7 +277,7 @@ namespace UAS_LabelMachine
                 dc.ColumnName = field[dt.Columns.IndexOf(dc)];
                 dc.Caption = caption[dt.Columns.IndexOf(dc)];
             }
-            command.Dispose();
+            
             return dt;
         }
 
@@ -293,7 +293,7 @@ namespace UAS_LabelMachine
             command = new OracleCommand(sql, connection);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
-            command.Dispose();
+            
             return dt;
         }
 
@@ -316,7 +316,7 @@ namespace UAS_LabelMachine
                 arr.Add(dc[Fields]);
             }
             ad.Dispose();
-            command.Dispose();
+            
             return (string[])arr.ToArray(typeof(string));
         }
 
@@ -339,7 +339,7 @@ namespace UAS_LabelMachine
                 arr.Add(dc[Fields]);
             }
             ad.Dispose();
-            command.Dispose();
+            
             return (string[])arr.ToArray(typeof(string));
         }
 
@@ -461,7 +461,7 @@ namespace UAS_LabelMachine
             }
             ad.UpdateCommand = command;
             ad.Update(DataTable);
-            command.Dispose();
+            
             ad.Dispose();
         }
 
@@ -662,7 +662,7 @@ namespace UAS_LabelMachine
                 dt1.Columns[i].Caption = caption[i];
             }
             //返回的第一条数据是SQL,后面的是实际的列名
-            command.Dispose();
+            
             return dt1;
         }
 
@@ -721,7 +721,7 @@ namespace UAS_LabelMachine
                 dt1.Columns[i].Caption = caption[i];
             }
             ad.Dispose();
-            command.Dispose();
+            
             return dt1;
         }
 
@@ -740,13 +740,13 @@ namespace UAS_LabelMachine
             ad.Fill(dt);
             if (int.Parse(dt.Rows[0][0].ToString()) > 0)
             {
-                command.Dispose();
+                
                 ad.Dispose();
                 return true;
             }
             else
             {
-                command.Dispose();
+                
                 ad.Dispose();
                 return false;
             }
@@ -846,7 +846,7 @@ namespace UAS_LabelMachine
                     }
                     break;
             }
-            //command.Dispose();
+            //
             return result;
         }
 
@@ -862,12 +862,12 @@ namespace UAS_LabelMachine
                 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;
             }
@@ -881,7 +881,7 @@ namespace UAS_LabelMachine
             string sql = "select distinct count('" + Field + "') from " + TableName;
             OracleDataAdapter ad = new OracleDataAdapter(new OracleCommand(sql, connection));
             ad.Fill(dt);
-            command.Dispose();
+            
             return int.Parse(dt.Rows[0][0].ToString());
         }
 
@@ -910,7 +910,7 @@ namespace UAS_LabelMachine
             command.ArrayBindCount = DeleteID.Length;
             command.Parameters.Add(new OracleParameter("DeleteID", OracleDbType.Long, DeleteID, ParameterDirection.Input));
             command.ExecuteNonQuery();
-            command.Dispose();
+            
         }
 
         /// <summary>
@@ -959,7 +959,7 @@ namespace UAS_LabelMachine
                 command.Parameters.Add(new OracleParameter(names[0][i - 1].ToString(), OracleDbType.Varchar2, names[i], ParameterDirection.Input));
             }
             int rowsnum = (command.ExecuteNonQuery());
-            command.Dispose();
+            
             return rowsnum;
         }
 
@@ -974,7 +974,7 @@ namespace UAS_LabelMachine
                 command.Parameters.Add(new OracleParameter(param[i].ToString(), OracleDbType.Varchar2, param1[i], ParameterDirection.Input));
             }
             command.ExecuteNonQuery();
-            command.Dispose();
+            
         }
 
 
@@ -991,7 +991,7 @@ namespace UAS_LabelMachine
             command = new OracleCommand(SQL, connection);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
-            command.Dispose();
+            
             return dt.Rows[0][0].ToString();
         }
 
@@ -1062,7 +1062,7 @@ namespace UAS_LabelMachine
             string sql = "update " + TableName + " set " + update + " where " + condition;
             command = new OracleCommand(sql, connection);
             command.ExecuteNonQuery();
-            //command.Dispose();
+            //
         }
 
         /// <summary>
@@ -1090,7 +1090,7 @@ namespace UAS_LabelMachine
             }
             for (int i = 0; i < command.Parameters.Count; i++)
                 param[i] = command.Parameters[i].Value.ToString();
-            command.Dispose();
+            
         }
 
         /// <summary>
@@ -1118,7 +1118,7 @@ namespace UAS_LabelMachine
             }
             for (int i = 0; i < command.Parameters.Count; i++)
                 param[i] = command.Parameters[i].Value.ToString();
-            command.Dispose();
+            
         }
 
         /// <summary>

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 227 - 174
UAS-出货标签管理(泽天)/UAS_出货标签管理.Designer.cs


+ 52 - 48
UAS-出货标签管理(泽天)/UAS_出货标签管理.cs

@@ -104,12 +104,14 @@ namespace UAS_LabelMachine
         string[] PIBID;
 
         DataTable Attach;
-
+        //传送贴标角度
         string Angle = "";
 
         string X = "";
 
         string Y = "";
+        //贴标机采集的行数
+        int MachineCollectRowIndex = 0;
 
         public UAS_出货标签打印(string Master)
         {
@@ -239,7 +241,7 @@ namespace UAS_LabelMachine
             string[] SplitData = Input.Text.Split('*');
             if (SplitData.Length < 5)
             {
-                MessageBox.Show("数据格式错误,无法解析", "提示");
+                richTextAutoBottom1.AppendText("数据格式错误,无法解析\n");
                 if (ConnectToMachine)
                 {
                     receiveClient.Client.Send(Encoding.ASCII.GetBytes("ReadId1|,|NG|,|Y"));
@@ -279,27 +281,24 @@ namespace UAS_LabelMachine
             //校验DateCode是否过期
             if (!CheckDateCode(Data["DATECODE"]))
             {
-                string close = MessageBox.Show(this.ParentForm, "物料" + Data["PRCODE"] + "【DateCode】超出校验日期,是否继续", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
-                if (close != "Yes")
-                {
-                    Input.SelectAll();
-                    return;
-                }
+                richTextAutoBottom1.AppendText("物料" + Data["PRCODE"] + "【DateCode】超出校验日期,是否继续\n");
+                Input.SelectAll();
+                receiveClient.Client.Send(Encoding.ASCII.GetBytes(GetSendCode("ReadId1|,|NG|,|Y")));
+                return;
             }
             if (Data["PRCODE"] != CurrentPrCode)
             {
-                MessageBox.Show("当前采集【物料编号】不对应,请重新采集", "提示");
+                richTextAutoBottom1.AppendText("当前采集【物料编号】不对应,请重新采集\n");
                 Input.SelectAll();
+                receiveClient.Client.Send(Encoding.ASCII.GetBytes(GetSendCode("ReadId1|,|NG|,|Y")));
                 return;
             }
             if (Data["BRAND"] != CurrentBrand)
             {
-                string close = MessageBox.Show(this.ParentForm, "当前采集【品牌】不对应,是否继续采集", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
-                if (close != "Yes")
-                {
-                    Input.SelectAll();
-                    return;
-                }
+                richTextAutoBottom1.AppendText("当前采集【品牌】不对应,是否继续采集\n");
+                Input.SelectAll();
+                receiveClient.Client.Send(Encoding.ASCII.GetBytes(GetSendCode("ReadId1|,|NG|,|Y")));
+                return;
             }
             int CodeCount = 0;
             //如果单位是KPCS则需要除1000
@@ -315,10 +314,11 @@ namespace UAS_LabelMachine
                     MessageBox.Show("请检查最小包装数");
                 }
                 //如果单位是KPCS则必须是1000的整数倍
-                if (int.Parse((Convert.ToDouble((double.Parse(Data["QTY"]) / 1000).ToString("0.000")) / Convert.ToDouble(double.Parse(CurrentZXBZ).ToString("0.000"))).ToString()) % 1 != 0)
+                if (decimal.Parse((Convert.ToDouble((double.Parse(Data["QTY"]) / 1000).ToString("0.000")) / Convert.ToDouble(double.Parse(CurrentZXBZ).ToString("0.000"))).ToString()) % 1 != 0)
                 {
-                    MessageBox.Show("物料" + Data["PRCODE"] + "采集数量无法按照最小包装数拆分", "提示");
+                    richTextAutoBottom1.AppendText("物料" + Data["PRCODE"] + "采集数量无法按照最小包装数拆分\n");
                     Input.SelectAll();
+                    receiveClient.Client.Send(Encoding.ASCII.GetBytes(GetSendCode("ReadId1|,|NG|,|Y")));
                     return;
                 }
                 CodeCount = int.Parse((double.Parse(Data["QTY"]) / 1000 / double.Parse(CurrentZXBZ)).ToString());
@@ -328,7 +328,8 @@ namespace UAS_LabelMachine
             {
                 if (double.Parse(Data["QTY"]) % double.Parse(CurrentZXBZ) != 0)
                 {
-                    MessageBox.Show("采集【数量】无法按照最小包装数拆分", "提示");
+                    richTextAutoBottom1.AppendText("采集【数量】无法按照最小包装数拆分\n");
+                    receiveClient.Client.Send(Encoding.ASCII.GetBytes(GetSendCode("ReadId1|,|NG|,|Y")));
                     Input.SelectAll();
                     return;
                 }
@@ -417,7 +418,7 @@ namespace UAS_LabelMachine
             {
                 rowsnum = dh.BatchInsert(sql.ToString(), new string[] { "PIB_ID", "PIB_CUSTBARCODE" }, PIBID, CustBarCode.ToArray());
             }
-            catch (Exception e)
+            catch (Exception)
             {
                 if (ReSetType != " ")
                 {
@@ -434,7 +435,6 @@ namespace UAS_LabelMachine
             {
                 MessageBox.Show("未成功插入数据,请核对出货单当前明细", "提示");
             }
-
             //更新流水号
             LoadGridData(new object(), new EventArgs());
             if (LabelInf.Rows.Count > 0)
@@ -443,13 +443,14 @@ namespace UAS_LabelMachine
             }
             if (SingleLabelAutoPrint.Checked)
             {
-                thread = new Thread(AutoPrintSingleLabel);
-                stw = new SetLoadingWindow(thread, "正在打印单盘标签");
-                BaseUtil.SetFormCenter(stw);
-                stw.ShowDialog();
+                //thread = new Thread(AutoPrintSingleLabel);
+                //stw = new SetLoadingWindow(thread, "正在打印单盘标签");
+                //BaseUtil.SetFormCenter(stw);
+                //stw.ShowDialog();
                 receiveClient.Client.Send(Encoding.ASCII.GetBytes(GetSendCode("ReadId1|,|OK|,|Y")));
             }
-            else {
+            else
+            {
                 receiveClient.Client.Send(Encoding.ASCII.GetBytes(GetSendCode("ReadId1|,|OK|,|N")));
             }
             if (SumQty.Columns.Count == 0)
@@ -705,6 +706,7 @@ namespace UAS_LabelMachine
                         if (double.Parse(outqty) > double.Parse(collectnum == "" ? "0" : collectnum))
                         {
                             GridPrcode.Rows[i].Selected = true;
+                            MachineCollectRowIndex = GridPrcode.SelectedRows[0].Index;
                             if (i - 2 >= 0)
                                 GridPrcode.FirstDisplayedScrollingRowIndex = i - 2;
                             else
@@ -1831,6 +1833,7 @@ namespace UAS_LabelMachine
             if (GridPrcode.SelectedRows.Count > 0)
             {
                 DataGridViewSelectedRowCollection dsc = GridPrcode.SelectedRows;
+                MachineCollectRowIndex = GridPrcode.SelectedRows[0].Index;
                 CurrentPrCode = GridPrcode.Rows[dsc[0].Index].Cells["pd_prodcode"].Value.ToString();
                 CurrentZXBZ = GridPrcode.Rows[dsc[0].Index].Cells["pjd_zxbzs_user"].Value.ToString();
                 CurrentUnit = GridPrcode.Rows[dsc[0].Index].Cells["pr_unit"].Value.ToString();
@@ -2515,37 +2518,39 @@ namespace UAS_LabelMachine
                     bool SendLast = false;
                     for (int i = 0; i < GridPrcode.Rows.Count; i++)
                     {
-                        //获取复核的数据
-                        int checknum = int.Parse(GridPrcode.Rows[i].Cells["checknum"].Value.ToString());
-                        double outqty = double.Parse(GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString());
-                        double zxbzs = double.Parse(GridPrcode.Rows[i].Cells["PJD_ZXBZS_USER"].Value.ToString());
-                        string Prcode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
-                        string pdno = GridPrcode.Rows[i].Cells["pd_pdno"].Value.ToString();
-                        if ((pr_code == Prcode || pr_code == "") && checknum < outqty / zxbzs)
+                        //采集哪行复核哪行
+                        if (i == MachineCollectRowIndex)
                         {
-                            checknum = checknum + 1;
-                            GridPrcode.Rows[i].Cells["checknum"].Value = checknum;
-                            if (checknum < outqty / zxbzs)
-                            {
-                                dh.ExecuteSql("update CS$InoutPrcode set checknum=nvl(checknum,0)+1 where pd_inoutno='" + pi_inoutno.Text + "' and pd_pdno='" + pdno + "' and combined=" + combined, "update");
-                            }
-                            else if (checknum == outqty / zxbzs)
+                            //获取复核的数据
+                            int checknum = int.Parse(GridPrcode.Rows[i].Cells["checknum"].Value.ToString());
+                            double outqty = double.Parse(GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString());
+                            double zxbzs = double.Parse(GridPrcode.Rows[i].Cells["PJD_ZXBZS_USER"].Value.ToString());
+                            string Prcode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
+                            string pdno = GridPrcode.Rows[i].Cells["pd_pdno"].Value.ToString();
+                            if ((pr_code == Prcode || pr_code == "") && checknum < outqty / zxbzs)
                             {
-                                dh.ExecuteSql("update CS$InoutPrcode set checknum=nvl(checknum,0)+1 where pd_inoutno='" + pi_inoutno.Text + "' and pd_pdno='" + pdno + "' and combined=" + combined, "update");
-                                Console.WriteLine("ReadId3|,|OK|,|1");
-                                sendClient.Client.Send(Encoding.ASCII.GetBytes("ReadId3|,|OK|,|1"));
-                                checknum = 0;
-                                SendLast = true;
-                                PassTenCount = 0;
+                                checknum = checknum + 1;
+                                GridPrcode.Rows[i].Cells["checknum"].Value = checknum;
+                                if (checknum < outqty / zxbzs)
+                                {
+                                    dh.ExecuteSql("update CS$InoutPrcode set checknum=nvl(checknum,0)+1 where pd_inoutno='" + pi_inoutno.Text + "' and pd_pdno='" + pdno + "' and combined=" + combined, "update");
+                                }
+                                else if (checknum == outqty / zxbzs)
+                                {
+                                    dh.ExecuteSql("update CS$InoutPrcode set checknum=nvl(checknum,0)+1 where pd_inoutno='" + pi_inoutno.Text + "' and pd_pdno='" + pdno + "' and combined=" + combined, "update");
+                                    sendClient.Client.Send(Encoding.ASCII.GetBytes("ReadId3|,|OK|,|1"));
+                                    checknum = 0;
+                                    SendLast = true;
+                                    PassTenCount = 0;
+                                }
+                                break;
                             }
-                            break;
                         }
                     }
                     //DataGridViewSelectedRowCollection selectrow = GridPrcode.SelectedRows;
                     //达到了中盒容量之后
                     if (PassTenCount == MidboxCapacity.Value)
                     {
-                        Console.WriteLine("ReadId3|,|OK|,|1");
                         sendClient.Client.Send(Encoding.ASCII.GetBytes("ReadId3|,|OK|,|1"));
                         PassTenCount = 0;
                     }
@@ -2554,7 +2559,6 @@ namespace UAS_LabelMachine
                         //如果发送了最后一盒,则不发送继续堆叠的指令
                         if (!SendLast)
                         {
-                            Console.WriteLine("ReadId3|,|OK|,|0");
                             sendClient.Client.Send(Encoding.ASCII.GetBytes("ReadId3|,|OK|,|0"));
                         }
                     }

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels