Pārlūkot izejas kodu

回传最小包装数

章政 6 gadi atpakaļ
vecāks
revīzija
c879626045

+ 53 - 18
UAS-出货标签管理(泽天)/UAS_出货标签管理.Designer.cs

@@ -78,7 +78,10 @@
             this.ExportData = new System.Windows.Forms.Button();
             this.PrintFooter = new System.Windows.Forms.Button();
             this.GridPrcode = new UAS_LabelMachine.CustomControl.DataGridViewWithSerialNum();
+            this.pd_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pjd_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pd_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_outqty = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pr_unit = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pd_brand = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pjd_zxbzs_user = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -569,18 +572,36 @@
             this.GridPrcode.BackgroundColor = System.Drawing.SystemColors.Control;
             this.GridPrcode.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
             this.GridPrcode.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+            this.pd_pdno,
+            this.pjd_id,
             this.pd_prodcode,
+            this.pd_outqty,
             this.pr_unit,
             this.pd_brand,
             this.pjd_zxbzs_user});
             this.GridPrcode.GridColor = System.Drawing.SystemColors.Control;
             this.GridPrcode.Location = new System.Drawing.Point(0, 204);
             this.GridPrcode.Name = "GridPrcode";
-            this.GridPrcode.ReadOnly = true;
             this.GridPrcode.RowTemplate.Height = 23;
             this.GridPrcode.Size = new System.Drawing.Size(1257, 158);
             this.GridPrcode.TabIndex = 88;
             this.GridPrcode.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.GridPrcode_CellClick);
+            this.GridPrcode.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.GridPrcode_CellEndEdit);
+            // 
+            // pd_pdno
+            // 
+            this.pd_pdno.DataPropertyName = "pd_pdno";
+            this.pd_pdno.HeaderText = "明细序号";
+            this.pd_pdno.Name = "pd_pdno";
+            this.pd_pdno.ReadOnly = true;
+            this.pd_pdno.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            // 
+            // pjd_id
+            // 
+            this.pjd_id.DataPropertyName = "pjd_id";
+            this.pjd_id.HeaderText = "pjd_id";
+            this.pjd_id.Name = "pjd_id";
+            this.pjd_id.Visible = false;
             // 
             // pd_prodcode
             // 
@@ -588,6 +609,15 @@
             this.pd_prodcode.HeaderText = "物料编号";
             this.pd_prodcode.Name = "pd_prodcode";
             this.pd_prodcode.ReadOnly = true;
+            this.pd_prodcode.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            // 
+            // pd_outqty
+            // 
+            this.pd_outqty.DataPropertyName = "pd_outqty";
+            this.pd_outqty.HeaderText = "出库数量";
+            this.pd_outqty.Name = "pd_outqty";
+            this.pd_outqty.ReadOnly = true;
+            this.pd_outqty.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             // 
             // pr_unit
             // 
@@ -595,6 +625,7 @@
             this.pr_unit.HeaderText = "单位";
             this.pr_unit.Name = "pr_unit";
             this.pr_unit.ReadOnly = true;
+            this.pr_unit.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             // 
             // pd_brand
             // 
@@ -602,13 +633,14 @@
             this.pd_brand.HeaderText = "品牌";
             this.pd_brand.Name = "pd_brand";
             this.pd_brand.ReadOnly = true;
+            this.pd_brand.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             // 
             // pjd_zxbzs_user
             // 
             this.pjd_zxbzs_user.DataPropertyName = "pjd_zxbzs_user";
             this.pjd_zxbzs_user.HeaderText = "最小包装";
             this.pjd_zxbzs_user.Name = "pjd_zxbzs_user";
-            this.pjd_zxbzs_user.ReadOnly = true;
+            this.pjd_zxbzs_user.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             // 
             // groupBoxWithBorder1
             // 
