Browse Source

简化代码

章政 6 years ago
parent
commit
73efe28647

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

@@ -462,7 +462,7 @@ namespace UAS_LabelMachine
                                         string month = "";
                                         string day = "";
                                         string date = "";
-                                        LogicHandler.GetTimeFromDatecode(dh,DateCode, pi_cardcode.Text, out year, out month, out day, out date);
+                                        LogicHandler.GetTimeFromDatecode(dh, DateCode, pi_cardcode.Text, out year, out month, out day, out date);
                                         System.DateTime dtime;
                                         //有效期比对
                                         if (System.DateTime.TryParseExact(date, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dtime))
@@ -702,7 +702,7 @@ namespace UAS_LabelMachine
                             dr[0]["pib_datecode"] = DateCode;
                             try
                             {
-                                LogicHandler.GetTimeFromDatecode(dh1,DateCode, pi_cardcode.Text, out year, out month, out day, out date);
+                                LogicHandler.GetTimeFromDatecode(dh1, DateCode, pi_cardcode.Text, out year, out month, out day, out date);
                                 dr[0]["pib_year"] = year;
                                 dr[0]["pib_month"] = month;
                                 dr[0]["pib_day"] = day;
@@ -778,7 +778,7 @@ namespace UAS_LabelMachine
                     //解析DateCode,将值设置到年月日
                     try
                     {
-                        LogicHandler.GetTimeFromDatecode(dh1,DateCode, pi_cardcode.Text, out year, out month, out day, out date);
+                        LogicHandler.GetTimeFromDatecode(dh1, DateCode, pi_cardcode.Text, out year, out month, out day, out date);
                         LabelInf.Rows[CurrentRowIndex].Cells["pib_year"].Value = year;
                         LabelInf.Rows[CurrentRowIndex].Cells["pib_month"].Value = month;
                         LabelInf.Rows[CurrentRowIndex].Cells["pib_day"].Value = day;
@@ -2322,7 +2322,7 @@ namespace UAS_LabelMachine
             string month = "0";
             string day = "0";
             string date = "";
-            LogicHandler.GetTimeFromDatecode(dh1,datecode, pi_cardcode.Text, out year, out month, out day, out date);
+            LogicHandler.GetTimeFromDatecode(dh1, datecode, pi_cardcode.Text, out year, out month, out day, out date);
             adh.ExecuteSql("update prodiobarcode set pib_ifpick=-1,pib_ifmodify=-1,pib_lotno='" + lotno + "',pib_datecode='" + datecode + "',pib_year='" + year + "',pib_month='" + month + "',pib_day='" + day + "' where pib_inoutno='" + pi_inoutno.Text + "' and pib_pdno=" + pdno, "update");
             LoadGridData();
             setvalue.FindForm().Close();
@@ -2338,7 +2338,7 @@ namespace UAS_LabelMachine
             string month = "0";
             string day = "0";
             string date = "";
-            LogicHandler.GetTimeFromDatecode(dh1,datecode, pi_cardcode.Text, out year, out month, out day, out date);
+            LogicHandler.GetTimeFromDatecode(dh1, datecode, pi_cardcode.Text, out year, out month, out day, out date);
             adh.ExecuteSql("update prodiobarcode set pib_ifpick=-1,pib_ifmodify=-1,pib_ifprint=-1,pib_lotno='" + lotno + "',pib_datecode='" + datecode + "',pib_year='" + year + "',pib_month='" + month + "',pib_day='" + day + "' where pib_inoutno='" + pi_inoutno.Text + "' and pib_pdno=" + pdno, "update");
             LoadGridData();
             DataTable pibid_dt = (DataTable)adh.ExecuteSql("select pib_id from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_pdno=" + pdno, "select");
@@ -2368,7 +2368,7 @@ namespace UAS_LabelMachine
             //解析DateCode,将值设置到年月日
             try
             {
-                LogicHandler.GetTimeFromDatecode(dh,DateCode, pi_cardcode.Text, out year, out month, out day, out date);
+                LogicHandler.GetTimeFromDatecode(dh, DateCode, pi_cardcode.Text, out year, out month, out day, out date);
                 LabelInf.Rows[CurrentRowIndex].Cells["pib_year"].Value = year;
                 LabelInf.Rows[CurrentRowIndex].Cells["pib_month"].Value = month;
                 LabelInf.Rows[CurrentRowIndex].Cells["pib_day"].Value = day;

+ 17 - 29
UAS-出货标签管理/PublicMethod/DataHelper.cs

@@ -33,39 +33,27 @@ namespace UAS_LabelMachine
         ////需要显示的账套
         //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)));";
-        ////华商龙ERP地址
-        //public static readonly string ERPAddesss = "http://218.18.115.198:8888/ERP/";
-        ////华商龙FTP
-        //public static readonly string FTPAdress = "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";
+        //华商龙外网地址
+        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)));";
+        //华商龙ERP地址
+        public static readonly string ERPAddesss = "http://218.18.115.198:8888/ERP/";
+        //华商龙FTP
+        public static readonly string FTPAdress = "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";
 
