فهرست منبع

添加选行打印功能

章政 8 سال پیش
والد
کامیت
42dfb274e9
2فایلهای تغییر یافته به همراه92 افزوده شده و 52 حذف شده
  1. 14 14
      UAS-出货标签管理/UAS_出货标签管理.Designer.cs
  2. 78 38
      UAS-出货标签管理/UAS_出货标签管理.cs

+ 14 - 14
UAS-出货标签管理/UAS_出货标签管理.Designer.cs

@@ -763,7 +763,7 @@
             // 
             this.label18.AutoSize = true;
             this.label18.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label18.Location = new System.Drawing.Point(66, 146);
+            this.label18.Location = new System.Drawing.Point(69, 150);
             this.label18.Name = "label18";
             this.label18.Size = new System.Drawing.Size(13, 17);
             this.label18.TabIndex = 90;
@@ -797,7 +797,7 @@
             // 
             this.label16.AutoSize = true;
             this.label16.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label16.Location = new System.Drawing.Point(65, 73);
+            this.label16.Location = new System.Drawing.Point(68, 76);
             this.label16.Name = "label16";
             this.label16.Size = new System.Drawing.Size(13, 17);
             this.label16.TabIndex = 87;
@@ -1328,7 +1328,7 @@
             // 
             this.SingleLabelAutoPrint.AutoSize = true;
             this.SingleLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.SingleLabelAutoPrint.Location = new System.Drawing.Point(2, 105);
+            this.SingleLabelAutoPrint.Location = new System.Drawing.Point(9, 110);
             this.SingleLabelAutoPrint.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.SingleLabelAutoPrint.Name = "SingleLabelAutoPrint";
             this.SingleLabelAutoPrint.Size = new System.Drawing.Size(75, 21);
@@ -1373,7 +1373,7 @@
             // 
             this.MidLabelNum.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.MidLabelNum.ID = null;
-            this.MidLabelNum.Location = new System.Drawing.Point(51, 160);
+            this.MidLabelNum.Location = new System.Drawing.Point(51, 165);
             this.MidLabelNum.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.MidLabelNum.Name = "MidLabelNum";
             this.MidLabelNum.Size = new System.Drawing.Size(64, 23);
@@ -1386,7 +1386,7 @@
             // 
             this.label5.AutoSize = true;
             this.label5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label5.Location = new System.Drawing.Point(7, 157);
+            this.label5.Location = new System.Drawing.Point(7, 167);
             this.label5.Name = "label5";
             this.label5.Size = new System.Drawing.Size(32, 17);
             this.label5.TabIndex = 50;
@@ -1396,7 +1396,7 @@
             // 
             this.label4.AutoSize = true;
             this.label4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label4.Location = new System.Drawing.Point(7, 129);
+            this.label4.Location = new System.Drawing.Point(7, 138);
             this.label4.Name = "label4";
             this.label4.Size = new System.Drawing.Size(32, 17);
             this.label4.TabIndex = 49;
@@ -1415,7 +1415,7 @@
             // 
             this.label15.AutoSize = true;
             this.label15.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label15.Location = new System.Drawing.Point(90, 128);
+            this.label15.Location = new System.Drawing.Point(94, 137);
             this.label15.Name = "label15";
             this.label15.Size = new System.Drawing.Size(20, 17);
             this.label15.TabIndex = 40;
@@ -1424,7 +1424,7 @@
             // MidBoxCapacity
             // 
             this.MidBoxCapacity.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.MidBoxCapacity.Location = new System.Drawing.Point(52, 130);
+            this.MidBoxCapacity.Location = new System.Drawing.Point(52, 135);
             this.MidBoxCapacity.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.MidBoxCapacity.Name = "MidBoxCapacity";
             this.MidBoxCapacity.Size = new System.Drawing.Size(38, 23);
@@ -1446,7 +1446,7 @@
             // 
             this.MidLabelAutoPrint.AutoSize = true;
             this.MidLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.MidLabelAutoPrint.Location = new System.Drawing.Point(10, 105);
