wtt
2024-06-06 5c76893e9a80142091c2a5b0b0af976e00b63eab
WarM/ÌõÂë´òÓ¡/Gy_PackBarCodeBill_automaticallyByPLC.cs
@@ -10,6 +10,7 @@
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.VisualBasic;
namespace WarM.条码打印
{
@@ -71,6 +72,10 @@
        public bool BillChange;   //
        public bool grdStatus;
        public int selectRow = 0;
        //记录当前组托的条码的源单ID、子ID,用于保证当前托中所有子条码为同一个工单生成
        public int HSourceInterID_ICMO = 0;
        public int HSourceEntryID_ICMO = 0;
        private void Gy_PackBarCodeBill_automaticallyByPLC_Load(object sender, EventArgs e)
        {
@@ -181,6 +186,11 @@
            DBUtility.Xt_BaseBillFun.initGridList(grdSub, this.Name + "grdSub");
            getDisplay_GrdMain();
            if (grdMain.Rows.Count > 0 && grdMain.Rows[0].Cells[4].Value!=null)
            {
                getPackQty(grdMain.Rows[0].Cells[4].Value.ToString());
            }
        }
@@ -355,7 +365,11 @@
                    return;
                }
                this.Sub_SaveBill();
            }catch(Exception ex)
                //组托成功后,清空组托数量与源单信息
                set_clearPackQtyAndSourceInfo();
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
@@ -364,11 +378,11 @@
        //自动组托 
        private void button_startListen_Click(object sender, EventArgs e)
        {
            if (DBUtility.ClsPub.isLong(textBox_PackQty.Text) == 0)
            {
                MessageBox.Show("请设置托条码的最小包装数!");
                return;
            }
            //if (DBUtility.ClsPub.isLong(textBox_PackQty.Text) == 0)
            //{
            //    MessageBox.Show("请设置托条码的最小包装数!");
            //    return;
            //}
            isStartListen = 1;
@@ -432,6 +446,9 @@
                            Report.Printer.PrinterName = comboBox_PrinterParams.Text.Replace("(默认)", "");
                        }
                        Report.Print(false);
                        //组托成功后,清空组托数量与源单信息
                        set_clearPackQtyAndSourceInfo();
                    }
                }catch(Exception ex)
                {
@@ -464,6 +481,8 @@
                return true;
            }catch(Exception ex)
            {
                string sql = "exec h_p_WMS_PackBarCodeBill_dealDataWhenError '" + textBox_HPackBarCode + "'";
                oCn.RunProc(sql);
                throw new Exception(ex.Message);
            }
            
@@ -746,11 +765,23 @@
            {
                if (e.KeyChar == (char)Keys.Return)
                {
                    //防错判断
                    if(!judgeIsSameSourceBill(textBox_HBarCode.Text.Trim()))
                    {
                        textBox_HBarCode.Text = "";
                        return;
                    }
                    SetBarCode_Webs();
                    textBox_HBarCode.Text = "";
                    textBox_HBarCode.Focus();
                    autoProducePackBarCode();
                    if (grdMain.Rows.Count ==1 )
                    {
                        getPackQty(grdMain.Rows[0].Cells[4].Value.ToString());
                    }
                }
            }
            catch (Exception e2)
@@ -1135,6 +1166,11 @@
        private void toolStripButton_Delete_Click(object sender, EventArgs e)
        {
            deleteGrdMainNote();
            if (grdMain.Rows.Count== 0)
            {
                set_clearPackQtyAndSourceInfo();
            }
        }
        #endregion
