Browse Source

优化获取文件速度,修改细节BUG

章政 8 years ago
parent
commit
44c724f678

File diff suppressed because it is too large
+ 226 - 199
UAS-出货标签管理/UAS_出货标签管理.Designer.cs


+ 57 - 48
UAS-出货标签管理/UAS_出货标签管理.cs

@@ -15,6 +15,7 @@ using UAS_LabelMachine.CustomControl.GroupBoxWithBorder;
 using UAS_LabelMachine.PublicForm;
 using System.Threading;
 using System.IO;
+using System.Globalization;
 
 namespace UAS_LabelMachine
 {
@@ -133,6 +134,10 @@ namespace UAS_LabelMachine
         //使用二维数组进行排序
         ArrayList<ArrayList<string>> ScanData;
         ArrayList<string> GetData;
+        /// <summary>
+        /// 是否通过选择Combox来改变打开的文件
+        /// </summary>
+        bool ComBoxClickChangeLabelDoc = false;
 
         public UAS_出货标签打印()
         {
@@ -169,9 +174,7 @@ namespace UAS_LabelMachine
             pi_inoutno.Focus();
             //将本地读取的打印机设置进Combox,并选中默认打印机
             if (User.UserAccountType == "admin")
-            {
                 PowerSetting.Visible = true;
-            }
             MidBoxCacheData = new DataTable();
             SingleBoxCacheData = new DataTable();
             sg_code.FormName = Name;
@@ -993,14 +996,15 @@ namespace UAS_LabelMachine
         /// </summary>
         private void GetInOutInfAndLabelFile()
         {
+            ComBoxClickChangeLabelDoc = false;
             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 ");
             sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
             sql.Append("and  pi_inoutno='" + pi_inoutno.Text + "') or( cl_custcode is null)) and cl_labeltype='单盘' order by cl_custcode");
             dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
-            SingleLabelCombox.DataSource = dt;
             SingleLabelCombox.DisplayMember = "cl_labelname";
             SingleLabelCombox.ValueMember = "la_id";
+            SingleLabelCombox.DataSource = dt;
             if (SingleDoc != null)
                 SingleDoc.Close();
             if (!GetGridOnly.Checked)
@@ -1020,9 +1024,9 @@ namespace UAS_LabelMachine
             sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
             sql.Append("and  pi_inoutno='" + pi_inoutno.Text + "') or( cl_custcode is null)) and cl_labeltype='中盒' order by cl_custcode");
             dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
-            MidLabelCombox.DataSource = dt;
             MidLabelCombox.DisplayMember = "cl_labelname";
             MidLabelCombox.ValueMember = "la_id";
+            MidLabelCombox.DataSource = dt;
             if (MidDoc != null)
                 MidDoc.Close();
             if (!GetGridOnly.Checked)
@@ -1036,21 +1040,15 @@ namespace UAS_LabelMachine
                         BaseUtil.GetLabelUrl(LabelUrl, LabelName, time);
                 }
             if (MidLabelCombox.Text != "")
-            {
-                if (MidDoc != null)
-                    MidDoc.Close();
                 MidDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + MidLabelCombox.Text);
-            }
             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 ");
             sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
             sql.Append("and  pi_inoutno='" + pi_inoutno.Text + "') or( cl_custcode is null)) and cl_labeltype='外箱' order by cl_custcode");
             dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
-            OutBoxCombox.DataSource = dt;
             OutBoxCombox.DisplayMember = "cl_labelname";
             OutBoxCombox.ValueMember = "la_id";
-            if (OutBoxDoc != null)
-                OutBoxDoc.Close();
+            OutBoxCombox.DataSource = dt;
             if (!GetGridOnly.Checked)
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
@@ -1067,6 +1065,7 @@ namespace UAS_LabelMachine
                     OutBoxDoc.Close();
                 OutBoxDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + OutBoxCombox.Text);
             }
+            ComBoxClickChangeLabelDoc = true;
         }
 
         /// <summary>
