فهرست منبع

优化采集项次代码,更新采集数据到本地数据库

章政 6 سال پیش
والد
کامیت
c0363d730f

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

@@ -11,28 +11,28 @@ namespace UAS_LabelMachine
     public class DataHelper
     {
 
-        //海创外网地址
-        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 FTPAdress = "ftp://" + Properties.Settings.Default.IPAddress + "|HCFTP|Admin1@#";
+        ////海创外网地址
+        //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 FTPAdress = "ftp://" + Properties.Settings.Default.IPAddress + "|HCFTP|Admin1@#";
 
-        //Oracle端口
-        public static readonly string OraclePort = "1521";
-        //需要显示的账套
-        public static readonly string Masters = "HC_TEST";
-
-        ////凯而高地址
-        //private readonly string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=KRG_TEST;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=112.25.154.186)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
-        ////凯而高ERP地址
-        //public static readonly string ERPAddesss = "http://112.25.154.186:8099/ERP/";
-        ////凯而高FTP
-        //public static readonly string FTPAdress = "ftp://112.25.154.186:21|KEGFTP|Admin1@#";
         ////Oracle端口
         //public static readonly string OraclePort = "1521";
         ////需要显示的账套
-        //public static readonly string Masters = "GOLDEN";
+        //public static readonly string Masters = "HC_TEST";
+
+        //凯而高地址
+        private readonly string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=KRG_TEST;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=112.25.154.186)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        //凯而高ERP地址
+        public static readonly string ERPAddesss = "http://112.25.154.186:8099/ERP/";
+        //凯而高FTP
+        public static readonly string FTPAdress = "ftp://112.25.154.186: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=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)));";

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