-        ////泽天外网地址
-        //private readonly string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=ZT_TEST;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=183.47.41.2)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
-        ////泽天ERP地址
-        //public static readonly string ERPAddesss = "http://183.47.41.2:8099/ERP/";
-        ////泽天FTP
-        //public static readonly string FTPAdress = "ftp://183.47.41.3:21|uas|Zt2018";
+        ////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 FTPAdress = "ftp://192.168.253.9/PrintFile|mesconfig|Administrator1@#";
         ////Oracle端口
         //public static readonly string OraclePort = "1521";
         ////需要显示的账套
-        //public static readonly string Masters = "ZT_TEST";
-        //用户选择的数据库的连接字符串
-
-        //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 FTPAdress = "ftp://192.168.253.9/PrintFile|mesconfig|Administrator1@#";
-        //Oracle端口
-        public static readonly string OraclePort = "1521";
-        //需要显示的账套
-        public static readonly string Masters = "UAS_TEST";
+        //public static readonly string Masters = "UAS_TEST";
         public static string DBConnectionString;
         static OracleConnection connection = null;
         static OracleCommand command = null;

+ 16 - 77
UAS-出货标签管理/UAS_出货标签管理.cs

@@ -129,8 +129,6 @@ namespace UAS_LabelMachine
         /*用于存放采集项目的Grid信息*/
         Dictionary<string, Dictionary<string, string>> SiItem;
         int CloumnCount = 0;
-        /*需要重绘的Cell*/
-        Dictionary<DataGridViewCell, bool> PaintCell = new Dictionary<DataGridViewCell, bool>();
         //使用二维数组进行排序
         ArrayList<ArrayList<string>> ScanData;
         ArrayList<string> GetData;