@@ -1145,14 +1181,29 @@
        {
            if (grdMain.SelectedRows != null && grdMain.SelectedRows.Count==1)
            {
                if (MessageBox.Show("确定要删除?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Cancel)
                //if (MessageBox.Show("确定要删除?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Cancel)
                //{
                //    return;
                //}
                //if (MessageBox.Show("删除后将不可恢复,确定要继续操作?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Cancel)
                //{
                //    return;
                //}
                string pwd = Interaction.InputBox("请输入密码", "删除确认!", "", 100, 100);
                //点击取消
                if(pwd == "")
                {
                    return;
                }
                if (MessageBox.Show("删除后将不可恢复,确定要继续操作?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Cancel)
                if(pwd != "123456")
                {
                    MessageBox.Show("密码错误!");
                    return;
                }
                Delete();
            }
            else
@@ -1228,6 +1279,9 @@
                Report.Printer.PrinterName = comboBox_PrinterParams.Text.Replace("(默认)", "");
            }
            Report.Print(false);
            //组托成功后,清空组托数量与源单信息
            set_clearPackQtyAndSourceInfo();
        }
        #endregion
@@ -1367,6 +1421,7 @@
                //获取缓存列表中 æ‰˜æ¡ç  å¯¹åº”çš„ ç»„托记录
                sql = "select top(1) a.* from Sc_PackUnionBill_Temp as a inner join Gy_BarCodeBill as b on a.HBarCode = b.HBarCode where a.HBarCode_Pack = '" + HPackBarCode + "' and b.HSourceID = " + HSourceID + " and a.HStockorgID = " + HOrgID;
                //sql = "select top(1) a.* from Sc_PackUnionBill_Temp as a where a.HBarCode_Pack = '" + HPackBarCode + "' and a.HStockorgID = " + HOrgID;
                ds = oCn.RunProcReturn(sql, "Sc_PackUnionBill_Temp");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
@@ -1384,13 +1439,83 @@
                    textBox_sBillNo.Text = HBillNo;
                    getDisplay_GrdMain();
                    if (grdMain.Rows.Count > 0 && grdMain.Rows[0].Cells[4].Value != null)
                    {
                        getPackQty(grdMain.Rows[0].Cells[4].Value.ToString());
                    }
                }
            }
        }
        #endregion
        #endregion
        #region æ ¹æ®æ¡ç ç¼–号,获取条码中物料所对应的组托数量,同时记录源单主ID、子ID
        private void getPackQty(string HBarCode)
        {
            string sql = "select * from h_v_IF_BarCodeBillList_getPackQty where æ¡ç ç¼–号 = '" + HBarCode + "'";
            DataSet ds_getPackQty = oCn.RunProcReturn(sql, "h_v_IF_BarCodeBillList_getPackQty");
            if (ds_getPackQty == null || ds_getPackQty.Tables[0].Rows.Count <= 0)
            {
                HSourceInterID_ICMO = 0;
                HSourceEntryID_ICMO = 0;
                textBox_PackQty.Text = "";
                return;
            }
            HSourceInterID_ICMO = int.Parse(ds_getPackQty.Tables[0].Rows[0]["HSourceInterID"].ToString());
            HSourceEntryID_ICMO = int.Parse(ds_getPackQty.Tables[0].Rows[0]["HSourceEntryID"].ToString());
            textBox_PackQty.Text = Double.Parse(ds_getPackQty.Tables[0].Rows[0]["组托数量"].ToString()).ToString();
        }
        #endregion
        #region åˆ¤æ–­å½“前扫描的条码是否与已经扫描过的条码为同一工单生成的
        private bool judgeIsSameSourceBill(string HBarCode)
        {
            if (grdMain.Rows.Count == 0)
            {
                return true;
            }
            else
            {
                string sql = "select * from h_v_IF_BarCodeBillList_getPackQty where æ¡ç ç¼–号 = '" + HBarCode + "'";
                DataSet ds_getPackQty = oCn.RunProcReturn(sql, "h_v_IF_BarCodeBillList_getPackQty");
                if (ds_getPackQty == null || ds_getPackQty.Tables[0].Rows.Count <= 0)
                {
                    MessageBox.Show("当前条码不存在!");
                    return false;
                }
                else
                {
                    int HSourceInterID_ICMO_Bak = int.Parse(ds_getPackQty.Tables[0].Rows[0]["HSourceInterID"].ToString());
                    int HSourceEntryID_ICMO_Bak = int.Parse(ds_getPackQty.Tables[0].Rows[0]["HSourceEntryID"].ToString());
                    if (HSourceInterID_ICMO != HSourceInterID_ICMO_Bak || HSourceEntryID_ICMO != HSourceEntryID_ICMO_Bak)
                    {
                        MessageBox.Show("当前扫描的条码与之前所扫描的条码工单不一致!");
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                }
            }
        }
        #endregion
        #region æ¸…空 ç»„托数量 ä¸Žè®°å½•的源单主ID、子ID
        private void set_clearPackQtyAndSourceInfo()
        {
            textBox_PackQty.Text = "";
            HSourceInterID_ICMO = 0;
            HSourceEntryID_ICMO = 0;
        }
        #endregion
    }
}