@@ -8,6 +8,8 @@ namespace UAS_LabelMachine
 {
     class ftpOperater
     {
+        public static string FTPAddress = DataHelper.FTPAdress.Split('|')[0];
+
         public static string DownLoadTo = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":\" + @"打印标签\";
 
         private string ftpServerIP;

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

@@ -954,7 +954,7 @@
             this.pr_code.ReturnData = null;
             this.pr_code.SelectField = null;
             this.pr_code.SetValueField = null;
-            this.pr_code.Size = new System.Drawing.Size(149, 22);
+            this.pr_code.Size = new System.Drawing.Size(149, 21);
             this.pr_code.TabIndex = 68;
             this.pr_code.TableName = null;
             this.pr_code.TextBoxEnable = false;
@@ -1146,7 +1146,7 @@
             this.sg_code.ReturnData = null;
             this.sg_code.SelectField = null;
             this.sg_code.SetValueField = null;
-            this.sg_code.Size = new System.Drawing.Size(149, 24);
+            this.sg_code.Size = new System.Drawing.Size(149, 21);
             this.sg_code.TabIndex = 32;
             this.sg_code.TableName = null;
             this.sg_code.TextBoxEnable = false;

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

@@ -477,27 +477,18 @@ namespace UAS_LabelMachine
                     CollectData.Add(ItemData[i].ToString().ToUpper(), Input.Text.Split(sg_separator.Text.ToCharArray())[i]);
             }
             //首先判断当前采集的个数,如果采集的个数为1则不对数据进行分隔符验证
-            if (ItemData.Length == 1)
+            if (ItemData.Length > 0)
             {
-                CollectData.Clear();
-                CollectData.Add(ItemData[0].ToString().ToUpper(), Input.Text);
+                //CollectData.Clear();
+                //for (int i = 0; i < ItemData.Length; i++)
+                //{
+                //    CollectData.Add(ItemData[i].ToString().ToUpper(), Input.Text);
+                //}
                 //勾选了自动匹配调用该函数
                 if (AutoMatch.Checked)
                     SetAutoMatchRow();
                 //将筛选之后的值赋给Cell 
-                SetDataToCell(ref CollectData, ItemData[0].ToString().ToUpper());
-            }
-            //如果本次采集的数据分割后和当前的采集项目个数不一样提示用户错误
-            else if (CollectData.ToArray().Length == ItemData.Length)
-            {
-                for (int i = 0; i < ItemData.Length; i++)
-                {
-                    //勾选了自动匹配调用该函数
-                    if (AutoMatch.Checked)
-                        SetAutoMatchRow();
-                    //将筛选之后的值赋给Cell
-                    SetDataToCell(ref CollectData, ItemData[i].ToString().ToUpper());
-                }
+                SetDataToCell(ref CollectData);
             }
             else
             {
@@ -661,6 +652,7 @@ namespace UAS_LabelMachine
             else
                 Print.BarTender.SinglePrint(SingleFormat, SingleLabelParam, pib_id);
             LabelInf.Rows[CurrentRowIndex].Cells["pib_ifprint"].Value = true;
+            sdh.ExecuteSql("update prodibarcode set pib_ifprint=-1 where pib_id='" + pib_id + "'", "update");
         }
 
         /// <summary>
@@ -686,127 +678,136 @@ namespace UAS_LabelMachine
         /// </summary>
         /// <param name="data"></param>
         /// <param name="kind"></param>
-        private void SetDataToCell(ref Dictionary<string, string> setdata, string kind)
+        private void SetDataToCell(ref Dictionary<string, string> setdata)
         {
             int length = setdata.Count;
-            for (int j = 0; j < length; j++)
+            string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
+            string LotNo = "";
+            string DateCode = "";
+            foreach (var item in setdata)
             {
                 string[] data = new string[setdata.Count];
                 for (int i = 0; i < length; i++)
                 {
-                    data[i] = setdata[kind];
+                    data[i] = setdata[item.Key];
+                }
+                DataGridViewCell cell = null;
+                string Matchstr = "";
+                switch (item.Key)
+                {
+                    case "DATECODE":
+                        cell = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"];
+                        Matchstr = MatchStr(item.Value, "DATECODE");
+                        DateCode = Matchstr;
+                        length--;
+                        break;
+                    case "LOTNO":
+                        cell = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"];
+                        Matchstr = MatchStr(item.Value, "LOTNO");
+                        LotNo = Matchstr;
+                        length--;
+                        break;
+                    case "MPN":
+                        cell = LabelInf.Rows[CurrentRowIndex].Cells["pr_vendprodcode"];
+                        Matchstr = MatchStr(item.Value, "MPN");
+                        //采集的供应商号不匹配的话
+                        if (cell.Value.ToString() != Matchstr)
+                        {
+                            CollectVeProdCodePass = false;
+                            //添加需要重绘的Cell
+                            LabelInf.Refresh();
+                            MessageLog.AppendText(">>供应商物料编号不匹配\n", Color.Red);
+                        }
+                        else
+                        {
+                            LabelInf.Refresh();
+                            CollectVeProdCodePass = true;
+                        }
+                        length--;
+                        break;
+                    case "QTY":
+                        cell = LabelInf.Rows[CurrentRowIndex].Cells["pib_qty"];
+                        Matchstr = MatchStr(item.Value, "QTY");
+                        //如果采集的数量不相等的话
+                        if (cell.Value.ToString() != Matchstr)
+                        {
+                            CollectQTYPass = false;
+                            LabelInf.Refresh();
+                            MessageLog.AppendText(">>数量不匹配\n", Color.Red);
+                        }
+                        else
+                        {
+                            LabelInf.Refresh();
+                            CollectQTYPass = true;
+                        }
+                        length--;
+                        break;
+                    case "品牌":
+                        cell = LabelInf.Rows[CurrentRowIndex].Cells["pib_brand"];
+                        Matchstr = MatchStr(item.Value, "品牌");
+                        //如果采集的数量不相等的话
+                        if (cell.Value.ToString() != Matchstr)
+                        {
+                            CollectQTYPass = false;
+                            LabelInf.Refresh();
+                            MessageLog.AppendText(">>品牌不匹配\n", Color.Red);
+                        }
+                        else
+                        {
+                            LabelInf.Refresh();
+                            CollectQTYPass = true;
+                        }
+                        length--;
+                        break;
+                    default:
+                        break;
                 }
-                for (int i = 0; i < data.Length; i++)
+                //如果数据为空或者数据不为空的时候但是和需要采集的数据不相等的情况下进行采集
+                //MPN和QTY只做比较不需要赋值
+                if (cell.Value.ToString() == "" || cell.Value.ToString() != Matchstr)
                 {
-                    DataGridViewCell cell = null;
-                    string Matchstr = "";
-                    switch (kind.ToString().ToUpper())
+                    string MatchResult = "";
+                    if (item.Key != "MPN" && item.Key != "QTY" && item.Key != "品牌")
                     {
-                        case "DATECODE":
-                            cell = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"];
-                            Matchstr = MatchStr(data[j], "DATECODE");
-                            setdata.Remove("DATECODE");
-                            length--;
+                        DataTable dt = (DataTable)LabelInf.DataSource;
+                        cell.Value = Matchstr;
+                        MatchResult = "成功";
+                    }
+                    else
+                        MatchResult = "失败";
+                    switch (SiItem[item.Key]["si_kind"])
+                    {
+                        case "索引字符":
+                            LogManager.DoLog("采集项" + item.Key + ",匹配结果:【" + MatchResult + "】,匹配方式:" + SiItem[item.Key]["si_kind"] + ",使用字符" + SiItem[item.Key]["si_indexstring"] + ",匹配后字符串" + Matchstr);
                             break;
-                        case "LOTNO":
-                            cell = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"];
-                            Matchstr = MatchStr(data[j], "LOTNO");
-                            setdata.Remove("LOTNO");
-                            length--;
+                        case "起始位置":
+                            LogManager.DoLog("采集项" + item.Key + ",匹配结果:【" + MatchResult + "】,匹配方式:" + SiItem[item.Key]["si_kind"] + ",从第" + SiItem[item.Key]["si_index"] + "位开始匹配,匹配后字符串" + Matchstr);
                             break;
-                        case "MPN":
-                            cell = LabelInf.Rows[CurrentRowIndex].Cells["pr_vendprodcode"];
-                            Matchstr = MatchStr(data[j], "MPN");
-                            //采集的供应商号不匹配的话
-                            if (cell.Value.ToString() != Matchstr)
-                            {
-                                CollectVeProdCodePass = false;
-                                //添加需要重绘的Cell
-                                LabelInf.Refresh();
-                                MessageLog.AppendText(">>供应商物料编号不匹配\n", Color.Red);
-                            }
-                            else
-                            {
-                                LabelInf.Refresh();
-                                CollectVeProdCodePass = true;
-                            }
-                            setdata.Remove("MPN");
-                            length--;
+                        case "二次解析":
+                            LogManager.DoLog("采集项" + item.Key + ",匹配结果:【" + MatchResult + "】,匹配方式:" + SiItem[item.Key]["si_kind"] + ",匹配后字符串" + Matchstr);
                             break;
-                        case "QTY":
-                            cell = LabelInf.Rows[CurrentRowIndex].Cells["pib_qty"];
-                            Matchstr = MatchStr(data[j], "QTY");
-                            //如果采集的数量不相等的话
-                            if (cell.Value.ToString() != Matchstr)
-                            {
-                                CollectQTYPass = false;
-                                LabelInf.Refresh();
-                                MessageLog.AppendText(">>数量不匹配\n", Color.Red);
-                            }
-                            else
-                            {
-                                LabelInf.Refresh();
-                                CollectQTYPass = true;
-                            }
-                            setdata.Remove("QTY");
-                            length--;
-                            break;
-                        case "品牌":
-                            cell = LabelInf.Rows[CurrentRowIndex].Cells["pib_brand"];
-                            Matchstr = MatchStr(data[j], "品牌");
-                            //如果采集的数量不相等的话
-                            if (cell.Value.ToString() != Matchstr)
-                            {
-                                CollectQTYPass = false;
-                                LabelInf.Refresh();
-                                MessageLog.AppendText(">>品牌不匹配\n", Color.Red);
-                            }
-                            else
-                            {
-                                LabelInf.Refresh();
-                                CollectQTYPass = true;
-                            }
-                            setdata.Remove("品牌");
-                            length--;
+                        case "全部":
+                            LogManager.DoLog("采集项" + item.Key + ",匹配结果:【" + MatchResult + "】,匹配方式:" + SiItem[item.Key]["si_kind"] + ",匹配后字符串" + Matchstr);
                             break;
                         default:
                             break;
                     }
-                    //如果数据为空或者数据不为空的时候但是和需要采集的数据不相等的情况下进行采集
-                    //MPN和QTY只做比较不需要赋值
-                    if (cell.Value.ToString() == "" || cell.Value.ToString() != Matchstr)
-                    {
-                        string MatchResult = "";
-                        if (kind != "MPN" && kind != "QTY" && kind != "品牌")
-                        {
-                            DataTable dt = (DataTable)LabelInf.DataSource;
-                            cell.Value = Matchstr;
-                            MatchResult = "成功";
-                        }
-                        else
-                            MatchResult = "失败";
-                        switch (SiItem[kind]["si_kind"])
-                        {
-                            case "索引字符":
-                                LogManager.DoLog("采集项" + kind + ",匹配结果:【" + MatchResult + "】,匹配方式:" + SiItem[kind]["si_kind"] + ",使用字符" + SiItem[kind]["si_indexstring"] + ",匹配后字符串" + Matchstr);
-                                break;
-                            case "起始位置":
-                                LogManager.DoLog("采集项" + kind + ",匹配结果:【" + MatchResult + "】,匹配方式:" + SiItem[kind]["si_kind"] + ",从第" + SiItem[kind]["si_index"] + "位开始匹配,匹配后字符串" + Matchstr);
-                                break;
-                            case "二次解析":
-                                LogManager.DoLog("采集项" + kind + ",匹配结果:【" + MatchResult + "】,匹配方式:" + SiItem[kind]["si_kind"] + ",匹配后字符串" + Matchstr);
-                                break;
-                            case "全部":
-                                LogManager.DoLog("采集项" + kind + ",匹配结果:【" + MatchResult + "】,匹配方式:" + SiItem[kind]["si_kind"] + ",匹配后字符串" + Matchstr);
-                                break;
-                            default:
-                                break;
-                        }
-                    }
-                    else
-                        LogManager.DoLog("采集项" + kind + ",匹配结果:【成功】,匹配方式:" + SiItem[kind]["si_kind"] + ",,匹配后字符串" + Matchstr);
                 }
+                else
+                    LogManager.DoLog("采集项" + item.Key + ",匹配结果:【成功】,匹配方式:" + SiItem[item.Key]["si_kind"] + ",,匹配后字符串" + Matchstr);
+            }
+            sql.Clear();
+            sql.Append("update prodiobarcode set pib_ifpick=-1");
+            if (LotNo != "")
+            {
+                sql.Append(",pib_lotno='" + LotNo + "'");
+            }
+            if (DateCode != "")
+            {
+                sql.Append(",pib_datecode='" + DateCode + "' ");
             }
+            sql.Append("where pib_id='" + pib_id + "'");
+            sdh.ExecuteSql(sql.ToString(), "update");
             //添加外箱号,如果外箱号的箱内容量不为0并且已经采集完成
             SetOutBoxCode2(false);
         }
@@ -1217,6 +1218,7 @@ namespace UAS_LabelMachine
                             }
                             //勾选为已打印
                             LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
+                            sdh.ExecuteSql("update prodibarcode set pib_ifprint=-1 where pib_id='" + pib_id + "'", "update");
                         }
                         catch (Exception ex) { LogManager.DoLog(ex.Message); }
                     }