@@ -746,7 +778,7 @@
             this.CollectionProcess.Margin = new System.Windows.Forms.Padding(2);
             this.CollectionProcess.Name = "CollectionProcess";
             this.CollectionProcess.Padding = new System.Windows.Forms.Padding(2);
-            this.CollectionProcess.Size = new System.Drawing.Size(130, 152);
+            this.CollectionProcess.Size = new System.Drawing.Size(130, 192);
             this.CollectionProcess.TabIndex = 80;
             this.CollectionProcess.TabStop = false;
             this.CollectionProcess.Text = " ";
@@ -755,7 +787,7 @@
             // 
             this.Capacity.AutoSize = true;
             this.Capacity.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Capacity.Location = new System.Drawing.Point(57, 61);
+            this.Capacity.Location = new System.Drawing.Point(62, 73);
             this.Capacity.Name = "Capacity";
             this.Capacity.Size = new System.Drawing.Size(0, 17);
             this.Capacity.TabIndex = 75;
@@ -764,7 +796,7 @@
             // 
             this.Process_midboxcode.AutoSize = true;
             this.Process_midboxcode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Process_midboxcode.Location = new System.Drawing.Point(57, 106);
+            this.Process_midboxcode.Location = new System.Drawing.Point(62, 118);
             this.Process_midboxcode.Name = "Process_midboxcode";
             this.Process_midboxcode.Size = new System.Drawing.Size(15, 17);
             this.Process_midboxcode.TabIndex = 74;
@@ -774,7 +806,7 @@
             // 
             this.Process_outboxcode.AutoSize = true;
             this.Process_outboxcode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Process_outboxcode.Location = new System.Drawing.Point(57, 82);
+            this.Process_outboxcode.Location = new System.Drawing.Point(62, 94);
             this.Process_outboxcode.Name = "Process_outboxcode";
             this.Process_outboxcode.Size = new System.Drawing.Size(15, 17);
             this.Process_outboxcode.TabIndex = 73;
@@ -785,7 +817,7 @@
             this.TotalCount.AutoSize = true;
             this.TotalCount.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.TotalCount.ForeColor = System.Drawing.Color.Blue;
-            this.TotalCount.Location = new System.Drawing.Point(91, 13);
+            this.TotalCount.Location = new System.Drawing.Point(96, 25);
             this.TotalCount.Name = "TotalCount";
             this.TotalCount.Size = new System.Drawing.Size(15, 17);
             this.TotalCount.TabIndex = 72;
@@ -795,7 +827,7 @@
             // 
             this.label17.AutoSize = true;
             this.label17.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label17.Location = new System.Drawing.Point(78, 13);
+            this.label17.Location = new System.Drawing.Point(83, 25);
             this.label17.Name = "label17";
             this.label17.Size = new System.Drawing.Size(13, 17);
             this.label17.TabIndex = 71;
@@ -806,7 +838,7 @@
             this.CollectedCount.AutoSize = true;
             this.CollectedCount.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.CollectedCount.ForeColor = System.Drawing.Color.Red;
-            this.CollectedCount.Location = new System.Drawing.Point(60, 13);
+            this.CollectedCount.Location = new System.Drawing.Point(65, 25);
             this.CollectedCount.Name = "CollectedCount";
             this.CollectedCount.Size = new System.Drawing.Size(15, 17);
             this.CollectedCount.TabIndex = 70;
@@ -816,7 +848,7 @@
             // 
             this.label14.AutoSize = true;
             this.label14.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label14.Location = new System.Drawing.Point(7, 83);
+            this.label14.Location = new System.Drawing.Point(12, 95);
             this.label14.Name = "label14";
             this.label14.Size = new System.Drawing.Size(32, 17);
             this.label14.TabIndex = 69;
@@ -826,7 +858,7 @@
             // 
             this.label11.AutoSize = true;
             this.label11.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label11.Location = new System.Drawing.Point(7, 106);
+            this.label11.Location = new System.Drawing.Point(12, 118);
             this.label11.Name = "label11";
             this.label11.Size = new System.Drawing.Size(32, 17);
             this.label11.TabIndex = 68;
