Forráskód Böngészése

不区分标签参数名大小写

章政 6 éve
szülő
commit
59c11e9ad7
1 módosított fájl, 29 hozzáadás és 64 törlés
  1. 29 64
      UAS-出货标签管理(吉利通)/UAS_出货标签管理.cs

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

@@ -15,7 +15,6 @@ using UAS_LabelMachine.PublicForm;
 using System.Threading;
 using System.IO;
 using System.Globalization;
-using System.Threading.Tasks;
 
 namespace UAS_LabelMachine
 {
@@ -120,7 +119,6 @@ namespace UAS_LabelMachine
         bool GetPackingCode = false;
         /*用于存放采集项目的Grid信息*/
         Dictionary<string, Dictionary<string, string>> SiItem;
-        int CloumnCount = 0;
         /*需要重绘的Cell*/
         Dictionary<DataGridViewCell, bool> PaintCell = new Dictionary<DataGridViewCell, bool>();
         //使用二维数组进行排序
@@ -131,12 +129,6 @@ namespace UAS_LabelMachine
         /// </summary>
         bool ComBoxClickChangeLabelDoc = false;
 
-        List<string> SingleParam = new List<string>();
-
-        List<string> MidParam = new List<string>();
-
-        List<string> OutParam = new List<string>();
-
         DataTable Attach;
 
         public UAS_出货标签打印(string Master)
@@ -166,7 +158,6 @@ namespace UAS_LabelMachine
             LogManager.DoLog("程序启动,登陆人员【" + User.UserName + "】");
             dh = SystemInf.dh;
             CheckForIllegalCrossThreadCalls = false;
-            CloumnCount = LabelInf.Columns.Count;
             pi_inoutno.Focus();
             sg_code.FormName = Name;
             sg_code.SetValueField = new string[] { "sg_code" };
@@ -194,14 +185,6 @@ namespace UAS_LabelMachine
             Height = ScreenArea.Height;
             MidBoxCapacity.Value = Properties.Settings.Default.MidBoxCapacity;
             OutboxCapacity.Value = Properties.Settings.Default.OutboxCapacity;
-            //怡海能达添加的特殊字段
-            if (DataHelper.DBConnectionString.Contains("sz.hi-mantech.com") || DataHelper.DBConnectionString.Contains("192.168.1.200"))
-            {
-                pib_datecode1.Visible = true;
-                SingleLabelAutoPrint.Checked = true;
-                MidLabelAutoPrint.Checked = true;
-                pib_madein.Visible = true;
-            }
             asc.controllInitializeSize(this);
             asc.controlAutoSize(this);
             //实例化打印进程
@@ -655,11 +638,11 @@ namespace UAS_LabelMachine
             DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString().ToLower().Replace("{pib_id}", pib_id), "select");
             for (int i = 0; i < SingleDoc.Variables.FreeVariables.Count; i++)
             {
-                if (dt.Columns.Contains(SingleDoc.Variables.FreeVariables.Item(i + 1).Name))
-                    SingleDoc.Variables.FreeVariables.Item(i + 1).Value = dt.Rows[0][SingleDoc.Variables.FreeVariables.Item(i + 1).Name].ToString();
+                if (dt.Columns.Contains(SingleDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower()))
+                    SingleDoc.Variables.FreeVariables.Item(i + 1).Value = dt.Rows[0][SingleDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower()].ToString();
                 if (SingleDoc.Variables.FreeVariables.Item(i + 1).Value == "")
                 {
-                    DataRow[] dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(i + 1).Name + "'");
+                    DataRow[] dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower() + "'");
                     if (dr1.Length > 0)
                         SingleDoc.Variables.FreeVariables.Item(i + 1).Value = dr1[0]["lp_sql"].ToString();
                 }
@@ -1000,10 +983,6 @@ namespace UAS_LabelMachine
             {
                 SingleDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + SingleLabelCombox.Text);
                 SingleLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + SingleLabelCombox.SelectedValue.ToString().Split('#')[0], "select");
-                for (int i = 0; i < SingleDoc.Variables.FreeVariables.Count; i++)
-                {
-                    SingleParam.Add(SingleDoc.Variables.FreeVariables.Item(i + 1).Name);
-                }
             }
             sql.Clear();
             sql.Append("select to_char(nvl(cl_date,sysdate),'YYYY-MM-DD HH24:Mi:SS') cl_date,cl_labelname,cl_isdefault,la_id||'#'||cl_labelurl||'#'||to_char(cl_date,'YYYY-MM-DD HH24:Mi:SS')  la_id,cl_custcode from customerlabel left join prodinout on pi_cardcode=cl_custcode ");