@@ -537,20 +535,9 @@ namespace UAS_LabelMachine
                             {
                                 dt.Rows[i]["pib_lotno"] = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value;
                                 dt.Rows[i]["pib_datecode"] = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value;
-                                //将采集数据正确的Cell添加到键值对中
-                                if (PaintCell.ContainsKey(LabelInf.Rows[i].Cells["pr_vendprodcode"]))
-                                {
-                                    PaintCell.Remove(LabelInf.Rows[i].Cells["pr_vendprodcode"]);
-                                }
-                                PaintCell.Add(LabelInf.Rows[i].Cells["pr_vendprodcode"], true);
-                                if (PaintCell.ContainsKey(LabelInf.Rows[i].Cells["pib_qty"]))
-                                {
-                                    PaintCell.Remove(LabelInf.Rows[i].Cells["pib_qty"]);
-                                }
-                                PaintCell.Add(LabelInf.Rows[i].Cells["pib_qty"], true);
-                                LabelInf.Refresh();
                                 LabelInf.Rows[i].Cells["pib_ifpick"].Value = true;
                                 LabelInf.Rows[i].Cells["Choose"].Value = true;
+                                LabelInf.Invalidate();
                                 //当前行的索引随循环增长
                                 CurrentRowIndex = i;
                                 if (SingleLabelAutoPrint.Checked)
@@ -576,20 +563,10 @@ namespace UAS_LabelMachine
                             dt.Rows[i]["pib_lotno"] = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value;
                             dt.Rows[i]["pib_datecode"] = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value;
                             CurrentRowIndex = i;
-                            //将采集数据正确的Cell添加到键值对中
-                            if (PaintCell.ContainsKey(LabelInf.Rows[i].Cells["pr_vendprodcode"]))
-                            {
-                                PaintCell.Remove(LabelInf.Rows[i].Cells["pr_vendprodcode"]);
-                            }
-                            PaintCell.Add(LabelInf.Rows[i].Cells["pr_vendprodcode"], true);
-                            if (PaintCell.ContainsKey(LabelInf.Rows[i].Cells["pib_qty"]))
-                            {
-                                PaintCell.Remove(LabelInf.Rows[i].Cells["pib_qty"]);
-                            }
-                            PaintCell.Add(LabelInf.Rows[i].Cells["pib_qty"], true);
                             LabelInf.Refresh();
                             LabelInf.Rows[i].Cells["pib_ifpick"].Value = true;
                             LabelInf.Rows[i].Cells["Choose"].Value = true;
+                            LabelInf.Invalidate();
                             SetOutBoxCode2(true);
                         }
                     }
