zzr99
2022-03-28 caf31525f29e659cca49dd6e35b5f13e8e0496d7
WarM/ÌõÂë´òÓ¡/Gy_BarCodeBill.cs
@@ -165,7 +165,10 @@
        public string ERPMode = ""; //ERP模式(WISE、CLOUD)
        public string CampanyName = ""; //客户定制化名称
        public string SourceQtyCtl = ""; //超源单数量控制
                                         //-------------------------------------------------------------------------
        public long PrintQty = 0;               //允许条码打印次数
        public string PrintQtyCtl = "";         //条码打印次数控制
        public string UpdatePrintQtyCtl = "";   //条码打印次数更新
                                                //-------------------------------------------------------------------------
        #region å›ºå®šä»£ç 
        //清空界面
@@ -405,6 +408,9 @@
                ERPMode = oSystemParameter.omodel.WMS_WMSStockCtl_ERPMode;
                CampanyName = oSystemParameter.omodel.WMS_CampanyName;
                SourceQtyCtl = oSystemParameter.omodel.BarCode_SourceQtyCtl;
                PrintQty = oSystemParameter.omodel.BarCode_PrintQty;
                PrintQtyCtl = oSystemParameter.omodel.BarCode_PrintQtyCtl;
                UpdatePrintQtyCtl = oSystemParameter.omodel.BarCode_UpdatePrintQtyCtl;
            }
            cmbHWorksNumber.Items.Clear();
