zrg
2025-05-08 428a4a5d860c121271c426015c08b646258b85d6
WFormSynchronizeData_SMR/WFormSynchronizeData_SMR/Form1.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
@@ -24,8 +25,13 @@
        //读取数据
        private void btnReadData_Click(object sender, EventArgs e)
        {
            DataTable list = oCN.RunProcReturn("select  * from Sb_EquipMentCollection_SN  WITH(NOLOCK) where HFlag=0  order by HCreateTime", "Sb_EquipMentCollection_SN").Tables[0];
            Stopwatch timer = new Stopwatch();
            timer.Start();
            CustomWriteLog("1.计时器开始:"+timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
            //根据时间正序排序获取前150条数据
            DataTable list = oCN.RunProcReturn("select top 150 * from Sb_EquipMentCollection_SN  WITH(NOLOCK) where HFlag=0  order by HCreateTime", "Sb_EquipMentCollection_SN").Tables[0];
          
            //循环集合
            for (int i = 0; i < list.Rows.Count; i++)
@@ -33,9 +39,10 @@
                bool flag = false;
                string HResult = list.Rows[i]["HResult"].ToString();
                string HBadCodeSN = list.Rows[i]["HBarCode"].ToString();
                string HCreateTime = list.Rows[i]["HCreateTime"].ToString();
                //开始事务
                oCN.BeginTran();
                CustomWriteLog("2.循环开始:" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                if (HResult == "OK")
                {
                    flag=HResultOK(list.Rows[i]);
@@ -45,23 +52,36 @@
                    flag = HResultNG(list.Rows[i]);
                }
                CustomWriteLog("2-1.循环结束:" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                if (flag) {
                    oCN.RunProc("update Sb_EquipMentCollection_SN set HFlag=1 where HBarCode='" + HBadCodeSN + "'");
                    oCN.RunProc("update Sb_EquipMentCollection_SN set HFlag=1 where HBarCode='" + HBadCodeSN + "' and HCreateTime='"+ HCreateTime + "'");
                    //结束事务
                    oCN.Commit();
                }
              
            }
            CustomWriteLog("3.结束计时:" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
            timer.Stop();//结束计时
        }
        public bool HResultOK(DataRow dic)
        {
            try
            {
                Stopwatch timer = new Stopwatch();
                timer.Start();
                CustomWriteLog("2.1.开始ok:" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                bool flag = false;
                string HBadCodeSN = dic["HBarCode"].ToString();
                HBadCodeSN = TM_ZH(HBadCodeSN);
                //判断当天条码有没有存储在条码表里 如果没有 则保存数据 并返回0
                //如果已存在 则返回 1
                //如果条件不满足的 则返回 2
                int num = SNHBardCodeList(HBadCodeSN);
                CustomWriteLog("2.2.条码生成:" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                if (num == 0)
                {
@@ -70,20 +90,30 @@
                else if (num == 1)
                {
                    //判断这个条码之前的状态是否为NG
                    DataSet ds = oCN.RunProcReturn(@"select * from Sb_EquipMentCollection_SN  WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "' and HCreateTime<'" + dic["HCreateTime"].ToString() + "' and HResult='NG'  and HProcNumber='" + dic["HProcNumber"].ToString() + "'", "Sb_EquipMentCollection_SN");
                    DataSet ds = oCN.RunProcReturn(@"select * from Sb_EquipMentCollection_SN  WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "' and HCreateTime<'" + dic["HCreateTime"].ToString() + "' and HResult='NG'", "Sb_EquipMentCollection_SN");
                    DataSet ds1 = oCN.RunProcReturn(@"select a.HSourceID,a.HProcID,* from Sc_StationOutBillMain a WITH(NOLOCK)
                    //查询出站单是否包含条码
                    //                    DataSet ds1 = oCN.RunProcReturn(@"select a.HSourceID,a.HProcID,* from Sc_StationOutBillMain a WITH(NOLOCK)
                    //inner join Sc_StationOutBillSub_SN sn WITH(NOLOCK) on a.HInterID=sn.HInterID
                    //left join Gy_Source s WITH(NOLOCK) on a.HSourceID=s.HItemID
                    //left join Gy_Process p WITH(NOLOCK) on a.HProcID=p.HItemID
                    //where  p.HNumber='" + dic["HProcNumber"].ToString() + "' and sn.HBarCode='" + HBadCodeSN + "'", "Sc_StationOutBillSub_SN");
                    //查询这个工序对应的条码 出站单是否已经存在
                    DataSet ds1 = oCN.RunProcReturn(@"select a.HProcID from Sc_StationOutBillMain a WITH(NOLOCK)
inner join Sc_StationOutBillSub_SN sn WITH(NOLOCK) on a.HInterID=sn.HInterID
left join Gy_Source s WITH(NOLOCK) on a.HSourceID=s.HItemID
left join Gy_Process p WITH(NOLOCK) on a.HProcID=p.HItemID
where  p.HNumber='" + dic["HProcNumber"].ToString() + "' and sn.HBarCode='" + HBadCodeSN + "'", "Sc_StationOutBillSub_SN");
                    //判断条码之前是否为NG  同时 判断出站单的条码数据是不存在
                    if (ds.Tables[0].Rows.Count > 0 && ds1.Tables[0].Rows.Count == 0)
                    {
                        //返修好的条码进行重新过站保存
                        flag = getOKOutBillAdd(dic, HBadCodeSN, "OK");
                    }
                    else
                    {
                        //出站单的条码数据是不存在 则新增
                        if (ds1.Tables[0].Rows.Count > 0)
                        {
                            flag = true;
@@ -99,6 +129,9 @@
                {
                    flag = false;
                }
                CustomWriteLog("2.5.结束计时:" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                timer.Stop();//结束计时
                return flag;
            }
@@ -119,6 +152,9 @@
                int num = 0;
                string HBadCodeSN = dic["HBarCode"].ToString();
                HBadCodeSN = TM_ZH(HBadCodeSN);
                //判断当天条码有没有存储在条码表里 如果没有 则保存数据 并返回0
                //如果已存在 则返回 1
                //如果条件不满足的 则返回 2
                num = SNHBardCodeList(HBadCodeSN);
                if (num == 0 || num == 1)
@@ -154,11 +190,17 @@
        {
            try
            {
                Stopwatch timer = new Stopwatch();
                timer.Start();
                CustomWriteLog("2.1.1.出站单新增开始:" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                //获取绑定流转卡
                DataSet ds = oCN.RunProcReturn(@"select * from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
                string HProcExchBillNo = ds.Tables[0].Rows[0]["HSourceBillNo"].ToString();
                string HProcNumber = dic["HProcNumber"].ToString();
                CustomWriteLog("2.1.2.绑定流转卡:"+ HProcNumber+"----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                //查询生产资源
                ds = oCN.RunProcReturn("select * from Gy_Source WITH(NOLOCK) where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
                long HSourceID = 0;
                if (ds.Tables[0].Rows.Count != 0)
@@ -166,20 +208,26 @@
                    HSourceID = long.Parse(ds.Tables[0].Rows[0]["HItemID"].ToString());//生产资源ID
                }
                CustomWriteLog("2.1.3.获取生产资源:" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                //查询职员
                ds = oCN.RunProcReturn("select * from Gy_Employee WITH(NOLOCK) where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
                long HEmpIDs = 0;
                string HEmpName = "";
                if (ds.Tables[0].Rows.Count != 0)
                {
                    HEmpIDs = long.Parse(ds.Tables[0].Rows[0]["HItemID"].ToString());//职员ID
                    HEmpName = ds.Tables[0].Rows[0]["HName"].ToString();
                }
                CustomWriteLog("2.1.4.查询职员信息:" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                long HDeptID = 0;
                long HPRDOrgIDs = 0;
                string sReturn = "";
                if (GetSingleSystemParameter("WMS_CampanyName", ref sReturn) == "杭州斯莫尔")
                {
                    HDeptID = 389499;
                    HDeptID = 389505;
                    HPRDOrgIDs = 100199;
                }
                else {
@@ -192,20 +240,24 @@
                    HDeptID = 0;
                }
                CustomWriteLog("2.1.5.获取客户信息:" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                ds = oCN.RunProcReturn(@"select   b.HProcNo,b.HProcID,a.HMaterID,a.HQty,a.HInterID,HEntryID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
                //根据流转卡和工序 查询出站单需要保存的信息
                ds = oCN.RunProcReturn(@"select   a.HWorkShopID,b.HProcNo,b.HProcID,a.HMaterID,a.HQty,a.HInterID,HEntryID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo,b.HCenterID  from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
inner join Sc_ProcessExchangeBillSub b WITH(NOLOCK) on a.HInterID=b.HInterID
left join Gy_Process p WITH(NOLOCK) on  b.HProcID=p.HItemID 
where a.HBillNo='" + HProcExchBillNo + "'  and p.HNumber='" + HProcNumber + "'", "Sc_ProcessExchangeBillMain");
                CustomWriteLog("2.1.6.查询流转卡信息:" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                string sExeReturnInfo = "";
                long HMainInterID = 0;
                string BillType = "3791";
                string HBillSubType = "3791";
                string HWorkShopID= ds.Tables[0].Rows[0]["HWorkShopID"].ToString();
                int HBillStatus = 1;
                string HMaker = "";//制单人
                string HMaker = HEmpName;//制单人
                string HMouldNum = "";//模穴号
                int HYear = DateTime.Now.Year;
                double HPeriod = DateTime.Now.Month;
@@ -246,7 +298,7 @@
                double HPrice = 0;
                double HMoney = 0;
                double HBadCount = 0;//不良数量
                long HCenterID = 0;//工作中心ID
                long HCenterID = long.Parse(ds.Tables[0].Rows[0]["HCenterID"].ToString());//工作中心ID
                string HProcNo = ds.Tables[0].Rows[0]["HProcNo"].ToString();//流水号
                string HOrderProcNO = "";//订单跟踪号
                string HSourceNameList = "";//设备清单
@@ -266,6 +318,31 @@
                int HTemporaryAreaID = 0;//暂放区
                long HInterID = 0;
                string HBillNo = "";
                int HShiftsID = 0;
                CustomWriteLog("2.1.7给字段赋值 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                //获取班次
                DataSet set= oCN.RunProcReturn("exec h_p_Gy_GetWorkShiftInfo " + HWorkShopID + "," + HCenterID, "h_p_Gy_GetWorkShiftInfo");
                if (set.Tables[0].Rows.Count > 0) {
                    HShiftsID = int.Parse(set.Tables[0].Rows[0]["HInterID"].ToString());
                }
                CustomWriteLog("2.1.8获取班次信息 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                //ds = oCN.RunProcReturn("exec h_p_Sc_SNBarcodeProcCtrl_S '" + HBadCodeSN + "'," + HProcID, "h_v_Gy_QualifiedRecordsList");
                //if (ds.Tables[0].Rows.Count == 0)
                //{
                //    oCN.RollBack();
                //    CustomWriteLog("条码:" + HBadCodeSN + "工序:" + HProcID + ",工序控制查无数据!", DateTime.Now.ToString("yyyy-MM-dd"));
                //    return false;
                //}
                //else if (ds.Tables[0].Rows[0]["HBack"].ToString() == "2")
                //{
                //    oCN.RollBack();
                //    CustomWriteLog("条码:" + HBadCodeSN + "工序:" + HProcID + "," + ds.Tables[0].Rows[0]["HBackRemark"].ToString() + "!", DateTime.Now.ToString("yyyy-MM-dd"));
                //    return false;
                //}
                //判断当前流转卡的出站单 是否有数据
@@ -273,6 +350,9 @@
left join Gy_Process p WITH(NOLOCK) on  a.HProcID=p.HItemID
where HProcExchBillNo='" + HProcExchBillNo + "' and p.HNumber='" + HProcNumber + "' and CONVERT(varchar(10),HDate,20) ='" + DateTime.Now.ToString("yyyy-MM-dd") + "'", "Sc_StationOutBillMain");
                CustomWriteLog("2.1.9获取是否有出站单 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                //如果没有出站单则新增出站单
                if (ds.Tables[0].Rows.Count != 0)
                {
                    HInterID = long.Parse(ds.Tables[0].Rows[0]["HInterID"].ToString());
@@ -295,7 +375,7 @@
                   ",HSupID,HQty,HPrice,HMoney,HBadCount,HCenterID,HProcNo,HOrderProcNO,HSourceNameList" +
                   ",HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HLastSubProc" +
                   ",HEmpID2,HEmpID3,HEmpID4,HEmpID5,HDSQty,HChongQty,HPriceRate,HWorkTimes,HQCCheckID,HMainInterID,HPRDOrgID" +
                       ",HmaterOutqty,HProcPriceRate,HTemporaryAreaID" +
                   ",HmaterOutqty,HProcPriceRate,HTemporaryAreaID,HShiftsID" +
                   ") " +
                   " values('" + BillType + "','" + HBillSubType + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate(),'" + HMouldNum + "'" +
                   "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HSourceName + "'," + HPieceQty + "," + HWasterQty + "," + HPlanPieceQty + "," + HBadPNL +
@@ -305,24 +385,55 @@
                   "," + HSupID + "," + HQty + "," + HPrice + "," + HMoney + "," + HBadCount + "," + HCenterID + "," + HProcNo + ",'" + HOrderProcNO + "'" + ",'" + HSourceNameList + "'" +
                   "," + HMainSourceInterID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'," + Convert.ToString(HLastSubProc ? 1 : 0) +
                   "," + HEmpID2 + "," + HEmpID3 + "," + HEmpID4 + "," + HEmpID5 + "," + HDSQty + "," + HChongQty + "," + HPriceRate + "," + HWorkTimes + "," + HQCCheckID + "," + HMainInterID + "," + HPRDOrgID +
                 "," + HmaterOutqty + "," + HProcPriceRate + "," + HTemporaryAreaID + ") ");
                 "," + HmaterOutqty + "," + HProcPriceRate + "," + HTemporaryAreaID + ","+ HShiftsID + ") ");
                }
                CustomWriteLog("2.1.10 出站单新增 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                if (HResult == "OK")
                {
                    CustomWriteLog("2.1.11 条码反写 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                    //查询 出站单子表 条码表的数据
                    ds = oCN.RunProcReturn("select  * from Sc_StationOutBillSub_SN WITH(NOLOCK) where HInterID='" + HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
                    string HMakeTime = dic["HCreateTime"].ToString();
                    oCN.RunProc($@"insert into Sc_StationOutBillSub_SN(HInterID,HBillNo_bak,HEntryID,HBarCode,HBarCodeQty,HMakeTime,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney)
values({ HInterID}, '{ HBillNo}', {(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)}, '{HBadCodeSN}', 1, '"+ HMakeTime + "', '', " + HProcExchInterID + "," + HProcExchEntryID + ", '" + HProcExchBillNo + "', '', 0, 0)");
                    CustomWriteLog("条码:" + HBadCodeSN + "工序:" + HProcNumber + ",出站时间:" + HMakeTime, "TM" + DateTime.Now.ToString("yyyy-MM-dd"));
                    //反写工序出站单的合格数量
                    oCN.RunProc("update Sc_StationOutBillMain  set HQty+=1  where HInterID='" + HInterID + "'");
                    CustomWriteLog("2.1.12 条码反写 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                }
                else if (HResult == "NG")
                {
                    //反写工序出站单的不良数量
                    oCN.RunProc("update Sc_StationOutBillMain  set HBadCount+=1 where HInterID='" + HInterID + "'");
                    CustomWriteLog("2.1.13 不合格反写 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                    //通过条码查询生产质量汇报单数据
                    ds = oCN.RunProcReturn("select  * from Sc_QualityReportBillSub WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "' order by HMakeDate desc", "Sc_QualityReportBillSub");
                    if (ds.Tables[0].Rows.Count > 0) {
                        string HBadDate = ds.Tables[0].Rows[0]["HMakeDate"].ToString();
                        //通过条码查询返修记录单的数据
                        ds = oCN.RunProcReturn("select  * from Sc_SourceLineRepairBillMain WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "' order by HMakeDate desc", "Sc_SourceLineRepairBillMain");
                        if (ds.Tables[0].Rows.Count > 0) {
                            string HRepairDate = ds.Tables[0].Rows[0]["HMakeDate"].ToString();
                            //判断 生产质量汇报单的创建时间 是否 小于 返修记录的创建时间
                            //正常情况是 先生成生产质量汇报单 然后才会去返修
                            //如果条码生成质量汇报单的时间 大于返修记录的时间 则证明这个条码属于测试条码 正常 返修OK的才会进入这个出站单保存方法 不会进入NG
                            if (DateTime.Parse(HBadDate) < DateTime.Parse(HRepairDate)) {
                                //反写工序出站单的不良数量
                                oCN.RunProc("update Sc_StationOutBillMain  set HBadCount+=1,HWasterQty_Work+=1 where HInterID='" + HInterID + "'");
                            }
                        }
                    } else {
                        //反写工序出站单的不良数量
                        oCN.RunProc("update Sc_StationOutBillMain  set HBadCount+=1,HWasterQty_Work+=1 where HInterID='" + HInterID + "'");
                    }
                    CustomWriteLog("2.1.14 不合格反写 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                }
                else
                {
@@ -331,18 +442,29 @@
                    return false;
                }
                //查询出站数量是否超过流转卡数量
                ds = oCN.RunProcReturn($@"select (b.HQty -sum(isnull(ou.HQty,0))-sum(isnull(ou.HBadCount,0))) HQty from Sc_ProcessExchangeBillSub b WITH(NOLOCK)
left join Sc_StationOutBillMain ou WITH(NOLOCK) on b.HInterID=ou.HProcExchInterID and b.HEntryID=ou.HProcExchEntryID
where b.HInterID={HProcExchInterID} and b.HEntryID={HProcExchEntryID}
group by b.HInterID,b.HEntryID,b.HQty", "Sc_ProcessExchangeBill_Out");
                //                //查询出站数量是否超过流转卡数量
                //                ds = oCN.RunProcReturn($@"select (b.HQty -sum(isnull(ou.HQty,0))-sum(isnull(ou.HBadCount,0))) HQty from Sc_ProcessExchangeBillSub b WITH(NOLOCK)
                //left join Sc_StationOutBillMain ou WITH(NOLOCK) on b.HInterID=ou.HProcExchInterID and b.HEntryID=ou.HProcExchEntryID
                //where b.HInterID={HProcExchInterID} and b.HEntryID={HProcExchEntryID}
                //group by b.HInterID,b.HEntryID,b.HQty", "Sc_ProcessExchangeBill_Out");
                if (double.Parse(ds.Tables[0].Rows[0][0].ToString()) < 0)
                //                if (double.Parse(ds.Tables[0].Rows[0][0].ToString()) < 0)
                //                {
                //                    oCN.RollBack();
                //                    CustomWriteLog("流转卡:"+ HProcExchBillNo + ",出站数量超过流转卡数量!", DateTime.Now.ToString("yyyy-MM-dd"));
                //                    return false;
                //                }
                CustomWriteLog("2.1.15 反写结束 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                //增加工序判断
                if (HProcNumber == "013")
                {
                    oCN.RollBack();
                    CustomWriteLog("流转卡:"+ HProcExchBillNo + ",出站数量超过流转卡数量!", DateTime.Now.ToString("yyyy-MM-dd"));
                    return false;
                    return true;
                }
                CustomWriteLog("2.1.16 工艺参数绑定 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                bool flag = false;
@@ -354,23 +476,31 @@
                    CustomWriteLog("系统参数保存失败,条码:" + HBadCodeSN, DateTime.Now.ToString("yyyy-MM-dd"));
                    return false;
                }
                CustomWriteLog("2.1.17 工艺参数绑定结束 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                //增加产线组装追溯单
                //查询流转卡和工序对应的配件信息  如果有 则查询配件的数量
                DataSet dataSet = oCN.RunProcReturn("exec h_p_Gy_BarCodeBillBomList '" + HProcExchBillNo + "'," + HProcID, "h_p_Gy_BarCodeBillBomList");
                CustomWriteLog("2.1.18 产线组装追溯单查询 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                if (dataSet.Tables[0].Rows.Count > 0)
                {
                    CustomWriteLog("2.1.19 产线组装追溯单数量判断 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                    //判配件数量是否等于0
                    for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
                    {
                        double SYHQty = double.Parse(dataSet.Tables[0].Rows[i]["配件数量"].ToString());
                        string HMaterNamePJ = dataSet.Tables[0].Rows[i]["配件代码"].ToString();
                        string HMaterBarCode = dataSet.Tables[0].Rows[i]["HBarCode"].ToString();
                        if (SYHQty == 0) {
                            oCN.RollBack();
                            CustomWriteLog("配件代码:" + HMaterNamePJ + ",数量为0!", DateTime.Now.ToString("yyyy-MM-dd"));
                            CustomWriteLog("配件条码:"+ HMaterBarCode + ",配件代码:" + HMaterNamePJ + ",数量为0!", DateTime.Now.ToString("yyyy-MM-dd"));
                            return false;
                        }
                    }
                    CustomWriteLog("2.1.20 产线组装追溯单数量判断结束 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                    //查询职员
@@ -381,6 +511,8 @@
                        HEmpIDs = long.Parse(ds.Tables[0].Rows[0]["HItemID"].ToString());//职员ID
                        HMakers = ds.Tables[0].Rows[0]["HName"].ToString();
                    }
                    CustomWriteLog("2.1.21 职员查询 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                    Int64 HInterID1 = CreateBillID("3727", ref sExeReturnInfo);
                    string HBillNo1 = CreateBillCode_Prod("3727", ref sExeReturnInfo, true);
@@ -393,6 +525,9 @@
,'{HBillNo1}','1','{HMakers}',getdate(),{HProcExchInterID},{HProcExchEntryID},'{HProcExchBillNo}'
,{HICMOInterID},'{HICMOBillNo}','{HBadCodeSN}',{HMaterID},0,'汇报',{HPRDOrgIDs})";
                    oCN.RunProc(sql);
                    CustomWriteLog("2.1.22 保存主表 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                    for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
                    {
@@ -407,8 +542,11 @@
                ,0,0,getdate(),'{HBarCodes}','{HBadCodeSN}','') ";
                        oCN.RunProc(sq2);
                    }
                }
                    CustomWriteLog("2.1.23 保存子表 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                }
                CustomWriteLog("2.1.24计时器结束 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                timer.Stop();//结束计时
                return true;
            }
            catch (Exception e)
@@ -425,11 +563,11 @@
            try
            {
                //获取绑定流转卡
                DataSet ds = oCN.RunProcReturn(@"select * from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
                DataSet ds = oCN.RunProcReturn(@"select HSourceBillNo from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
                string HProcExchBillNo = ds.Tables[0].Rows[0]["HSourceBillNo"].ToString();
                string HProcNumber = dic["HProcNumber"].ToString();
                ds = oCN.RunProcReturn("select * from Gy_Source WITH(NOLOCK) where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
                ds = oCN.RunProcReturn("select HItemID from Gy_Source WITH(NOLOCK) where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
                long HSourceID = 0;
                if (ds.Tables[0].Rows.Count != 0)
                {
@@ -437,7 +575,7 @@
                }
                //查询职员
                ds = oCN.RunProcReturn("select * from Gy_Employee WITH(NOLOCK) where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
                ds = oCN.RunProcReturn("select HItemID from Gy_Employee WITH(NOLOCK) where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
                long HEmpIDs = 0;
                if (ds.Tables[0].Rows.Count != 0)
                {
@@ -449,7 +587,7 @@
                string sReturn = "";
                if (GetSingleSystemParameter("WMS_CampanyName", ref sReturn) == "杭州斯莫尔")
                {
                    HDeptID = 389499;
                    HDeptID = 389505;
                    HPRDOrgIDs = 100199;
                }
                else
@@ -463,6 +601,7 @@
                    HDeptID = 0;
                }
                //根据流转卡和工序 查询出站单需要保存的信息
                ds = oCN.RunProcReturn(@"select   b.HProcNo,b.HProcID,a.HMaterID,a.HQty,a.HInterID,HEntryID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo 
                from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
                inner join Sc_ProcessExchangeBillSub b WITH(NOLOCK) on a.HInterID=b.HInterID
@@ -479,12 +618,28 @@
                long HInterID = 0;
                string HBillNo = "";
                ds = oCN.RunProcReturn("select  * from Sc_AssemblyBillMain WITH(NOLOCK) where HMainSourceInterID=" + HProcExchInterID + " and HMainSourceEntryID=" + HProcExchEntryID, "Sc_AssemblyBillMain");
                //ds = oCN.RunProcReturn("exec h_p_Sc_SNBarcodeProcCtrl_S '" + HBadCodeSN + "'," + HProcID, "h_v_Gy_QualifiedRecordsList");
                //if (ds.Tables[0].Rows.Count == 0)
                //{
                //    oCN.RollBack();
                //    CustomWriteLog("条码:" + HBadCodeSN + "工序:" + HProcID + ",工序控制查无数据!", DateTime.Now.ToString("yyyy-MM-dd"));
                //    return false;
                //}
                //else if (ds.Tables[0].Rows[0]["HBack"].ToString() == "2")
                //{
                //    oCN.RollBack();
                //    CustomWriteLog("条码:" + HBadCodeSN + "工序:" + HProcID + "," + ds.Tables[0].Rows[0]["HBackRemark"].ToString() + "!", DateTime.Now.ToString("yyyy-MM-dd"));
                //    return false;
                //}
                //查询产线组装追溯单的数据  获取时间 根据时间判断对应 是哪天出站单的数据
                ds = oCN.RunProcReturn("select  HDate from Sc_AssemblyBillMain WITH(NOLOCK) where HMainSourceInterID=" + HProcExchInterID + " and HMainSourceEntryID=" + HProcExchEntryID, "Sc_AssemblyBillMain");
                DateTime HDate=DateTime.Now;
                //当产品没有配件的时候 查询 不良记录
                if (ds.Tables[0].Rows.Count == 0)
                {
                    ds = oCN.RunProcReturn("select  * from Sc_QualityReportBillSub WITH(NOLOCK) where HProcExchInterID=" + HProcExchInterID + " and HProcExchEntryID=" + HProcExchEntryID+ " and HBarCode='" + HBadCodeSN + "'", "Sc_AssemblyBillMain");
                    //查询生产质量汇报单数据
                    ds = oCN.RunProcReturn("select HMakeDate from Sc_QualityReportBillSub WITH(NOLOCK) where HProcExchInterID=" + HProcExchInterID + " and HProcExchEntryID=" + HProcExchEntryID+ " and HBarCode='" + HBadCodeSN + "'", "Sc_AssemblyBillMain");
                    HDate = DateTime.Parse(ds.Tables[0].Rows[0]["HMakeDate"].ToString());
                }
                else {
@@ -505,7 +660,7 @@
                }
                //判断当前流转卡的出站单 是否有数据
                ds = oCN.RunProcReturn(@"select  * from Sc_StationOutBillMain a WITH(NOLOCK)
                ds = oCN.RunProcReturn(@"select  HInterID,HBillNo from Sc_StationOutBillMain a WITH(NOLOCK)
left join Gy_Process p WITH(NOLOCK) on  a.HProcID=p.HItemID
where HProcExchBillNo='" + HProcExchBillNo + "' and p.HNumber='" + HProcNumber + "' and CONVERT(varchar(10),HDate,20) ='" + HDate.ToString("yyyy-MM-dd") + "'", "Sc_StationOutBillMain");
@@ -517,14 +672,17 @@
                if (HResult == "OK")
                {
                    ds = oCN.RunProcReturn("select  * from Sc_StationOutBillSub_SN  WITH(NOLOCK) where HInterID='" + HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
                    ds = oCN.RunProcReturn("select  HInterID,HEntryID from Sc_StationOutBillSub_SN  WITH(NOLOCK) where HInterID='" + HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
                    string HMakeTime = dic["HCreateTime"].ToString();
                    oCN.RunProc($@"insert into Sc_StationOutBillSub_SN(HInterID,HBillNo_bak,HEntryID,HBarCode,HBarCodeQty,HMakeTime,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney)
values({ HInterID}, '{ HBillNo}', {(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)}, '{HBadCodeSN}', 1, '" + HMakeTime + "', '', " + HProcExchInterID + "," + HProcExchEntryID + ", '" + HProcExchBillNo + "', '', 0, 0)");
                    CustomWriteLog("条码:" + HBadCodeSN + "工序:"+ HProcNumber + ",出站时间:" + HMakeTime, "TM" + DateTime.Now.ToString("yyyy-MM-dd"));
                    //反写工序出站单的合格数量
                    oCN.RunProc("update Sc_StationOutBillMain set HQty+=1,HBadCount-=1  where HInterID='" + HInterID + "'");
                    //oCN.RunProc("update Sc_StationOutBillMain set HQty+=1,HBadCount-=1  where HInterID='" + HInterID + "'");
                    oCN.RunProc("update Sc_StationOutBillMain set HQty+=1  where HInterID='" + HInterID + "'");
                    //反写条码状态
                    oCN.RunProc("update Gy_BarCodeBill set HStatus=''  where HBarCode='" + HBadCodeSN + "'");
                }
@@ -551,35 +709,43 @@
            try
            {
                DataSet ds = oCN.RunProcReturn("select  * from Sc_StationOutBillMain WITH(NOLOCK) where HInterID=" + HInterID + " and HBillNo='" + HBillNo + "'", "Sc_StationOutBillMain");
                //查询出站单的信息 方便参数保存
                 DataSet ds = oCN.RunProcReturn(@"select a.HProcExchInterID,a.HProcExchEntryID,a.HProcExchBillNo,a.HProcID,p.HNumber from Sc_StationOutBillMain a WITH(NOLOCK)
left join Gy_Process p WITH(NOLOCK)  on a.HProcID=p.HItemID where HInterID=" + HInterID + " and HBillNo='" + HBillNo + "'", "Sc_StationOutBillMain");
                string HProcExchInterID = ds.Tables[0].Rows[0]["HProcExchInterID"].ToString();
                string HProcExchEntryID = ds.Tables[0].Rows[0]["HProcExchEntryID"].ToString();
                string HProcExchBillNo = ds.Tables[0].Rows[0]["HProcExchBillNo"].ToString();
                ds = oCN.RunProcReturn(@"select  s.HItemID HMouldID,t.HItemID HTechParamID,HCount,HCreateTime from  Sb_EquipMentCollectionTechParam_SN a WITH(NOLOCK)
                string HProcID = ds.Tables[0].Rows[0]["HProcID"].ToString();
                string HProcNum = ds.Tables[0].Rows[0]["HNumber"].ToString();
                //注:因为 组装 拍照 时间间隔比较短  所以目前只明确组装工序才可以保存工艺参数 之后如果有其他工序的话  需要增加工序字段
                if (HProcID == "88"|| HProcNum=="005") {
                    //查询工艺参数临时表 获取当天条码对应的参数
                    ds = oCN.RunProcReturn(@"select  s.HItemID HMouldID,t.HItemID HTechParamID,HCount,HCreateTime,a.HResult from  Sb_EquipMentCollectionTechParam_SN a WITH(NOLOCK)
inner join Gy_Source s WITH(NOLOCK) on a.HSourceCode=s.HNumber
inner join Gy_TechnologyParameter t WITH(NOLOCK) on a.HType=t.HName
where a.HFlag=0 and a.HBarCode='" + HBadCodeSN + "'", "Sb_EquipMentCollectionTechParam_SN");
                //注:当前只有一道工序有参数 如果有多道工序的话 需要增加 工序的过滤
                    //注:当前只有一道工序有参数 如果有多道工序的话 需要增加 工序的过滤
                if (ds.Tables[0].Rows.Count != 0) {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    if (ds.Tables[0].Rows.Count != 0)
                    {
                        string HMouldID = ds.Tables[0].Rows[i]["HMouldID"].ToString();
                        string HTechParamID = ds.Tables[0].Rows[i]["HTechParamID"].ToString();
                        string HCount = ds.Tables[0].Rows[i]["HCount"].ToString();
                        string HGetTime = ds.Tables[0].Rows[i]["HCreateTime"].ToString();
                        DataSet dataSet = oCN.RunProcReturn("select * from Sc_StationOutBillSub_TechParam WITH(NOLOCK) where HInterID=" + HInterID + " and HBillNo_bak='" + HBillNo + "'", "Sc_StationOutBillSub_TechParam");
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            string HMouldID = ds.Tables[0].Rows[i]["HMouldID"].ToString();
                            string HTechParamID = ds.Tables[0].Rows[i]["HTechParamID"].ToString();
                            string HCount = ds.Tables[0].Rows[i]["HCount"].ToString();
                            string HGetTime = ds.Tables[0].Rows[i]["HCreateTime"].ToString();
                            string HResult = ds.Tables[0].Rows[i]["HResult"].ToString();
                        sql = "insert into Sc_StationOutBillSub_TechParam(HInterID,HBillNo_bak,HEntryID ,HSourceInterID,HSourceEntryID,HSourceBillNo,HTechParamID,HRelValue,HGetTime,HBarCode,HMouldID)" +
                            $"values({HInterID},'{HBillNo}',{(dataSet.Tables[0].Rows.Count + 1)},{HProcExchInterID},{HProcExchEntryID},'{HProcExchBillNo}',{HTechParamID},{HCount},'{HGetTime}','{HBadCodeSN}',{HMouldID})";
                            DataSet dataSet = oCN.RunProcReturn("select * from Sc_StationOutBillSub_TechParam WITH(NOLOCK) where HInterID=" + HInterID + " and HBillNo_bak='" + HBillNo + "'", "Sc_StationOutBillSub_TechParam");
                        oCN.RunProc(sql);
                            sql = "insert into Sc_StationOutBillSub_TechParam(HInterID,HBillNo_bak,HEntryID ,HSourceInterID,HSourceEntryID,HSourceBillNo,HTechParamID,HRelValue,HGetTime,HBarCode,HMouldID,HRemark)" +
                                $"values({HInterID},'{HBillNo}',{(dataSet.Tables[0].Rows.Count + 1)},{HProcExchInterID},{HProcExchEntryID},'{HProcExchBillNo}',{HTechParamID},{HCount},'{HGetTime}','{HBadCodeSN}',{HMouldID},'{HResult}')";
                            oCN.RunProc(sql);
                        }
                        oCN.RunProc("update Sb_EquipMentCollectionTechParam_SN set HFlag=1 where HBarCode='" + HBadCodeSN + "'");
                    }
                    oCN.RunProc("update Sb_EquipMentCollectionTechParam_SN set HFlag=1 where HBarCode='" + HBadCodeSN + "'");
                }
                return true;
@@ -597,14 +763,60 @@
        {
            try
            {
                DataSet ds = oCN.RunProcReturn(@"select * from Gy_BarCodeBill where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
                //判断条码是否存在条码档案
                if (ds.Tables[0].Rows.Count > 0)
                {
                    string HSourceBillNo = ds.Tables[0].Rows[0]["HSourceBillNo"].ToString();
                    DataSet dataTable = oCN.RunProcReturn(@"select * from Sc_ProcessExchangeBillMain where HBillNo='" + HSourceBillNo + "'", "Sc_ProcessExchangeBillMain");
                    //判断条码的源单 流转卡是否被删除
                    if (dataTable.Tables[0].Rows.Count == 0)
                    {
                        //如果源单已经删除  则条码也删除重新生成
                        oCN.RunProc("delete from Gy_BarCodeBill where HBarCode='" + HBadCodeSN + "'");
                        //重新查询条码档案 进入新增方法
                        ds = oCN.RunProcReturn(@"select * from Gy_BarCodeBill where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
                    }
                }
                //判断条码是否在数据库里
                if (ds.Tables[0].Rows.Count == 0)
                {
                    //判断长度是否为29位
                    //判断长度是否为29位 无尘车间
                    if (HBadCodeSN.Length == 29)
                    {
                        string str1 = HBadCodeSN.Substring(23, 3);
                        string str1 = HBadCodeSN.Substring(18, 8);
                        ds = oCN.RunProcReturn("select  * from Sc_ProcessExchangeBillMain where HProjectNum like'" + str1 + "-1%'", "Sc_ProcessExchangeBillMain");
                        //判断是否能找到对应的流转卡
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            string HProcExchBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
                            get_HBardBillSave(HBadCodeSN, HProcExchBillNo);
                        }
                        else
                        {
                            str1 = HBadCodeSN.Substring(23, 3);
                            ds = oCN.RunProcReturn("select  * from Sc_ProcessExchangeBillMain where HProjectNum like'" + str1 + "-1%'", "Sc_ProcessExchangeBillMain");
                            //判断是否能找到对应的流转卡
                            if (ds.Tables[0].Rows.Count > 0)
                            {
                                string HProcExchBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
                                get_HBardBillSave(HBadCodeSN, HProcExchBillNo);
                            }
                            else
                            {
                                oCN.RollBack();
                                CustomWriteLog("条码:" + HBadCodeSN + ",流转卡不存在!", DateTime.Now.ToString("yyyy-MM-dd"));
                                return 2;
                            }
                        }
                    }
                    //判断长度是否为50位  15车间
                    else if (HBadCodeSN.Length == 50)
                    {
                        string str1 = HBadCodeSN.Substring(42, 8);
                        ds = oCN.RunProcReturn("select  * from Sc_ProcessExchangeBillMain where HProjectNum like'" + str1 + "-1%'", "Sc_ProcessExchangeBillMain");
                        //判断是否能找到对应的流转卡
                        if (ds.Tables[0].Rows.Count > 0)
@@ -751,7 +963,7 @@
        //定时读取数据
        private void timer1_Tick(object sender, EventArgs e)
        {
            DataTable list = oCN.RunProcReturn("select  * from Sb_EquipMentCollection_SN WITH(NOLOCK) where HFlag=0  order by HCreateTime", "Sb_EquipMentCollection_SN").Tables[0];
            DataTable list = oCN.RunProcReturn("select top 100 * from Sb_EquipMentCollection_SN WITH(NOLOCK) where HFlag=0  order by HCreateTime asc", "Sb_EquipMentCollection_SN").Tables[0];
            //循环集合
            for (int i = 0; i < list.Rows.Count; i++)
@@ -759,10 +971,14 @@
                bool flag = false;
                string HResult = list.Rows[i]["HResult"].ToString();
                string HBadCodeSN = list.Rows[i]["HBarCode"].ToString();
                string HCreateTime = list.Rows[i]["HCreateTime"].ToString();
                //HBadCodeSN = "P1099081-00-E:SDU324292189300";
                //HResult = "OK";
                //开始事务
                oCN.BeginTran();
                if (HResult == "OK")
                 if (HResult == "OK")
                {
                    flag = HResultOK(list.Rows[i]);
                }
@@ -773,7 +989,7 @@
                if (flag)
                {
                    oCN.RunProc("update Sb_EquipMentCollection_SN set HFlag=1 where HBarCode='" + HBadCodeSN + "'");
                    oCN.RunProc("update Sb_EquipMentCollection_SN set HFlag=1 where HBarCode='" + HBadCodeSN + "' and HCreateTime='" + HCreateTime + "'");
                    //结束事务
                    oCN.Commit();
                }
@@ -800,7 +1016,7 @@
                string sReturn = "";
                if (GetSingleSystemParameter("WMS_CampanyName", ref sReturn) == "杭州斯莫尔")
                {
                    HDeptID = 389499;
                    HDeptID = 389505;
                }
                else
                {
@@ -817,11 +1033,14 @@
                string HProcExchEntryID = "0";
                string HProcExchBillNo = "";
                long HMaterID = 0;
                long HProcID = 0;
                long HUnitID = 0;
                long HICMOInterID = 0;
                long HICMOEntryID = 0;
                string HICMOBillNo = "";
                ds = oCN.RunProcReturn(@"select  HMaterID,HUnitID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo,HBillNo,a.HInterID,b.HEntryID,a.HBillNo from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
                //根据 条码+工序 查询流转卡信息
                ds = oCN.RunProcReturn(@"select b.HProcID, HMaterID,HUnitID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo,HBillNo,a.HInterID,b.HEntryID,a.HBillNo from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
inner join Sc_ProcessExchangeBillSub b  WITH(NOLOCK) on a.HInterID=b.HInterID
left join Gy_Process p WITH(NOLOCK) on b.HProcID=p.HItemID
where HBillNo=(select HSourceBillNo from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + dic["HBarCode"].ToString() + "') and p.HNumber='" + dic["HProcNumber"].ToString() + "'  ", "Sc_ProcessExchangeBillMain");
@@ -835,10 +1054,11 @@
                    HProcExchInterID = ds.Tables[0].Rows[0]["HInterID"].ToString();
                    HProcExchEntryID = ds.Tables[0].Rows[0]["HEntryID"].ToString();
                    HProcExchBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
                    HProcID = int.Parse(ds.Tables[0].Rows[0]["HProcID"].ToString());
                }
                ds = oCN.RunProcReturn("select * from Gy_Source WITH(NOLOCK) where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
                ds = oCN.RunProcReturn("select HItemID from Gy_Source WITH(NOLOCK) where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
                long HSourceID = 0;
                if (ds.Tables[0].Rows.Count != 0)
                {
@@ -873,11 +1093,11 @@
(HInterID,HENTRYID,HBillNo_bak,HEmpID,HBarCode,HBadReasonID,HAddr,HMaker,HMakeDate
,HMaterID,HUnitID,HRemark,HSourceID,HICMOInterID,HICMOEntryID,HICMOBillNo,HReportType
,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney
,HQty,HResult,HProcExchInterID,HProcExchEntryID,HProcExchBillNo)
values({HInterID},1,'{HBillNo}',{HEmpID},'{HBarCode}',0,'','{HMaker}','{HMakeDate}'
,HQty,HResult,HProcExchInterID,HProcExchEntryID,HProcExchBillNo,HProcID)
values({HInterID},1,'{HBillNo}',{HEmpID},'{HBarCode}',219,'','{HMaker}','{HMakeDate}'
,{HMaterID},{ HUnitID},'',{HSourceID},{ HICMOInterID},{ HICMOEntryID},'{HICMOBillNo}',0
,0,0,'','',0,0
,0,'{HResult}',{ HProcExchInterID},{ HProcExchEntryID},'{ HProcExchBillNo}')");
,1,'{HResult}',{ HProcExchInterID},{ HProcExchEntryID},'{ HProcExchBillNo}'," + HProcID + ")");
                return true;
            }
@@ -1096,5 +1316,13 @@
            }
        }
        #endregion
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MessageBox.Show("确定要关闭吗?", "确认", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                e.Cancel = true;
            }
        }
    }
}