duhe
2024-04-30 e294473fbac1442d4d2466edd0bf0ce0385460a5
托盘条码自动组托:组托保证数据一致性。
1个文件已修改
162 ■■■■■ 已修改文件
WarM/条码打印/Gy_PackBarCodeBill_automaticallyByPLC.cs 162 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WarM/ÌõÂë´òÓ¡/Gy_PackBarCodeBill_automaticallyByPLC.cs
@@ -347,12 +347,18 @@
        //未满托生成 æŒ‰é’® ç‚¹å‡»äº‹ä»¶
        private void button_produceByHand_Click(object sender, EventArgs e)
        {
            if (HQty == 0)
            try
            {
                MessageBox.Show("请扫码子条码!");
                return;
                if (HQty == 0)
                {
                    MessageBox.Show("请扫码子条码!");
                    return;
                }
                this.Sub_SaveBill();
            }catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.Sub_SaveBill();
        }
        //自动组托 
@@ -408,22 +414,28 @@
        {
            if(isStartListen == 1)
            {
                if(HQty == DBUtility.ClsPub.isDoule(textBox_PackQty.Text))
                try
                {
                    this.Sub_SaveBill();
                    //设置打印模板,打印
                    grdSub.Rows[0].Cells[0].Value = "*";
                    Report = new GridppReport();
                    Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + textBox_PrintModelParams.Text + ".grf");  //here .
                    Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
                    Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
                    Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
                    if (comboBox_PrinterParams.Text != "")
                    if (HQty == DBUtility.ClsPub.isDoule(textBox_PackQty.Text))
                    {
                        Report.Printer.PrinterName = comboBox_PrinterParams.Text.Replace("(默认)", "");
                        this.Sub_SaveBill();
                        //设置打印模板,打印
                        grdSub.Rows[0].Cells[0].Value = "*";
                        Report = new GridppReport();
                        Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + textBox_PrintModelParams.Text + ".grf");  //here .
                        Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
                        Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
                        Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
                        if (comboBox_PrinterParams.Text != "")
                        {
                            Report.Printer.PrinterName = comboBox_PrinterParams.Text.Replace("(默认)", "");
                        }
                        Report.Print(false);
                    }
                    Report.Print(false);
                }catch(Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
@@ -432,25 +444,29 @@
        //生成托盘条码
        private bool Sub_SaveBill()
        {
            //获取组织信息
            HOrgID = get_ORGANIZATIONSIDByName(cmbHOrgID.Text);
            HOrgNumber = get_ORGANIZATIONSNOByName(cmbHOrgID.Text);
            if (HOrgID == -1)
            try
            {
                MessageBox.Show("选择组织有错误!");
                return false;
            }
                //获取组织信息
                HOrgID = get_ORGANIZATIONSIDByName(cmbHOrgID.Text);
                HOrgNumber = get_ORGANIZATIONSNOByName(cmbHOrgID.Text);
                if (HOrgID == -1)
                {
                    throw new Exception("选择组织有错误!");
                }
            if (!Sub_AllowSave())//单据完整性判断
                if (!Sub_AllowSave())//单据完整性判断
                {
                    throw new Exception("单据完整性判断失败!");
                }
                SaveBarCode();
                return true;
            }catch(Exception ex)
            {
                return false;
                throw new Exception(ex.Message);
            }
            SaveBarCode();
            return true;
        }
        //单据完整性判断          æœªå®Œæˆ
@@ -508,6 +524,15 @@
                sSQLMul[1] = " exec h_p_WMS_SetMaxNo_QTY '" + sTMNumber + "'," + HQty.ToString() + " ";
                //判断当前托盘条码是否已经通过临时组托在条码档案中生成了,若已经生成了则不需要在插入
                ds = oCn.RunProcReturn("select * from Gy_BarCodeBill where HBarCode = '" + textBox_HPackBarCode.Text + "' and HSTOCKORGID = " + HOrgID, "Gy_BarCodeBill");
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    sSQLMul[0] = "";
                }
                oCn.BeginTran();
                if (getRunProcByMul_Back(sSQLMul, ref DBUtility.ClsPub.sExeReturnInfo))
                {
                    //MessageBox.Show("条码生成完毕!");
@@ -519,15 +544,21 @@
                    setPackBarCodeBillData();
                    getDisplay_GrdMain();
                    oCn.Commit();
                }
                else
                {
                    //MessageBox.Show("条码生成失败!" + DBUtility.ClsPub.sExeReturnInfo);
                    oCn.RollBack();
                }
                //oCn.Commit();
            }
            catch (Exception e)
            {
                //MessageBox.Show("条码生成失败!" + e.Message);
                oCn.RollBack();
                throw new Exception(e.Message);
            }
        }