@@ -836,7 +868,7 @@
             // 
             this.label13.AutoSize = true;
             this.label13.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label13.Location = new System.Drawing.Point(7, 42);
+            this.label13.Location = new System.Drawing.Point(12, 54);
             this.label13.Name = "label13";
             this.label13.Size = new System.Drawing.Size(44, 17);
             this.label13.TabIndex = 67;
@@ -846,7 +878,7 @@
             // 
             this.Installed.AutoSize = true;
             this.Installed.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Installed.Location = new System.Drawing.Point(57, 42);
+            this.Installed.Location = new System.Drawing.Point(62, 54);
             this.Installed.Name = "Installed";
             this.Installed.Size = new System.Drawing.Size(0, 17);
             this.Installed.TabIndex = 66;
@@ -855,7 +887,7 @@
             // 
             this.Process.AutoSize = true;
             this.Process.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Process.Location = new System.Drawing.Point(7, 13);
+            this.Process.Location = new System.Drawing.Point(12, 25);
             this.Process.Name = "Process";
             this.Process.Size = new System.Drawing.Size(44, 17);
             this.Process.TabIndex = 65;
@@ -1530,10 +1562,6 @@
         private System.Windows.Forms.Button SetPrintStatus;
         private System.Windows.Forms.Label SetPrintStatus_label;
         private System.Windows.Forms.Button PrintFooter;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pd_prodcode;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pr_unit;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pd_brand;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pjd_zxbzs_user;
         private System.Windows.Forms.DataGridViewCheckBoxColumn Choose;
         private System.Windows.Forms.DataGridViewCheckBoxColumn pib_ifprint;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_id1;
@@ -1554,5 +1582,12 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_spec;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode1;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode2;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pd_pdno;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pjd_id;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pd_prodcode;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pd_outqty;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pr_unit;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pd_brand;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pjd_zxbzs_user;
     }
 }

+ 171 - 40
UAS-出货标签管理(泽天)/UAS_出货标签管理.cs

@@ -61,14 +61,9 @@ namespace UAS_LabelMachine
         /// 当前扫描的所在行
         /// </summary>
         int CurrentRowIndex = 0;
-        /// <summary>
-        /// 正则表达式用于项目匹配
-        /// </summary>
-        Regex reg;
 
         bool logout = false;
 
-
         DataTable SingleLabelParam;
         DataTable MidLabelParam;
         DataTable OutLabelParam;
@@ -99,17 +94,10 @@ namespace UAS_LabelMachine
         /// </summary>
         List<string> MidBoxArgument = new List<string>();
         /// <summary>
-        /// 全部采集
-        /// </summary>
-        bool AllCollect = false;
-        /// <summary>
         /// 是否全选
         /// </summary>
         bool AllChecked = false;
 
-        int CloumnCount = 0;
-        /*需要重绘的Cell*/
-        Dictionary<DataGridViewCell, bool> PaintCell = new Dictionary<DataGridViewCell, bool>();
         /// <summary>
         /// 是否通过选择Combox来改变打开的文件
         /// </summary>
@@ -120,12 +108,30 @@ namespace UAS_LabelMachine
         List<string> MidParam = new List<string>();
 
         List<string> OutParam = new List<string>();
-
+        //当前采集的物料编号
         string CurrentPrCode = "";
-
+        //当前采集的最小包装
         string CurrentZXBZ = "";
-
+        //当前采集的单位
         string CurrentUnit = "";