+            this.MidLabelAutoPrint.Location = new System.Drawing.Point(10, 108);
             this.MidLabelAutoPrint.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.MidLabelAutoPrint.Name = "MidLabelAutoPrint";
             this.MidLabelAutoPrint.Size = new System.Drawing.Size(75, 21);
@@ -1533,7 +1533,7 @@
             // 
             this.label10.AutoSize = true;
             this.label10.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label10.Location = new System.Drawing.Point(8, 181);
+            this.label10.Location = new System.Drawing.Point(8, 182);
             this.label10.Name = "label10";
             this.label10.Size = new System.Drawing.Size(32, 17);
             this.label10.TabIndex = 90;
@@ -1556,7 +1556,7 @@
             // 
             this.label9.AutoSize = true;
             this.label9.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label9.Location = new System.Drawing.Point(83, 205);
+            this.label9.Location = new System.Drawing.Point(88, 212);
             this.label9.Name = "label9";
             this.label9.Size = new System.Drawing.Size(32, 17);
             this.label9.TabIndex = 88;
@@ -1579,7 +1579,7 @@
             // 
             this.label8.AutoSize = true;
             this.label8.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label8.Location = new System.Drawing.Point(8, 210);
+            this.label8.Location = new System.Drawing.Point(8, 212);
             this.label8.Name = "label8";
             this.label8.Size = new System.Drawing.Size(32, 17);
             this.label8.TabIndex = 83;
@@ -1589,7 +1589,7 @@
             // 
             this.label6.AutoSize = true;
             this.label6.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label6.Location = new System.Drawing.Point(8, 149);
+            this.label6.Location = new System.Drawing.Point(8, 151);
             this.label6.Name = "label6";
             this.label6.Size = new System.Drawing.Size(32, 17);
             this.label6.TabIndex = 87;
@@ -1646,7 +1646,7 @@
             // 
             this.OutBoxLabelAutoPrint.AutoSize = true;
             this.OutBoxLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.OutBoxLabelAutoPrint.Location = new System.Drawing.Point(4, 105);
+            this.OutBoxLabelAutoPrint.Location = new System.Drawing.Point(11, 112);
             this.OutBoxLabelAutoPrint.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.OutBoxLabelAutoPrint.Name = "OutBoxLabelAutoPrint";
             this.OutBoxLabelAutoPrint.Size = new System.Drawing.Size(75, 21);

+ 78 - 38
UAS-出货标签管理/UAS_出货标签管理.cs

@@ -1140,7 +1140,9 @@ namespace UAS_LabelMachine
                     {
                         //如果不存在中盒号则进行添加
                         if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
+                        {
                             MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
+                        }
                     }
                 }
                 if (SingleID.ToArray().Length == 0)
