王 垚
2022-04-06 9167264eeb081fdbb94d8a1d2f76f35a6ccdd5fe
WarM/ÌõÂë´òÓ¡/Gy_BarCodeBillList.cs
@@ -10,6 +10,7 @@
using DBUtility;
using System.Threading;
using System.IO;
using Pub_Class;
namespace WarM
{
@@ -28,10 +29,15 @@
        public const string ModRightNameCheck = ModRightName + "_Check";
        public const string ModRightNameClose = ModRightName + "_Close";
        public const string ModRightNameDelete = ModRightName + "_Delete";
        public const string ModRightNamePrint = ModRightName + "_Print";    //打印
        //DAL.ClsGy_ICBomBill oBill = new DAL.ClsGy_ICBomBill();
        //public  Gy_ICBomBill oFrm;
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        public int selectRow = 0;
        public int selectRow2 = 0;
        public long PrintQty = 0;               //允许条码打印次数
        public string PrintQtyCtl = "";         //条码打印次数控制
        public string UpdatePrintQtyCtl = "";   //条码打印次数更新
        //
        private void initGrid()
        {
@@ -135,6 +141,25 @@
            this.Text = ModCaption;
            lblCaption.Text = ModCaption;
            initGrid();
            Sub_GetSystemParameter();
        }
        //获取系统参数信息
        private void Sub_GetSystemParameter()
        {
            //获取系统参数
            ClsXt_SystemParameter oSystemParameter = new ClsXt_SystemParameter();
            if (oSystemParameter.ShowBill(ref DBUtility.ClsPub.sExeReturnInfo) == false)
            {
                MessageBox.Show("获取系统参数失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
                return;
            }
            else
            {
                PrintQty = oSystemParameter.omodel.BarCode_PrintQty;
                PrintQtyCtl = oSystemParameter.omodel.BarCode_PrintQtyCtl;
                UpdatePrintQtyCtl = oSystemParameter.omodel.BarCode_UpdatePrintQtyCtl;
            }
        }
        private void grdMain_DblClick(object sender, EventArgs e)
@@ -390,11 +415,23 @@
        #region  //打印设置
        GridppReport Report;
        int CurRows = 0;
        string sBarCodeItemID = ""; //条码自增列
        //预览
        int CurRows = 0;
        private void yl_Click(object sender, EventArgs e)
        {
            //打印预览权限
            if (!DBUtility.ClsPub.Security_Log(ModRightNamePrint, 1, true, DBUtility.ClsPub.CurUserName))
            {
                return;
            }
            //打印前判断条码是否超过允许可打印次数
            if (ReportPrintBegin())
            {
                return;
            }
            //选择打印模板
            BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
            oFrm.sBillName = ModName;
@@ -405,6 +442,60 @@
                Sub_SetReport(oFrm.sOpenTmp);
                Report.PrintPreview(false);
                Thread.Sleep(1000);
            }
        }
        //打印
        private void dy_Click(object sender, EventArgs e)
        {
            //打印预览权限
            if (!DBUtility.ClsPub.Security_Log(ModRightNamePrint, 1, true, DBUtility.ClsPub.CurUserName))
            {
                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(false);
                Thread.Sleep(1000);
            }
        }
        //打印前判断条码是否超过允许可打印次数
        private bool ReportPrintBegin()
        {
            DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
            string sHRemark = "";
            sBarCodeItemID = "";
            for (int i = 0; i < grdMain.SelectedRows.Count; i++)
            {
                sBarCodeItemID = sBarCodeItemID + "," + DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.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;
            }
        }
@@ -424,6 +515,7 @@
            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);
        }
        //填入单据表头信息
@@ -453,6 +545,8 @@
            }
            //CurRows = CurRows + 1;
        }
        //填入单据表体信息
        private void ReportFetchRecordByDataTable()
        {
            try
@@ -466,47 +560,19 @@
            }
        }
        #endregion
        //
        private void grdMain_Paint(object sender, PaintEventArgs e)
        {
            GraphicsGrid();
        }
        private void dy_Click(object sender, EventArgs e)
        //打印结束后回填条码打印次数
        private void ReportPrintEnd()
        {
            DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
            //打印前判断条码是否已打印过
            string sBarCode = "";
            string sRelQty = "";
            for (int i = 0; i < grdMain.SelectedRows.Count; i++)
            if (UpdatePrintQtyCtl == "Y")
            {
                sBarCode = sBarCode + "," + DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[Fun_GetCol("条码编号")].Value);
                oBar.Set_UpdatePrintQty(sBarCodeItemID);
            }
            //if (oBar.Set_BPrintQty(sBarCode.Substring(1), ref sRelQty))
            //{
            //    MessageBox.Show(sRelQty);
            //    return;
            //}
            //选择打印模板
            BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
            //DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
            oFrm.sBillName = ModName;
            oFrm.sBillModel = ModCaption;
            oFrm.ShowDialog();
            if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
            {
                Sub_SetReport(oFrm.sOpenTmp);
                Report.Print(false);
                //oBar.Set_PrintQty(DBUtility.ClsPub.isStrNull(grdMain.Rows[CurRows].Cells[Fun_GetCol("条码编号")].Value));
                Thread.Sleep(1000);
            }
            //批量更新条码打印次数
            oBar.Set_EPrintQty(sBarCode.Substring(1));
        }
        //连打
        private void dy2_Click(object sender, EventArgs e)
        {
            //选择打印模板
@@ -537,6 +603,15 @@
                    i++;
                }
            }
        }
        #endregion
        //
        private void grdMain_Paint(object sender, PaintEventArgs e)
        {
            GraphicsGrid();
        }
        private void yc_Click(object sender, EventArgs e)
@@ -633,7 +708,7 @@
        private void zf_Click(object sender, EventArgs e)
        {
            //Sub_AbandonCheck();
            if (!ClsPub.Security_Log(ModRightNameDelete, 1, true, DBUtility.ClsPub.CurUserName))
            if (!DBUtility.ClsPub.Security_Log(ModRightNameDelete, 1, true, DBUtility.ClsPub.CurUserName))
            {
                return;
            }
@@ -661,7 +736,7 @@
        private void fzf_Click(object sender, EventArgs e)
        {
            //this.Sub_CheckBill();
            if (!ClsPub.Security_Log(ModRightNameDelete, 1, true, DBUtility.ClsPub.CurUserName))
            if (!DBUtility.ClsPub.Security_Log(ModRightNameDelete, 1, true, DBUtility.ClsPub.CurUserName))
            {
                return;
            }