+        //当前采集的总数
+        string CurrentPrCount = "";
+        //当前明细序号
+        string CurrentPDNO = "";
+        //当前的物料品牌
+        string CurrentBrand = "";
+
+        string SinglePrefix = "";
+        string SingleSuffix = "";
+        int SingleMaxNum = 0;
+        int SingleNumLength = 0;
+        int SingleRadix = 0;
+
+        string OutPrefix = "";
+        string OutSuffix = "";
+        int OutMaxNum = 0;
+        int OutNumLength = 0;
+        int OutRadix = 0;
 
         public UAS_出货标签打印(string Master)
         {
@@ -154,7 +160,6 @@ namespace UAS_LabelMachine
             LogManager.DoLog("程序启动,登陆人员【" + User.UserName + "】");
             dh = SystemInf.dh;
             CheckForIllegalCrossThreadCalls = false;
-            CloumnCount = LabelInf.Columns.Count;
             pi_inoutno.Focus();
             //将本地读取的打印机设置进Combox,并选中默认打印机
             MidBoxCacheData = new DataTable();
@@ -294,9 +299,24 @@ namespace UAS_LabelMachine
             int CodeCount = 0;
             //如果单位是KPCS则需要除1000
             if (CurrentUnit == "KPCS")
+            {
+                if (int.Parse(Data["QTY"]) / 1000 % int.Parse(CurrentZXBZ) != 0)
+                {
+                    MessageBox.Show("采集数量无法按照最小包装数拆分");
+                    return;
+                }
                 CodeCount = int.Parse(Data["QTY"]) / 1000 / int.Parse(CurrentZXBZ);
+            }
             else
+            {
+                if (int.Parse(Data["QTY"]) % int.Parse(CurrentZXBZ) != 0)
+                {
+                    MessageBox.Show("采集数量无法按照最小包装数拆分");
+                    return;
+                }
                 CodeCount = int.Parse(Data["QTY"]) / int.Parse(CurrentZXBZ);
+            }
+
             string pib_barcode = Data.ContainsKey("SERIAL") ? Data["SERIAL"] : "";
             //获取ID
             string[] PIBID = dh.GetSEQ("prodiobarcode_seq", CodeCount);
@@ -314,14 +334,38 @@ namespace UAS_LabelMachine
                     pib_outboxcode2 = (int.Parse(maxoutbox) + 1).ToString();
                 }
             }
-            else pib_outboxcode2 = OutBoxNum.Text;
+            else
+            {
+                pib_outboxcode2 = OutBoxNum.Text;
+            }
+            List<string> CustBarCode = new List<string>();
+            List<string> CustOutBarCode = new List<string>();
+            for (int i = 0; i < CodeCount; i++)
+            {
+                string serialcode = BaseUtil.DToAny(SingleMaxNum, SingleRadix);
+                for (int j = serialcode.ToString().Length; j < SingleNumLength; j++)
+                {
+                    serialcode = "0" + serialcode;
+                }
+                CustBarCode.Add(SinglePrefix + serialcode + SingleSuffix);
+                serialcode = BaseUtil.DToAny(OutMaxNum, OutRadix);
+                for (int j = serialcode.ToString().Length; j < OutNumLength; j++)
+                {
+                    serialcode = "0" + serialcode;
+                }
+                CustOutBarCode.Add(OutPrefix + serialcode + OutSuffix);
+                SingleMaxNum = SingleMaxNum + 1;
+                OutMaxNum = OutMaxNum + 1;
+            }
             sql.Clear();
             sql.Append("insert into prodiobarcode(PIB_ID,PIB_PRODCODE,PIB_INDATE,PIB_INOUTNO,PIB_PIID,PIB_PDNO, PIB_PDID,PIB_PICLASS,");
             sql.Append("PIB_BARCODE,PIB_CUSTBARCODE,PIB_QTY,PIB_OUTBOXCODE1,PIB_OUTBOXCODE2,pib_custoutboxcode,PIB_IFPRINT,PIB_ORDERCODE,PIB_CUSTPO) ");
             sql.Append("select :PIB_ID,pd_prodcode,sysdate,pi_inoutno,pi_id,pd_pdno,pd_id,pi_class,");