@@ -542,27 +573,30 @@
                {
                    for (int i = 0; i < 1; i++)
                    {
                        oCn.RunProc(sSQL[i]);
                        if (sSQL[i].Length > 0)
                        {
                            oCn.RunProc(sSQL[i]);
                        }
                    }
                    //上传组托信息到服务器
                    send();
                    oCn.Commit();
                }
                else
                {
                    sErrMsg = "没有数据!";
                    oCn.Commit();
                    return false;
                    sErrMsg = "没有数据!";
                    throw new Exception(sErrMsg);
                }
                oCn.Commit();
                //oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sErrMsg = e.Message;
                oCn.RollBack();
                return false;
                sErrMsg = e.Message;
                throw new Exception(sErrMsg);
            }
        }
        #endregion
@@ -581,7 +615,13 @@
            //{
            //    return;
            //}
            LoadData();
            try
            {
                LoadData();
            }catch(Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        //判断用户权限
@@ -610,7 +650,7 @@
            //判断是否数据完整 
            if (AllowLoadData() == false)
            {
                return;
                throw new Exception("数据完整性判断失败!");
            }
            try
            {
@@ -628,14 +668,14 @@
                }
                else
                {
                    MessageBox.Show("生成失败!原因:" + err);
                    return;
                    string error = "生成失败!原因:" + err;
                    throw new Exception(error);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("单据号:" + textBox_sBillID.Text + ",单据ID:" + textBox_sBillID.Text + ";上传失败!" + e.Message);
                return;
                string error = "单据号:" + textBox_sBillID.Text + ",单据ID:" + textBox_sBillID.Text + ";上传失败!" + e.Message;
                throw new Exception(error);
            }
        }
@@ -659,37 +699,37 @@
        public bool set_SavePackUnionBill_Add(Int64 HInterID, string HBillType, string HBillNo, string HBarCode_Pack, string HMaker, Int64 HStockOrgID, ref string sErrMsg)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            oCn.BeginTran();
            try
            {
                oCn.BeginTran();
                DataSet ds = oCn.RunProcReturn("exec h_p_Sc_PackUnionBill_Insert_New " + HInterID.ToString() + ",'" + HBillNo + "','" + HBillType + "','" + HBarCode_Pack + "','" + HMaker + "'," + HStockOrgID.ToString(), "h_p_Sc_PackUnionBill_Insert_New");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HInterID + ";上传失败!";
                    oCn.RollBack();
                    return false;
                    sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HInterID + ";上传失败!";
                    throw new Exception(sErrMsg);
                }
                else
                {
                    if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0][0]) == 1)
                    {
                        sErrMsg = "上传失败,单据号:" + HBillNo + ",单据ID:" + HInterID + ";" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
                        oCn.RollBack();
                        return false;
                        sErrMsg = "上传失败,单据号:" + HBillNo + ",单据ID:" + HInterID + ";" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
                        throw new Exception(sErrMsg);
                    }
                    else
                    {
                        //sErrMsg = "生成生产组托单成功!单据号为:" + HBillNo;
                        oCn.Commit();
                        //sErrMsg = "生成生产组托单成功!单据号为:" + HBillNo;
                        return true;
                    }
                }
            }
            catch (Exception e)
            {
                sErrMsg = "生成生产组托单失败!" + e.Message;
                oCn.RollBack();
                return false;
                sErrMsg = "生成生产组托单失败!" + e.Message;
                throw new Exception(sErrMsg);
            }
        }
@@ -715,11 +755,9 @@
            }
            catch (Exception e2)
            {
                //if (DBUtility.ClsPub.bSound)
                //{
                //    DBUtility.ClsPub.MessageBeep((int)DBUtility.ClsPub.BeepType.Warning);
                //}
                MessageBox.Show("发生网络异常,请稍后再试!");
                textBox_HBarCode.Text = "";
                textBox_HBarCode.Focus();
                MessageBox.Show(e2.Message);
            }
        }
        //将条码信息写入条码出入库临时表
@@ -743,13 +781,13 @@
                }
                else
                {
                    MessageBox.Show(err);
                    return;
                    throw new Exception(err);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("扫描子条码,写入临时表信息失败!" + e.Message + err);
                string sError = "扫描子条码,写入临时表信息失败!" + e.Message + err;
                throw new Exception(sError);
            }
        }