@@ -597,6 +574,7 @@ namespace UAS_LabelMachine
                     {
                         LabelInf.Rows[CurrentRowIndex].Cells["pib_ifpick"].Value = true;
                         LabelInf.Rows[CurrentRowIndex].Cells["Choose"].Value = true;
+                        LabelInf.Invalidate();
                         //勾选了单盘自动打印
                         if (SingleLabelAutoPrint.Checked)
                         {
@@ -772,17 +750,11 @@ namespace UAS_LabelMachine
                             {
                                 CollectVeProdCodePass = false;
                                 //添加需要重绘的Cell
-                                if (PaintCell.ContainsKey(cell))
-                                    PaintCell.Remove(cell);
-                                PaintCell.Add(cell, false);
                                 LabelInf.Refresh();
                                 MessageLog.AppendText(">>供应商物料编号不匹配\n", Color.Red);
                             }
                             else
                             {
-                                if (PaintCell.ContainsKey(cell))
-                                    PaintCell.Remove(cell);
-                                PaintCell.Add(cell, true);
                                 LabelInf.Refresh();
                                 CollectVeProdCodePass = true;
                             }
@@ -796,18 +768,11 @@ namespace UAS_LabelMachine
                             if (cell.Value.ToString() != Matchstr)
                             {
                                 CollectQTYPass = false;
-                                //添加需要重绘的Cell
-                                if (PaintCell.ContainsKey(cell))
-                                    PaintCell.Remove(cell);
-                                PaintCell.Add(cell, false);
                                 LabelInf.Refresh();
                                 MessageLog.AppendText(">>数量不匹配\n", Color.Red);
                             }
                             else
                             {
-                                if (PaintCell.ContainsKey(cell))
-                                    PaintCell.Remove(cell);
-                                PaintCell.Add(cell, true);
                                 LabelInf.Refresh();
                                 CollectQTYPass = true;
                             }
@@ -821,18 +786,11 @@ namespace UAS_LabelMachine
                             if (cell.Value.ToString() != Matchstr)
                             {
                                 CollectQTYPass = false;
-                                //添加需要重绘的Cell
-                                if (PaintCell.ContainsKey(cell))
-                                    PaintCell.Remove(cell);
-                                PaintCell.Add(cell, false);
                                 LabelInf.Refresh();
                                 MessageLog.AppendText(">>品牌不匹配\n", Color.Red);
                             }
                             else
                             {
-                                if (PaintCell.ContainsKey(cell))
-                                    PaintCell.Remove(cell);
-                                PaintCell.Add(cell, true);
                                 LabelInf.Refresh();
                                 CollectQTYPass = true;
                             }
@@ -1148,7 +1106,7 @@ namespace UAS_LabelMachine
                     PI_ID = dt.Rows[0]["pi_id"].ToString();
                     if (dh.GetConfig("AutoBarcode", "ProdInOut!Sale").ToString() != "")
                     {
-                        string[] param = new string[] { PI_ID, "", "" };
+                        string[] param = new string[] { PI_ID, "" };
                         dh.CallProcedure("GetCustBarcode", param);
                     }
                     LoadGridData(sender, e);
@@ -1520,6 +1478,7 @@ namespace UAS_LabelMachine
                             MessageBox.Show("单盘打印范围错误");
                             return;
                         }
+                        LabelInf.Invalidate();
                     }
                     catch (Exception)
                     {
@@ -2054,38 +2013,18 @@ namespace UAS_LabelMachine
                 }
                 if (e.RowIndex >= 0)
                 {
-                    //重绘制定的Cell,表示采集的数量不匹配
-                    if (LabelInf.Columns[e.ColumnIndex].Name == "pib_qty" && PaintCell.ContainsKey(LabelInf.Rows[e.RowIndex].Cells["pib_qty"]))
-                    {
-                        SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
-                        e.Graphics.FillRectangle(PaintCell[LabelInf.Rows[e.RowIndex].Cells["pib_qty"]] ? Brushes.ForestGreen : Brushes.Red, e.CellBounds);
-                        Rectangle border = e.CellBounds;
-                        border.Width -= 1;
-                        e.Graphics.DrawRectangle(Pens.Black, border);
-                        e.PaintContent(e.CellBounds);
-                        e.Handled = true;
-                    }
-                    //表示采集的供应商物料编号不匹配
-                    if (LabelInf.Columns[e.ColumnIndex].Name == "pr_vendprodcode" && PaintCell.ContainsKey(LabelInf.Rows[e.RowIndex].Cells["pr_vendprodcode"]))
+                    if (LabelInf.Rows[e.RowIndex].Cells["pib_ifpick"].FormattedValue.ToString() == "True")
                     {
-                        SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
-                        e.Graphics.FillRectangle(PaintCell[LabelInf.Rows[e.RowIndex].Cells["pr_vendprodcode"]] ? Brushes.ForestGreen : Brushes.Red, e.CellBounds);
-                        Rectangle border = e.CellBounds;
-                        border.Width -= 1;
-                        e.Graphics.DrawRectangle(Pens.Black, border);
-                        e.PaintContent(e.CellBounds);
-                        e.Handled = true;
-                    }
-                    //表示采集的供应商物料编号不匹配
-                    if (LabelInf.Columns[e.ColumnIndex].Name == "pib_brand" && PaintCell.ContainsKey(LabelInf.Rows[e.RowIndex].Cells["pib_brand"]))
-                    {
-                        SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
-                        e.Graphics.FillRectangle(PaintCell[LabelInf.Rows[e.RowIndex].Cells["pib_brand"]] ? Brushes.ForestGreen : Brushes.Red, e.CellBounds);
-                        Rectangle border = e.CellBounds;
-                        border.Width -= 1;
-                        e.Graphics.DrawRectangle(Pens.Black, border);
-                        e.PaintContent(e.CellBounds);
-                        e.Handled = true;
+                        if (LabelInf.Columns[e.ColumnIndex].Name == "pib_lotno" || LabelInf.Columns[e.ColumnIndex].Name == "pib_datecode")
+                        {
+                            SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
+                            e.Graphics.FillRectangle(Brushes.ForestGreen, e.CellBounds);
+                            Rectangle border = e.CellBounds;
+                            border.Width -= 1;
+                            e.Graphics.DrawRectangle(Pens.Black, border);
+                            e.PaintContent(e.CellBounds);
+                            e.Handled = true;
+                        }
                     }
                 }
             }