-            sql.Append("'" + pib_barcode + "','','','','" + pib_outboxcode2 + "','',0,pd_ordercode,pd_pocode ");
+            sql.Append("'" + pib_barcode + "',:PIB_CUSTBARCODE,'" + CurrentZXBZ + "','','" + pib_outboxcode2 + "',:pib_custoutboxcode,0,pd_ordercode,pd_pocode ");
             sql.Append("from prodinout left join prodiodetail on pi_id=pd_piid where pi_id='" + PI_ID + "' and pd_prodcode='" + CurrentPrCode + "'");
-            dh.BatchInsert(sql.ToString(), new string[] { "PIB_ID" }, PIBID);
+            dh.BatchInsert(sql.ToString(), new string[] { "PIB_ID", "PIB_CUSTBARCODE", "pib_custoutboxcode" }, PIBID, CustBarCode.ToArray(), CustOutBarCode.ToArray());
+            dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (SingleMaxNum + CodeCount) + "'", "rmn_nrcode='" + pi_cardcode.Text + "' and rmn_type='Single' and rmn_prefix='" + SinglePrefix + "'");
+            dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (OutMaxNum + CodeCount) + "'", "rmn_nrcode='" + pi_cardcode.Text + "' and rmn_type='Out' and rmn_prefix='" + OutPrefix + "'");
             LoadGridData(new object(), new EventArgs());
             //加载完数据之后进行容量的判断
             if (LabelInfDataTable.Select("pib_outboxcode2='" + OutBoxNum.Text + "'").Length > OutboxCapacity.Value)
@@ -532,6 +576,9 @@ namespace UAS_LabelMachine
                     pi_date.Text = dt.Rows[0]["pi_date"].ToString();
                     PI_ID = dt.Rows[0]["pi_id"].ToString();
                     LoadGridData(sender, e);
+                    //获取条码规则
+                    GetBarCodeRule("Single", out SinglePrefix, out SingleSuffix, out SingleMaxNum, out SingleNumLength, out SingleRadix);
+                    GetBarCodeRule("Out", out OutPrefix, out OutSuffix, out OutMaxNum, out OutNumLength, out OutRadix);
                     //重新输入单号后清除缓存
                     MidBoxArgument.Clear();
                     MidBoxCacheData.Clear();
@@ -1408,7 +1455,6 @@ namespace UAS_LabelMachine
         /// <param name="e"></param>
         private void LoadGridData(object sender, EventArgs e)
         {
-            AllCollect = false;
             sql.Clear();
             sql.Append("select pd_custprodcode,pd_custprodspec,pd_pocode,pib_madein,pib_custbarcode,pib_custoutboxcode,pib_id,pib_datecode1,pib_pdid,pib_piid,pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand, pr_vendprodcode,");
             sql.Append("pib_lotno,pib_datecode,pib_qty,pr_spec,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifprint,0)pib_ifprint");
@@ -1505,22 +1551,6 @@ namespace UAS_LabelMachine
             }
         }
 