@@ -1283,7 +1282,6 @@ namespace UAS_LabelMachine
             int pib_id_length = pib_id_arr.Length;
             //将所有的列存在在这里
             List<DataTable> AllSingleBoxCacheData = new List<DataTable>();
-
             //每五百条拼接一次条件
             int fivehundred_count = pib_id_length / 500 + 1;
             //当前打印的索引
@@ -1309,10 +1307,10 @@ namespace UAS_LabelMachine
                 if (i + 1 != fivehundred_count)
                     pib_id_string.Append(" or pib_id in ");
             }
-
             //手动添加ID列
             DataColumn datacolumn = new DataColumn("pib_id");
-            SingleBoxCacheData.Columns.Add(datacolumn);
+            if (!SingleBoxCacheData.Columns.Contains("pib_id"))
+                SingleBoxCacheData.Columns.Add(datacolumn);
             //获取打印的SQL
             for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
             {
@@ -1397,8 +1395,10 @@ namespace UAS_LabelMachine
             //手动添加ID列
             DataColumn IDColumn = new DataColumn("pib_id");
             DataColumn OutBoxColumn = new DataColumn("pib_outboxcode1");
-            MidBoxCacheData.Columns.Add(IDColumn);
-            MidBoxCacheData.Columns.Add(OutBoxColumn);
+            if (!MidBoxCacheData.Columns.Contains("pib_id"))
+                MidBoxCacheData.Columns.Add(IDColumn);
+            if (!MidBoxCacheData.Columns.Contains("pib_outboxcode1"))
+                MidBoxCacheData.Columns.Add(OutBoxColumn);
             string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
             DataTable dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
             for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
@@ -2029,21 +2029,21 @@ namespace UAS_LabelMachine
         /// <param name="e"></param>
         private void LabelInf_CellValueChanged(object sender, DataGridViewCellEventArgs e)
         {
-            //if (LabelInf.Columns[e.ColumnIndex].Name == "pib_datecode")
-            //{
-            //    string datecode = LabelInf.Rows[e.RowIndex].Cells["pib_datecode"].Value.ToString();
-            //    try
-            //    {
-            //        System.DateTime dt = System.DateTime.ParseExact(datecode, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
-            //        GregorianCalendar gc = new GregorianCalendar();
-            //        int weekOfYear = gc.GetWeekOfYear(dt, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
-            //        if (weekOfYear < 10)
-            //            LabelInf.Rows[e.RowIndex].Cells["DateCode1"].Value = dt.Year.ToString().Substring(2, 2) + "0" + weekOfYear;
-            //        else
-            //            LabelInf.Rows[e.RowIndex].Cells["DateCode1"].Value = dt.Year.ToString().Substring(2, 2) + weekOfYear;
-            //    }
-            //    catch (Exception) { }
-            //}
+            if (LabelInf.Columns[e.ColumnIndex].Name == "pib_datecode")
+            {
+                string datecode = LabelInf.Rows[e.RowIndex].Cells["pib_datecode"].Value.ToString();
+                try
+                {
+                    System.DateTime dt = System.DateTime.ParseExact(datecode, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
+                    GregorianCalendar gc = new GregorianCalendar();
+                    int weekOfYear = gc.GetWeekOfYear(dt, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
+                    if (weekOfYear < 10)
+                        LabelInf.Rows[e.RowIndex].Cells["DateCode1"].Value = dt.Year.ToString().Substring(2, 2) + "0" + weekOfYear;
+                    else
+                        LabelInf.Rows[e.RowIndex].Cells["DateCode1"].Value = dt.Year.ToString().Substring(2, 2) + weekOfYear;
+                }
+                catch (Exception) { }
+            }
         }
 
         private void AllCollected_Click(object sender, EventArgs e)
@@ -2051,13 +2051,13 @@ namespace UAS_LabelMachine
             if (AllCollect == false)
             {
                 foreach (DataGridViewRow dr in LabelInf.Rows)
-                    dr.Cells[CloumnCount - 2].Value = true;
+                    dr.Cells[1].Value = true;
                 AllCollect = true;
             }
             else
             {
                 foreach (DataGridViewRow dr in LabelInf.Rows)
-                    dr.Cells[CloumnCount - 2].Value = false;
+                    dr.Cells[1].Value = false;
                 AllCollect = false;
             }
         }
@@ -2123,12 +2123,15 @@ namespace UAS_LabelMachine
         {
             try
             {
-                if (SingleDoc != null)
-                    SingleDoc.Close();
-                if (SingleLabelCombox.Text != "" && SingleLabelCombox.SelectedValue != null && !GetGridOnly.Checked)
+                if (ComBoxClickChangeLabelDoc)
                 {
-                    System.DateTime time = Convert.ToDateTime(SingleLabelCombox.SelectedValue.ToString().Split('#')[2]);
-                    SingleDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(SingleLabelCombox.SelectedValue.ToString().Split('#')[1], SingleLabelCombox.Text, time));
+                    if (SingleDoc != null)
+                        SingleDoc.Close();
+                    if (SingleLabelCombox.Text != "" && SingleLabelCombox.SelectedValue != null && !GetGridOnly.Checked)
+                    {
+                        System.DateTime time = Convert.ToDateTime(SingleLabelCombox.SelectedValue.ToString().Split('#')[2]);
+                        SingleDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(SingleLabelCombox.SelectedValue.ToString().Split('#')[1], SingleLabelCombox.Text, time));
+                    }
                 }
             }
             catch (Exception) { }
@@ -2143,12 +2146,15 @@ namespace UAS_LabelMachine
         {
             try
             {
-                if (MidDoc != null)
-                    MidDoc.Close();
-                if (MidLabelCombox.Text != "" && MidLabelCombox.SelectedValue != null && !GetGridOnly.Checked)
+                if (ComBoxClickChangeLabelDoc)
                 {
-                    System.DateTime time = Convert.ToDateTime(MidLabelCombox.SelectedValue.ToString().Split('#')[2]);
-                    MidDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(MidLabelCombox.SelectedValue.ToString().Split('#')[1], MidLabelCombox.Text, time));
+                    if (MidDoc != null)
+                        MidDoc.Close();
+                    if (MidLabelCombox.Text != "" && MidLabelCombox.SelectedValue != null && !GetGridOnly.Checked)
+                    {
+                        System.DateTime time = Convert.ToDateTime(MidLabelCombox.SelectedValue.ToString().Split('#')[2]);
+                        MidDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(MidLabelCombox.SelectedValue.ToString().Split('#')[1], MidLabelCombox.Text, time));
+                    }
                 }
             }
             catch (Exception) { }
@@ -2163,12 +2169,15 @@ namespace UAS_LabelMachine
         {
             try
             {
-                if (OutBoxDoc != null)
-                    OutBoxDoc.Close();
-                if (OutBoxCombox.Text != "" && OutBoxCombox.SelectedValue != null && !GetGridOnly.Checked)
+                if (ComBoxClickChangeLabelDoc)
                 {
-                    System.DateTime time = Convert.ToDateTime(OutBoxCombox.SelectedValue.ToString().Split('#')[2]);
-                    OutBoxDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(OutBoxCombox.SelectedValue.ToString().Split('#')[1], OutBoxCombox.Text, time));
+                    if (OutBoxDoc != null)
+                        OutBoxDoc.Close();
+                    if (OutBoxCombox.Text != "" && OutBoxCombox.SelectedValue != null && !GetGridOnly.Checked)
+                    {
+                        System.DateTime time = Convert.ToDateTime(OutBoxCombox.SelectedValue.ToString().Split('#')[2]);
+                        OutBoxDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(OutBoxCombox.SelectedValue.ToString().Split('#')[1], OutBoxCombox.Text, time));
+                    }
                 }
             }
             catch (Exception) { }

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