@@ -1153,13 +1155,7 @@ namespace UAS_LabelMachine
                     GetSingleBoxData();
                 if (MidBoxCacheData.Rows.Count == 0)
                 {
-                    try
-                    {
-                        GetMidBoxData();
-                    }
-                    catch (Exception)
-                    {
-                    }
+                    GetMidBoxData();
                 }
                 for (int i = 0; i < LabelInf.RowCount; i++)
                 {
@@ -1226,25 +1222,25 @@ namespace UAS_LabelMachine
                             //保存参数打印
                             SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
                             SingleDoc.PrintDocument();
-                            //勾选为已打印
-                            LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
-                        }
-                        catch (Exception ex) { LogManager.DoLog(ex.Message); }
-                    }
-                    if (MidLabelAutoPrint.Checked && LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue != null && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True")
-                    {
-                        //判断当前行的盒号和下一行不相等或者已经是最后一行了
-                        if (i + 1 == LabelInf.RowCount || LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() != LabelInf.Rows[i + 1 == LabelInf.RowCount ? i : i + 1].Cells["pib_outboxcode1"].Value.ToString())
-                        {
-                            if (outboxcode1[LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()])
+                            if (MidLabelAutoPrint.Checked)
                             {
-                                if (MidLabelCombox.SelectedValue != null)
+                                //判断当前行的盒号和下一行不相等或者已经是最后一行了
+                                if (i + 1 == LabelInf.RowCount || LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() != LabelInf.Rows[i + 1 == LabelInf.RowCount ? i : i + 1].Cells["pib_outboxcode1"].Value.ToString())
                                 {
-                                    string la_id_mid = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
-                                    MidBoxCodePrint(la_id_mid, CurrentRowIndex);
+                                    if (outboxcode1[LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()])
+                                    {
+                                        if (MidLabelCombox.SelectedValue != null)
+                                        {
+                                            string la_id_mid = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
+                                            MidBoxCodePrint(la_id_mid, CurrentRowIndex);
+                                        }
+                                    }
                                 }
                             }
+                            //勾选为已打印
+                            LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
                         }
+                        catch (Exception ex) { LogManager.DoLog(ex.Message); }
                     }
                 }
                 dh.BatchInsert("update prodiobarcode set pib_printdate=sysdate where pib_id=:pib_id", new string[] { "pib_id" }, SingleID.ToArray());
@@ -1359,6 +1355,7 @@ namespace UAS_LabelMachine
                             sql = sql.Substring(0, sql.LastIndexOf("="));
                             sql = sql + " in (select distinct pib_outboxcode1 from PRODIOBARCODE where pib_inoutno='" + pi_inoutno.Text + "')" + " and pib_inoutno='" + pi_inoutno.Text + "' order by to_number(pib_outboxcode1)";
                         }
+                        Console.WriteLine(sql);
                         DataTable temp = dh.getFieldsDatasByCondition(sql);
                         temp.Columns[0].ColumnName = MidDoc.Variables.FreeVariables.Item(j + 1).Name;
                         AllMidBoxCacheData.Add(temp);
@@ -1369,14 +1366,17 @@ namespace UAS_LabelMachine
             //将所有数据写入到CacheData中
             if (Temp.Length > 0)
             {
-                for (int i = 0; i < Temp[0].Rows.Count; i++)
+                for (int i = 0; i < pib_id_arr.Length; i++)
                 {
                     DataRow dr = MidBoxCacheData.NewRow();
                     dr["pib_id"] = pib_id_arr[i];
                     dr["pib_outboxcode1"] = pib_outbox_arr[i];
                     //由于之前加了一个ID列和箱号,导致j从2开始
                     for (int j = 2; j < MidBoxCacheData.Columns.Count; j++)
-                        dr[Temp[j - 2].Columns[0].ColumnName] = Temp[j - 2].Rows[i][0].ToString();
+                    {
+                        //选出勾选的中盒号
+                        dr[Temp[j - 2].Columns[0].ColumnName] = Temp[j - 2].Select("PIB_OUTBOXCODE1='" + pib_outbox_arr[i] + "'")[0][0];
+                    }
                     MidBoxCacheData.Rows.Add(dr);
                 }
             }