-        private void AllCollected_Click(object sender, EventArgs e)
-        {
-            if (AllCollect == false)
-            {
-                foreach (DataGridViewRow dr in LabelInf.Rows)
-                    dr.Cells[1].Value = true;
-                AllCollect = true;
-            }
-            else
-            {
-                foreach (DataGridViewRow dr in LabelInf.Rows)
-                    dr.Cells[1].Value = false;
-                AllCollect = false;
-            }
-        }
-
         private void LogingOut_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
         {
             string close = MessageBox.Show(this.ParentForm, "是否注销", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
@@ -1705,12 +1735,15 @@ namespace UAS_LabelMachine
 
         private void LoadPrcodeData()
         {
-            GridPrcode.DataSource = (DataTable)dh.ExecuteSql("select pd_prodcode,pd_brand,pjd_zxbzs_user,pr_unit from prodiodetail left join prodinout on pi_id=pd_piid left join PRODJOINVENDDETAIL on pjd_brand =pd_brand and pjd_prodcode=pd_prodcode left join product on pd_prodcode=pr_code where pi_id='" + PI_ID + "' order by pjd_prodcode", "select");
+            GridPrcode.DataSource = (DataTable)dh.ExecuteSql("select pd_prodcode,pd_brand,pjd_zxbzs_user,pd_outqty,pd_pdno,pr_unit,pjd_id from prodiodetail left join prodinout on pi_id=pd_piid left join PRODJOINVENDDETAIL on pjd_brand =pd_brand and pjd_prodcode=pd_prodcode left join product on pd_prodcode=pr_code where pi_id='" + PI_ID + "' order by pd_pdno", "select");
             if (GridPrcode.Rows.Count > 0)
             {
                 CurrentPrCode = GridPrcode.Rows[0].Cells["pd_prodcode"].Value.ToString();
                 CurrentZXBZ = GridPrcode.Rows[0].Cells["pjd_zxbzs_user"].Value.ToString();
                 CurrentUnit = GridPrcode.Rows[0].Cells["pr_unit"].Value.ToString();
+                CurrentPDNO = GridPrcode.Rows[0].Cells["pd_pdno"].Value.ToString();
+                CurrentPrCount = GridPrcode.Rows[0].Cells["pd_outqty"].Value.ToString();
+                CurrentBrand = GridPrcode.Rows[0].Cells["pd_brand"].Value.ToString();
             }
         }
 
@@ -1719,9 +1752,12 @@ namespace UAS_LabelMachine
             //用户在重新勾选后重置采集项目的索引
             if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
             {
-                CurrentPrCode = GridPrcode.Rows[e.RowIndex].Cells["pd_prodcode"].ToString();
-                CurrentZXBZ = GridPrcode.Rows[e.RowIndex].Cells["pjd_zxbzs_user"].ToString();
-                CurrentUnit = GridPrcode.Rows[e.RowIndex].Cells["pr_unit"].ToString();
+                CurrentPrCode = GridPrcode.Rows[e.RowIndex].Cells["pd_prodcode"].Value.ToString();
+                CurrentZXBZ = GridPrcode.Rows[e.RowIndex].Cells["pjd_zxbzs_user"].Value.ToString();
+                CurrentUnit = GridPrcode.Rows[e.RowIndex].Cells["pr_unit"].Value.ToString();
+                CurrentPDNO = GridPrcode.Rows[e.RowIndex].Cells["pd_pdno"].Value.ToString();
+                CurrentPrCount = GridPrcode.Rows[e.RowIndex].Cells["pd_outqty"].Value.ToString();
+                CurrentBrand = GridPrcode.Rows[e.RowIndex].Cells["pd_brand"].Value.ToString();
             }
         }
 
@@ -1756,5 +1792,100 @@ namespace UAS_LabelMachine
             }
             OutBoxNum.SelectedIndex = OutBoxNum.Items.Count - 1;
         }