@@ -2707,9 +2713,10 @@
        #region  //打印设置
        GridppReport Report;
        int CurRows = 0;
        string sBarCodeItemID = ""; //条码自增列
        //预览
        int CurRows = 0;
        private void yl_Click(object sender, EventArgs e)
        {
            //判断是否已经生成条码
@@ -2738,32 +2745,68 @@
            }
        }
        //打印前判断条码是否已打印过
        //打印
        private void dy_Click(object sender, EventArgs e)
        {
            //判断是否已经生成条码
            if (DBUtility.ClsPub.isStrNull(grdSub.Rows[0].Cells[HTMCol].Value) == "")
            {
                MessageBox.Show("条码未生成,请先生成条码后再打印!");
                return;
            }
            //打印前判断条码是否已打印过
            if (ReportPrintBegin())
            {
                return;
            }
            //选择打印模板
            BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
            oFrm.sBillName = ModName;
            oFrm.sBillModel = ModCaption;
            oFrm.ShowDialog();
            if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
            {
                //循环选中行
                Sub_SetReport(oFrm.sOpenTmp);
                Report.Print(true);
                Thread.Sleep(1000);
            }
        }
        ////打印前判断条码是否已打印过
        //private bool ReportPrintBegin()
        //{
        //    string sRelQty = "";
        //    if (oBar.Set_BPrintQty(DBUtility.ClsPub.isStrNull(grdSub.Rows[0].Cells[HTMCol].Value), ref sRelQty))
        //    {
        //        MessageBox.Show("条码已经打印过,不可重复打印!");
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}
        //打印前判断条码是否超过允许可打印次数
        private bool ReportPrintBegin()
        {
            string sRelQty = "";
            if (oBar.Set_BPrintQty(DBUtility.ClsPub.isStrNull(grdSub.Rows[0].Cells[HTMCol].Value), ref sRelQty))
            string sHRemark = "";
            if (PrintQtyCtl == "Y")
            {
                MessageBox.Show("条码已经打印过,不可重复打印!");
                return true;
                if (oBar.Set_CheckPrintQty_SD(HInterID, PrintQty, ref sHRemark))
                {
                    MessageBox.Show(sHRemark);
                    return true;
                }
                return false;
            }
            else
            {
                return false;
            }
        }
        //打印结束后回填条码打印次数
        private void ReportPrintEnd()
        {
            try
            {
                oCn.RunProc("update Gy_BarCodeBill set HPrintQty=isnull(HPrintQty,0)+1 where HInterID=" + HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
            }
            catch (Exception e)
            {
                MessageBox.Show("打印失败!打印结束 ï¼š" + e.Message);
            }
        }
@@ -2773,26 +2816,6 @@
            for (int i = 0; i < grdList.Rows.Count; i++)
            {
                grdList.Rows[i].Cells[0].Value = "*";
            }
            //
            Report = new GridppReport();
            Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf");  //here .
            Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
            Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
            Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
        }
        private void Sub_SetReportView(string sOpenTmp)
        {
            //判断行数
            for (int i = 0; i < grdList.Rows.Count; i++)
            {
                grdList.Rows[i].Cells[0].Value = "";
            }
            for (int i = 0; i < grdList.SelectedRows.Count; i++)
            {
                grdList.Rows[grdList.SelectedRows[i].Index].Cells[0].Value = "*";
            }
            //
            Report = new GridppReport();
@@ -2824,11 +2847,7 @@
            }
        }
        private Int32 Fun_GetCol(string sCol)
        {
            return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdList);
        }
        //填入单据表体信息
        private void ReportFetchRecordByDataTable()
        {
            try
@@ -2842,17 +2861,40 @@
            }
        }
        private void dy_Click(object sender, EventArgs e)
        ////打印结束后回填条码打印次数
        //private void ReportPrintEnd()
        //{
        //    try
        //    {
        //        oCn.RunProc("update Gy_BarCodeBill set HPrintQty=isnull(HPrintQty,0)+1 where HInterID=" + HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
        //    }
        //    catch (Exception e)
        //    {
        //        MessageBox.Show("打印失败!打印结束 ï¼š" + e.Message);
        //    }
        //}
        //打印结束后回填条码打印次数
        private void ReportPrintEnd()
        {
            if (UpdatePrintQtyCtl == "Y")
            {
                oBar.Set_UpdatePrintQty_SD(HInterID);
            }
        }
        //试打印
        private void sdy_Click(object sender, EventArgs e)
        {
            //判断是否已经生成条码
            if (DBUtility.ClsPub.isStrNull(grdSub.Rows[0].Cells[HTMCol].Value) == "")
            {
                MessageBox.Show("条码未生成,请先生成条码后再打印!");
                MessageBox.Show("条码未生成,请先生成条码后再预览!");
                return;
            }
            //打印前判断条码是否已打印过
            if (ReportPrintBegin())
            if (ReportPrintBegin_SDY())
            {
                return;
            }
@@ -2864,12 +2906,71 @@
            oFrm.ShowDialog();
            if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
            {
                //循环选中行
                Sub_SetReport(oFrm.sOpenTmp);
                Report.Print(true);
                Sub_SetReportView(oFrm.sOpenTmp);
                Report.PrintPreview(false);
                Thread.Sleep(1000);
            }
        }
        //打印前判断条码是否超过允许可打印次数
        private bool ReportPrintBegin_SDY()
        {
            string sHRemark = "";
            sBarCodeItemID = "";
            for (int i = 0; i < grdList.SelectedRows.Count; i++)
            {
                sBarCodeItemID = sBarCodeItemID + "," + DBUtility.ClsPub.isLong(grdList.Rows[grdList.SelectedRows[i].Index].Cells[Fun_GetCol("HItemID")].Value).ToString();
            }
            sBarCodeItemID = sBarCodeItemID.Remove(0, 1);
            if (PrintQtyCtl == "Y")
            {
                if (oBar.Set_CheckPrintQty(sBarCodeItemID, PrintQty, ref sHRemark))
                {
                    MessageBox.Show(sHRemark);
                    return true;
                }
                return false;
            }
            else
            {
                return false;
            }
        }
        private void Sub_SetReportView(string sOpenTmp)
        {
            //判断行数
            for (int i = 0; i < grdList.Rows.Count; i++)
            {
                grdList.Rows[i].Cells[0].Value = "";
            }
            for (int i = 0; i < grdList.SelectedRows.Count; i++)
            {
                grdList.Rows[grdList.SelectedRows[i].Index].Cells[0].Value = "*";
            }
            //
            Report = new GridppReport();
            Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf");  //here .
            Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
            Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
            Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd_SDY);
        }
        //打印结束后回填条码打印次数
        private void ReportPrintEnd_SDY()
        {
            if (UpdatePrintQtyCtl == "Y")
            {
                oBar.Set_UpdatePrintQty(sBarCodeItemID);
            }
        }
        private Int32 Fun_GetCol(string sCol)
        {
            return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdList);
        }
        #endregion
@@ -3200,33 +3301,6 @@
            }
        }
        private void sdy_Click(object sender, EventArgs e)
        {
            //判断是否已经生成条码
            if (DBUtility.ClsPub.isStrNull(grdSub.Rows[0].Cells[HTMCol].Value) == "")
            {
                MessageBox.Show("条码未生成,请先生成条码后再预览!");
                return;
            }
            //打印前判断条码是否已打印过
            if (ReportPrintBegin())
            {
                return;
            }
            //选择打印模板
            BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
            oFrm.sBillName = ModName;
            oFrm.sBillModel = ModCaption;
            oFrm.ShowDialog();
            if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
            {
                Sub_SetReportView(oFrm.sOpenTmp);
                Report.PrintPreview(false);
                Thread.Sleep(1000);
            }
        }
        //生成外箱码
        private void wxm_Click(object sender, EventArgs e)