@@ -1386,29 +1386,32 @@ namespace UAS_LabelMachine
         {
             if (SingleLabelCombox.Text != "")
             {
-                try
+                if (SingleBoxBegin.Text != "" || SingleBoxEnd.Text != "")
                 {
-                    int begin = int.Parse(SingleBoxBegin.Text);
-                    int end = int.Parse(SingleBoxEnd.Text);
-                    if (begin > 0 && end < LabelInf.Rows.Count)
+                    try
                     {
-                        for (int i = begin - 1; i < end; i++)
+                        int begin = int.Parse(SingleBoxBegin.Text);
+                        int end = int.Parse(SingleBoxEnd.Text);
+                        if (begin > 0 && end <= LabelInf.Rows.Count)
                         {
-                            LabelInf.Rows[i].Cells["Choose"].Value = true;
-                            LabelInf.Rows[i].Cells["pib_ifpick"].Value = true;
+                            for (int i = begin - 1; i < end; i++)
+                            {
+                                LabelInf.Rows[i].Cells["Choose"].Value = true;
+                                LabelInf.Rows[i].Cells["pib_ifpick"].Value = true;
+                            }
+                        }
+                        else
+                        {
+                            MessageBox.Show("单盘打印范围错误");
+                            return;
                         }
                     }
-                    else
+                    catch (Exception)
                     {
                         MessageBox.Show("单盘打印范围错误");
                         return;
                     }
                 }
-                catch (Exception)
-                {
-                    MessageBox.Show("单盘打印范围错误");
-                    return;
-                }
                 thread = new Thread(SingleBoxPrint);
                 stw = new SetLoadingWindow(thread, "正在打印单盘");
                 BaseUtil.SetFormCenter(stw);
@@ -1423,13 +1426,50 @@ namespace UAS_LabelMachine
             //未输入内容打印全部中盒
             if (MidLabelNum.Text == "")
             {
+                int begin = 0;
+                int end = 0;
+                if (MidBoxBegin.Text != "" || MidBoxEnd.Text != "")
+                {
+                    try
+                    {
+                        begin = int.Parse(MidBoxBegin.Text);
+                        end = int.Parse(MidBoxEnd.Text);
+                        int minmidbox = int.Parse(LabelInf.Rows[0].Cells["pib_outboxcode1"].Value.ToString());
+                        int maxmidbox = int.Parse(LabelInf.Rows[LabelInf.Rows.Count - 1].Cells["pib_outboxcode1"].Value.ToString());
+                        if (begin > minmidbox && end <= maxmidbox)
+                        {
+                            //设置中盒打印范围的行号
+                            for (int i = 0; i < LabelInf.Rows.Count; i++)
+                            {
+                                if (LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() == MidBoxBegin.Text)
+                                {
+                                    begin = i;
+                                }
+                                if (LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() == MidBoxEnd.Text)
+                                {
+                                    end = i;
+                                }
+                            }
+                        }
+                        else
+                        {
+                            MessageBox.Show("中盒打印范围错误");
+                            return;
+                        }
+                    }
+                    catch (Exception)
+                    {
+                        MessageBox.Show("中盒打印范围错误");
+                        return;
+                    }
+                }
                 MidBoxArgument.Clear();
                 MidBoxCacheData.Clear();
                 BaseUtil.CleanDataTable(MidBoxCacheData);
                 List<int> MidOutBoxCode = new List<int>();
                 List<int> MidOutBoxCodeIndex = new List<int>();
                 string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
-                for (int i = 0; i < LabelInf.Rows.Count; i++)
+                for (int i = (begin == 0 ? 0 : begin); i < (end == 0 ? LabelInf.Rows.Count : end); i++)
                 {
                     if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
                         MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
@@ -1959,7 +1999,7 @@ namespace UAS_LabelMachine
             {
                 sql.Clear();
                 sql.Append("select pd_custprodcode,pd_custprodspec,pd_pocode,pib_madein,pib_id,pib_pdid,pib_piid,pib_pdno,pib_prodcode,pr_brand,pr_vendprodcode,");
-                sql.Append("pib_lotno,pib_datecode,pib_qty,pib_barcode,pib_outboxcode1,pib_outboxcode2,pib_ifpick,pib_ifprint");
+                sql.Append("pib_lotno,pib_datecode,pib_qty,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifpick,0)pib_ifpick,nvl(pib_ifprint,0)pib_ifprint");
                 sql.Append(",sa_pocode from prodiobarcode left join prodiodetail on pib_piid=pd_piid and pd_pdno=pib_pdno and ");
                 sql.Append(" pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join sale on sa_code=pib_ordercode ");
                 sql.Append("where pib_piid='" + PI_ID + "' order by to_number(pib_outboxcode1),pib_id,pd_prodcode");