+
+        /// <summary>
+        /// 获取条码规则
+        /// </summary>
+        /// <param name="Type"></param>
+        /// <param name="Prefix"></param>
+        /// <param name="Suffix"></param>
+        /// <param name="CurrentMaxNum"></param>
+        /// <param name="SerialNumLength"></param>
+        /// <param name="Radix"></param>
+        private void GetBarCodeRule(string Type, out string Prefix, out string Suffix, out int CurrentMaxNum, out int SerialNumLength, out int Radix)
+        {
+            //获取编码规则
+            Prefix = "";
+            Suffix = "";
+            CurrentMaxNum = 0;
+            SerialNumLength = 0;
+            Radix = 0;
+            DataTable Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_type,nrd_radix,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode='" + pi_cardcode.Text + "' and nr_type='" + Type + "' order by nrd_detno", "select");
+            //如果没有则取公共规则
+            if (Nr.Rows.Count == 0)
+                Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_radix,nrd_type,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode is null and nr_type='" + Type + "' and nr_isdefault <> 0 order by nrd_detno", "select");
+            //用于过滤参数的正则表达式
+            Regex match = new Regex("{\\w+}");
+            //用于存放每一项的明细的数据
+            string[] NrData = new string[Nr.Rows.Count];
+            //流水长度
+            Dictionary<int, string> NrDic = new Dictionary<int, string>();
+            Prefix = "";
+            for (int m = 0; m < Nr.Rows.Count; m++)
+            {
+                switch (Nr.Rows[m]["nrd_type"].ToString())
+                {
+                    //常量直接进行拼接
+                    case "常量":
+                        Prefix += Nr.Rows[m]["nrd_sql"].ToString();
+                        Suffix += Nr.Rows[m]["nrd_sql"].ToString();
+                        break;
+                    case "SQL":
+                        string SQL = Nr.Rows[m]["nrd_sql"].ToString();
+                        DataTable Temp;
+                        //如果不包含参数替换
+                        if (SQL.IndexOf("{") == 0)
+                        {
+                            Temp = (DataTable)dh.ExecuteSql(SQL, "select");
+                        }
+                        else
+                        {
+                            //替换参数后重新执行SQL
+                            foreach (Match mch in match.Matches(SQL))
+                            {
+                                SQL = SQL.Replace(mch.Value.Trim(), "'" + pi_inoutno.Text + "'");
+                            }
+                            Temp = (DataTable)dh.ExecuteSql(SQL, "select");
+                        }
+                        if (Temp.Rows.Count > 0)
+                        {
+                            Prefix += Temp.Rows[0][0].ToString();
+                            Suffix += Temp.Rows[0][0].ToString();
+                        }
+                        break;
+                    //流水需要通过MaxNumber去取
+                    case "流水":
+                        string maxnum = dh.getFieldDataByCondition("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + pi_cardcode.Text + "' and rmn_prefix='" + Prefix + "'  and rmn_type='" + Type + "'").ToString();
+                        //设置当前流水
+                        if (maxnum == "")
+                        {
+                            dh.ExecuteSql("insert into RuleMaxNum(rmn_id,rmn_nrcode,rmn_prefix,rmn_maxnumber,rmn_type) values(RuleMaxNum_seq.nextval,'" + pi_cardcode.Text + "','" + Prefix + "','1','" + Type + "')", "insert");
+                            CurrentMaxNum = 1;
+                        }
+                        else
+                        {
+                            CurrentMaxNum = int.Parse(maxnum);
+                        }
+                        SerialNumLength = int.Parse(Nr.Rows[m]["nrd_length"].ToString());
+                        Radix = int.Parse(Nr.Rows[m]["nrd_radix"].ToString());
+                        Suffix = "";
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+
+        private void GridPrcode_CellEndEdit(object sender, DataGridViewCellEventArgs e)
+        {
+            string Value = GridPrcode.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
+            string ID = GridPrcode.Rows[e.RowIndex].Cells["pjd_id"].Value.ToString();
+            dh.UpdateByCondition("PRODJOINVENDDETAIL", "pjd_zxbzs_user='" + Value + "'", "pjd_id='" + ID + "'");
+            //删除对应物料的明细
+            string CurrentPrCode = GridPrcode.Rows[e.RowIndex].Cells["pd_prodcode"].Value.ToString();
+            string CurrentPDNO = GridPrcode.Rows[e.RowIndex].Cells["pd_pdno"].Value.ToString();
+            dh.ExecuteSql("delete from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_pdno='" + CurrentPDNO + "' and pib_prodcode='" + CurrentPrCode + "'", "delete");
+            LoadGridData(sender, new EventArgs());
+        }
     }
 }

+ 9 - 0
UAS-出货标签管理(泽天)/UAS_出货标签管理.resx

@@ -126,9 +126,18 @@
   <metadata name="ExportFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>294, 17</value>
   </metadata>
+  <metadata name="pd_pdno.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="pjd_id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <metadata name="pd_prodcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="pd_outqty.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <metadata name="pr_unit.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>