@@ -1194,13 +1173,11 @@ namespace UAS_LabelMachine
                             DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString().ToLower().Replace("{pib_id}", pib_id), "select");
                             for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
                             {
-                                if (dt.Columns.Contains(SingleDoc.Variables.FreeVariables.Item(j + 1).Name))
-                                {
-                                    SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dt.Rows[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
-                                }
+                                if (dt.Columns.Contains(SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower()))
+                                    SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dt.Rows[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower()].ToString();
                                 if (SingleDoc.Variables.FreeVariables.Item(j + 1).Value == "")
                                 {
-                                    DataRow[] dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
+                                    DataRow[] dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower() + "'");
                                     if (dr1.Length > 0)
                                         SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
                                 }
@@ -1454,40 +1431,28 @@ namespace UAS_LabelMachine
 
         private void MidBoxCodePrint(int rowindex)
         {
-            string[] arg = MidBoxArgument.ToArray();
-            for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
+            //获取对应行的pib_id
+            string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
+            string pib_outboxcode1 = LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString();
+            sql.Clear();
+            sql.Append("select * from ");
+            for (int i = 0; i < MidLabelParam.Rows.Count; i++)
             {
-                //将维护的模板参数和模板本身的参数名称进行比对
-                for (int k = 0; k < MidLabelParam.Rows.Count; k++)
+                if (i != MidLabelParam.Rows.Count - 1)
+                    sql.Append("(" + MidLabelParam.Rows[i]["lp_sql"].ToString() + "),");
+                else
+                    sql.Append("(" + MidLabelParam.Rows[i]["lp_sql"].ToString() + ")");
+            }
+            DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString().ToLower().Replace("{pib_id}", pib_id).Replace("{pib_outboxcode1}", pib_outboxcode1), "select");
+            for (int i = 0; i < MidDoc.Variables.FreeVariables.Count; i++)
+            {
+                if (dt.Columns.Contains(MidDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower()))
+                    MidDoc.Variables.FreeVariables.Item(i + 1).Value = dt.Rows[0][MidDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower()].ToString();
+                if (MidDoc.Variables.FreeVariables.Item(i + 1).Value == "")
                 {
-                    //名称相等的时候,取SQL进行值的查询
-                    if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == MidLabelParam.Rows[k]["lp_name"].ToString())
-                    {
-                        //获取对应行的pib_id
-                        string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
-                        string pib_outboxcode1 = LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString();
-                        sql.Clear();
-                        sql.Append("select * from ");
-                        for (int i = 0; i < MidLabelParam.Rows.Count; i++)
-                        {
-                            if (i != MidLabelParam.Rows.Count - 1)
-                                sql.Append("(" + MidLabelParam.Rows[i]["lp_sql"].ToString() + "),");
-                            else
-                                sql.Append("(" + MidLabelParam.Rows[i]["lp_sql"].ToString() + ")");
-                        }
-                        DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString().ToLower().Replace("{pib_id}", pib_id).Replace("{pib_outboxcode1}", pib_outboxcode1), "select");
-                        for (int i = 0; i < MidDoc.Variables.FreeVariables.Count; i++)
-                        {
-                            if (dt.Columns.Contains(MidDoc.Variables.FreeVariables.Item(i + 1).Name))
-                                MidDoc.Variables.FreeVariables.Item(i + 1).Value = dt.Rows[0][MidDoc.Variables.FreeVariables.Item(i + 1).Name].ToString();
-                            if (MidDoc.Variables.FreeVariables.Item(j + 1).Value == "")
-                            {
-                                DataRow[] dr1 = Attach.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
-                                if (dr1.Length > 0)
-                                    MidDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
-                            }
-                        }
-                    }
+                    DataRow[] dr1 = Attach.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower()+ "'");
+                    if (dr1.Length > 0)
+                        MidDoc.Variables.FreeVariables.Item(i + 1).Value = dr1[0]["lp_sql"].ToString();
                 }
             }
             MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
@@ -1514,11 +1479,11 @@ namespace UAS_LabelMachine
             DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString().ToLower().Replace("{pib_id}", pib_id).Replace("{pib_outboxcode2}", pib_outboxcode2), "select");
             for (int i = 0; i < OutBoxDoc.Variables.FreeVariables.Count; i++)
             {
-                if (dt.Columns.Contains(OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name))
-                    OutBoxDoc.Variables.FreeVariables.Item(i + 1).Value = dt.Rows[0][OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name].ToString();
+                if (dt.Columns.Contains(OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower()))
+                    OutBoxDoc.Variables.FreeVariables.Item(i + 1).Value = dt.Rows[0][OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower()].ToString();
                 if (OutBoxDoc.Variables.FreeVariables.Item(i + 1).Value == "")
                 {
-                    DataRow[] dr1 = Attach.Select("lp_name='" + OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name + "'");
+                    DataRow[] dr1 = Attach.Select("lp_name='" + OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower() + "'");
                     if (dr1.Length > 0)
                         OutBoxDoc.Variables.FreeVariables.Item(i + 1).Value = dr1[0]["lp_sql"].ToString();
                 }