wtt
4 天以前 311ff7d5a864a1e966848412df6d7880804db491
WebAPI/Controllers/POStockInBillController.cs
@@ -51,6 +51,7 @@
        public ClsGy_BarCodeBill_WMS_Model_View oView = new ClsGy_BarCodeBill_WMS_Model_View();
        public ClsKF_PonderationBillMain_Temp model = new ClsKF_PonderationBillMain_Temp();
        public ClsKf_ICStockBill_WMS oBar = new Model.ClsKf_ICStockBill_WMS();
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
        public double sRelQty = 0;
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        // private DataBaseServices objDataBaseServices = new DataBaseServices();
@@ -77,47 +78,101 @@
        /// <returns></returns>
        [Route("POStockInBill/get_CheckTypeByBarCode_Json")]
        [HttpGet]
        public Object get_CheckTypeByBarCode_Json(string sCode, Int64 sInterID, string sBillNo, string sBillType, string sMaker, Int64 WhID, Int64 SPID, Double sQty, bool sRedBlue, bool SourceFlag, string sSourceBillNo, string sSourceType, Int64 HOWNERID)
        //public Object get_CheckTypeByBarCode_Json(string sCode, Int64 sInterID, string sBillNo, string sBillType, string sMaker, Int64 WhID, Int64 SPID, Double sQty, bool sRedBlue, bool SourceFlag, string sSourceBillNo, string sSourceType, Int64 HOWNERID)
        //{
        //    try
        //    {
        //        string sErrMsg = "";
        //        string sJXCode = "";
        //        if (oSystemParameter.omodel.WMS_CampanyName == "安瑞") //系统参数  客户定制化名称     空白为通用
        //        {
        //            sJXCode = POStockInBillController.JX_Json(sCode, sInterID, HBillType, HOWNERID, sBillNo, sMaker);
        //            SourceFlag = true;
        //        }
        //        else
        //        {
        //            sJXCode = sCode;
        //        }
        //        //var sJXCode = POStockInBillController.JX_Json(sCode, sInterID, HBillType, HOWNERID, HBillNo, sMaker);
        //        //if (sRedBlue == true)
        //        //{
        //        //    HBillType = "1239";
        //        //}
        //        //oBar = webserver.get_CheckTypeByBarCode(sCode, sInterID, sBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID, ref DBUtility.ClsPub.sErrInfo);
        //        WebS.WebService1 oWebs = new WebS.WebService1();
        //        WebS.ClsKf_ICStockBill_WMS WebSoBar = new WebS.ClsKf_ICStockBill_WMS();
        //        string sExpressNumber = "";
        //        WebSoBar = oWebs.get_CheckTypeByBarCode_All(sJXCode, sInterID, HBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID, sExpressNumber, ref DBUtility.ClsPub.sErrInfo);
        //        //WebSoBar = oWebs.get_ba(sCode, sInterID, HBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID, sExpressNumber, ref DBUtility.ClsPub.sErrInfo);
        //        if (WebSoBar == null)
        //        {
        //            objJsonResult.code = "0";
        //            objJsonResult.count = 0;
        //            objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
        //            objJsonResult.data = null;
        //            return objJsonResult;
        //        }
        //        else
        //        {
        //            objJsonResult.code = "0";
        //            objJsonResult.count = 1;
        //            objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
        //            objJsonResult.data = WebSoBar;
        //            return objJsonResult;
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        objJsonResult.code = "0";
        //        objJsonResult.count = 1;
        //        objJsonResult.Message = e.Message + ";" + e.StackTrace;
        //        objJsonResult.data = null;
        //        return objJsonResult;
        //    }
        //}
        public object get_CheckTypeByBarCode_Json(string sCode, long sInterID, string sBillNo, string sBillType, string sMaker, long WhID, long SPID, double sQty, bool sRedBlue, bool SourceFlag, string sSourceBillNo, string sSourceType, long HOWNERID)
        {
            object result;
            try
            {
                //if (sRedBlue == true)
                //{
                //    HBillType = "1239";
                //}
                //oBar = webserver.get_CheckTypeByBarCode(sCode, sInterID, sBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID, ref DBUtility.ClsPub.sErrInfo);
                WebS.WebService1 oWebs = new WebS.WebService1();
                WebS.ClsKf_ICStockBill_WMS WebSoBar = new WebS.ClsKf_ICStockBill_WMS();
                string sExpressNumber = "";
                WebSoBar = oWebs.get_CheckTypeByBarCode_All(sCode, sInterID, HBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID, sExpressNumber, ref DBUtility.ClsPub.sErrInfo);
                if (WebSoBar == null)
                string hexpressNumber = "";
                WebSoBar = oWebs.get_CheckTypeByBarCode_All(sCode, sInterID, this.HBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID, hexpressNumber, ref ClsPub.sErrInfo);
                bool flag = WebSoBar == null;
                if (flag)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                    this.objJsonResult.code = "0";
                    this.objJsonResult.count = 0;
                    this.objJsonResult.Message = ClsPub.sErrInfo;
                    this.objJsonResult.data = null;
                    result = this.objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
                    objJsonResult.data = WebSoBar;
                    return objJsonResult;
                    this.objJsonResult.code = "0";
                    this.objJsonResult.count = 1;
                    this.objJsonResult.Message = ClsPub.sErrInfo;
                    this.objJsonResult.data = WebSoBar;
                    result = this.objJsonResult;
                }
            }
            catch (Exception e)
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = e.Message + ";" + e.StackTrace;
                objJsonResult.data = null;
                return objJsonResult;
                this.objJsonResult.code = "0";
                this.objJsonResult.count = 1;
                this.objJsonResult.Message = ex.Message + ";" + ex.StackTrace;
                this.objJsonResult.data = null;
                result = this.objJsonResult;
            }
            return result;
        }
@@ -167,6 +222,2909 @@
            }
        }
        //[Route("kf_PoStockInBill/JX_Json")]
        //[HttpGet]
        //public static string JX_Json(string sBarCodeNew, Int64 hinterid, string HBillType,Int64 HOrgID,string HBillNo,string HMaker)
        //{
        //    try
        //    {
        //        //1.判断系统参数是否安瑞  不是安瑞 直接跳掉
        //        //如果是安瑞  走下面
        //        //解析条码
        //        //如果在条码档案里面   不处理  没有的话 存入条码档案
        //        //根据解析的物料 +  批次  判断 条码临时表  记录是否存在  没有的话  进行扫源单的动作
        //        //加了  生产日期  有效期至   保质期标志
        //        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
        //        //if (oSystemParameter.omodel.WMS_CampanyName == "安瑞")
        //        //{
        //        string HTM = "";
        //        //采购入库
        //        if (HBillType == "1201")
        //        {
        //            string[] sArray = sBarCodeNew.Split('@');
        //            string HMaterNumber = "";
        //            HMaterNumber = sArray[0];
        //            Int64 HQty = 0;
        //            HQty = ClsPub.isInt(sArray[4]);
        //            string HBarchNo = "";
        //            HBarchNo = sArray[6];
        //            DateTime HSCRQ = ClsPub.isDate(sArray[3]);
        //            DateTime HYXQZ = ClsPub.isDate(sArray[5]);
        //            //采购订单号
        //            string HPOOrderBillNo = "";
        //            HPOOrderBillNo = ClsPub.isStrNull(sArray[8]);
        //            Int64 HMaterID = 0;
        //            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        //            DataSet Dss;
        //            Dss = oCn.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
        //            string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
        //            DataSet Dss1;
        //            Dss1 = oCn.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
        //            HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
        //            string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
        //            string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
        //            Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
        //            HTM = HOrgNumber + HMaterID + HBarchNo;
        //            //如果条码档案不存在  进行存入条码档案的动作
        //            //根据物料 + 批次  +   采购订单号 找到对应的收料通知单号
        //            DataSet Dss2;
        //            Dss2 = oCn.RunProcReturn(" select fid,FMATERIALID,FENTRYID,FBILLNO from h_v_RECEIVEQuery where FSRCBILLNO= '" + HPOOrderBillNo + "' and  FMATERIALID = " + HMaterID, "h_v_RECEIVEQuery");
        //            HMaterID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["FMATERIALID"]);
        //            Int64 HSourceInterID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["fid"]);
        //            Int64 HSourceEntryID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["FENTRYID"]);
        //            string HSourceBillNo = Pub_Class.ClsPub.isStrNull(Dss2.Tables[0].Rows[0]["FBILLNO"]);
        //            //判断条码档案是否存在该条码
        //            //如果存在 再判断扫码临时表是否存在该条码
        //            //如果不存在  进行扫源单的方法
        //            DataSet Dss5;
        //            Dss5 = oCn.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
        //            if (Dss5.Tables[0].Rows.Count > 0)
        //            {
        //                DataSet Dss6;
        //                Dss6 = oCn.RunProcReturn(" select * from KF_PonderationBillMain_Temp where HBarCode= '" + HTM + "' and HInterID = " + hinterid.ToString() + " and HBillType = '" + HBillType + "' and hsourcebillno = '" + HSourceBillNo + "' ", "KF_PonderationBillMain_Temp");
        //                if (Dss6.Tables[0].Rows.Count > 0)
        //                {
        //                }
        //                else
        //                {
        //                    POStockInBillController POStockInBill = new POStockInBillController();
        //                    POStockInBill.set_SavePonderationBillMain_Temp_Source_Fast_Json("1103", HSourceBillNo, hinterid, HBillNo);
        //                }
        //            }
        //            else
        //            {
        //                string ModName = "85";
        //                var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
        //                Int64 HSupID = 0;
        //                oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
        //                                   ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
        //                                   ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
        //                                   ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
        //                                   ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
        //                                   ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
        //                                   ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
        //                                   ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
        //                                   ") values ("
        //                                   + "'" + HTM + "','批次条码'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
        //                                   + ",'" + HBarchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
        //                                   + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo.ToString() + "','1103',0"
        //                                   + ", 0,'',0,0,0,''"
        //                                   + ",0,'','','" + HSCRQ.ToShortDateString() + "','" + HYXQZ.ToShortDateString() + "','',getdate()"
        //                                   + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
        //                                   + ",0,0,0"
        //                                   + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
        //                DataSet Dss7;
        //                Dss7 = oCn.RunProcReturn(" select * from KF_PonderationBillMain_Temp where HBarCode= '" + HTM + "' and HInterID = " + hinterid.ToString() + " and HBillType = '" + HBillType + "' and hsourcebillno = '" + HSourceBillNo + "' ", "KF_PonderationBillMain_Temp");
        //                if (Dss7.Tables[0].Rows.Count > 0)
        //                {
        //                }
        //                else
        //                {
        //                    POStockInBillController POStockInBill = new POStockInBillController();
        //                    POStockInBill.set_SavePonderationBillMain_Temp_Source_Fast_Json("1103", HSourceBillNo, hinterid, HBillNo);
        //                }
        //            }
        //        }
        //        //产品入库
        //        if(HBillType == "1202")
        //        {
        //            string HMaterNumber = "";
        //            HMaterNumber = sBarCodeNew.Substring(0, 10);
        //            string HSCRQ = "";
        //            HSCRQ = "20" + sBarCodeNew.Substring(10, 6);
        //            Int64 Year =  ClsPub.isInt(HSCRQ.Substring(0, 4));
        //            Int64 Month = ClsPub.isInt(HSCRQ.Substring(4, 2));
        //            Int64 Day = ClsPub.isInt(HSCRQ.Substring(6, 2));
        //            string HBatchNo = "";
        //            HBatchNo = sBarCodeNew.Substring(16, 11);
        //            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        //            DataSet ds;
        //            Int64 HMaterID = 0;
        //            DataSet Dss1;
        //            Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
        //            HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
        //            string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
        //            string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
        //            Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
        //            ds = oCN.RunProcReturn("select * from h_v_SCStockInCheckBill_Json where  HYear =" + Year + " and HMonth = " + Month + " and HDay = " + Day + " and HMaterID = " + HMaterID.ToString() + "and 批次 = '" + HBatchNo.ToString() + "'", "h_v_SCStockInCheckBill_Json");
        //            Int64 HSourceInterID = Pub_Class.ClsPub.isLong(ds.Tables[0].Rows[0]["HSourceInterID"]);
        //            Int64 HSourceEntryID = Pub_Class.ClsPub.isLong(ds.Tables[0].Rows[0]["HSourceEntryID"]);
        //            string HSourceBillNo = Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBillNo"]);
        //            DataSet Dss;
        //            Dss = oCN.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
        //            string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
        //            HTM = HOrgNumber + HMaterID + HBatchNo;
        //            DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
        //            string  HYXQZ = "20" + sBarCodeNew.Substring(27, 6);
        //            Int64 Year1 = ClsPub.isInt(HYXQZ.Substring(0, 4));
        //            Int64 Month1 = ClsPub.isInt(HYXQZ.Substring(4, 2));
        //            Int64 Day1 = ClsPub.isInt(HYXQZ.Substring(6, 2));
        //            DateTime HYXQZ1 = ClsPub.isDate(Year1 + "-" + Month1 + "-" + Day1);
        //            Int64 HQty = 0;
        //            HQty = ClsPub.isInt(sBarCodeNew.Substring(33,3));
        //            DataSet Dss5;
        //            Dss5 = oCN.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
        //            if (Dss5.Tables[0].Rows.Count > 0)
        //            {
        //                DataSet Dss6;
        //                Dss6 = oCN.RunProcReturn(" select * from KF_PonderationBillMain_Temp where HBarCode= '" + HTM + "' and HInterID = " + hinterid.ToString() + " and HBillType = '" + HBillType + "' and hsourcebillno = '" + HSourceBillNo + "' ", "KF_PonderationBillMain_Temp");
        //                if (Dss6.Tables[0].Rows.Count > 0)
        //                {
        //                }
        //                else
        //                {
        //                    WEBSController WEBS = new WEBSController();
        //                    WEBS.get_SourceBarCode_ProductIn_Json(hinterid, HBillNo, HBillType, HSourceBillNo, "3714", HMaker,HOrgID);
        //                }
        //            }
        //            else
        //            {
        //                string ModName = "85";
        //                var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
        //                Int64 HSupID = 0;
        //                oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
        //                                   ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
        //                                   ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
        //                                   ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
        //                                   ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
        //                                   ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
        //                                   ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
        //                                   ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
        //                                   ") values ("
        //                                   + "'" + HTM + "','批次条码'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
        //                                   + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
        //                                   + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo.ToString() + "','3714',0"
        //                                   + ", 0,'',0,0,0,''"
        //                                   + ",0,'','','" + HSCRQ1.ToShortDateString() + "','" + HYXQZ1.ToShortDateString() + "','',getdate()"
        //                                   + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
        //                                   + ",0,0,0"
        //                                   + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
        //                DataSet Dss7;
        //                Dss7 = oCN.RunProcReturn(" select * from KF_PonderationBillMain_Temp where HBarCode= '" + HTM + "' and HInterID = " + hinterid.ToString() + " and HBillType = '" + HBillType + "' and hsourcebillno = '" + HSourceBillNo + "' ", "KF_PonderationBillMain_Temp");
        //                if (Dss7.Tables[0].Rows.Count > 0)
        //                {
        //                }
        //                else
        //                {
        //                    WEBSController WEBS = new WEBSController();
        //                    WEBS.get_SourceBarCode_ProductIn_Json(hinterid, HBillNo, HBillType, HSourceBillNo, "3714", HMaker, HOrgID);
        //                }
        //            }
        //        }
        //        //生产退料
        //        if (HBillType == "1244")
        //        {
        //            string HMaterNumber = "";
        //            HMaterNumber = sBarCodeNew.Substring(0, 10);
        //            string HSCRQ = "";
        //            HSCRQ = "20" + sBarCodeNew.Substring(10, 6);
        //            Int64 Year = ClsPub.isInt(HSCRQ.Substring(0, 4));
        //            Int64 Month = ClsPub.isInt(HSCRQ.Substring(4, 2));
        //            Int64 Day = ClsPub.isInt(HSCRQ.Substring(6, 2));
        //            string HBatchNo = "";
        //            HBatchNo = sBarCodeNew.Substring(16, 11);
        //            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        //            Int64 HMaterID = 0;
        //            DataSet Dss1;
        //            Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
        //            HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
        //            string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
        //            string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
        //            Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
        //            DataSet Dss;
        //            Dss = oCN.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
        //            string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
        //            HTM = HOrgNumber + HMaterID + HBatchNo;
        //            DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
        //            string HYXQZ = "20" + sBarCodeNew.Substring(27, 6);
        //            Int64 Year1 = ClsPub.isInt(HYXQZ.Substring(0, 4));
        //            Int64 Month1 = ClsPub.isInt(HYXQZ.Substring(4, 2));
        //            Int64 Day1 = ClsPub.isInt(HYXQZ.Substring(6, 2));
        //            DateTime HYXQZ1 = ClsPub.isDate(Year1 + "-" + Month1 + "-" + Day1);
        //            Int64 HQty = 0;
        //            HQty = ClsPub.isInt(sBarCodeNew.Substring(33, 3));
        //            DataSet Dss5;
        //            Dss5 = oCN.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
        //            if (Dss5.Tables[0].Rows.Count > 0)
        //            {
        //            }
        //            else
        //            {
        //                string ModName = "85";
        //                var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
        //                Int64 HSupID = 0;
        //                oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
        //                                   ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
        //                                   ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
        //                                   ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
        //                                   ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
        //                                   ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
        //                                   ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
        //                                   ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
        //                                   ") values ("
        //                                   + "'" + HTM + "','批次条码'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
        //                                   + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
        //                                   + ", 0,0,'','',0"
        //                                   + ", 0,'',0,0,0,''"
        //                                   + ",0,'','','" + HSCRQ1.ToShortDateString() + "','" + HYXQZ1.ToShortDateString() + "','',getdate()"
        //                                   + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
        //                                   + ",0,0,0"
        //                                   + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
        //            }
        //        }
        //        //调拨单
        //        if (HBillType == "1207")
        //        {
        //            string HMaterNumber = "";
        //            HMaterNumber = sBarCodeNew.Substring(0, 10);
        //            string HSCRQ = "";
        //            HSCRQ = "20" + sBarCodeNew.Substring(10, 6);
        //            Int64 Year = ClsPub.isInt(HSCRQ.Substring(0, 4));
        //            Int64 Month = ClsPub.isInt(HSCRQ.Substring(4, 2));
        //            Int64 Day = ClsPub.isInt(HSCRQ.Substring(6, 2));
        //            string HBatchNo = "";
        //            HBatchNo = sBarCodeNew.Substring(16, 11);
        //            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        //            Int64 HMaterID = 0;
        //            DataSet Dss1;
        //            Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
        //            HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
        //            string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
        //            string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
        //            Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
        //            DataSet Dss;
        //            Dss = oCN.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
        //            string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
        //            HTM = HOrgNumber + HMaterID + HBatchNo;
        //            DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
        //            string HYXQZ = "20" + sBarCodeNew.Substring(27, 6);
        //            Int64 Year1 = ClsPub.isInt(HYXQZ.Substring(0, 4));
        //            Int64 Month1 = ClsPub.isInt(HYXQZ.Substring(4, 2));
        //            Int64 Day1 = ClsPub.isInt(HYXQZ.Substring(6, 2));
        //            DateTime HYXQZ1 = ClsPub.isDate(Year1 + "-" + Month1 + "-" + Day1);
        //            Int64 HQty = 0;
        //            HQty = ClsPub.isInt(sBarCodeNew.Substring(33, 3));
        //            DataSet Dss5;
        //            Dss5 = oCN.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
        //            if (Dss5.Tables[0].Rows.Count > 0)
        //            {
        //            }
        //            else
        //            {
        //                string ModName = "85";
        //                var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
        //                Int64 HSupID = 0;
        //                oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
        //                                   ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
        //                                   ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
        //                                   ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
        //                                   ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
        //                                   ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
        //                                   ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
        //                                   ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
        //                                   ") values ("
        //                                   + "'" + HTM + "','批次条码'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
        //                                   + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
        //                                   + ", 0,0,'','',0"
        //                                   + ", 0,'',0,0,0,''"
        //                                   + ",0,'','','" + HSCRQ1.ToShortDateString() + "','" + HYXQZ1.ToShortDateString() + "','',getdate()"
        //                                   + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
        //                                   + ",0,0,0"
        //                                   + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
        //            }
        //        }
        //        //其他出库单
        //        if (HBillType == "1206")
        //        {
        //            string HMaterNumber = "";
        //            HMaterNumber = sBarCodeNew.Substring(0, 10);
        //            string HSCRQ = "";
        //            HSCRQ = "20" + sBarCodeNew.Substring(10, 6);
        //            Int64 Year = ClsPub.isInt(HSCRQ.Substring(0, 4));
        //            Int64 Month = ClsPub.isInt(HSCRQ.Substring(4, 2));
        //            Int64 Day = ClsPub.isInt(HSCRQ.Substring(6, 2));
        //            string HBatchNo = "";
        //            HBatchNo = sBarCodeNew.Substring(16, 11);
        //            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        //            Int64 HMaterID = 0;
        //            DataSet Dss1;
        //            Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
        //            HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
        //            string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
        //            string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
        //            Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
        //            DataSet Dss;
        //            Dss = oCN.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
        //            string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
        //            HTM = HOrgNumber + HMaterID + HBatchNo;
        //            DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
        //            string HYXQZ = "20" + sBarCodeNew.Substring(27, 6);
        //            Int64 Year1 = ClsPub.isInt(HYXQZ.Substring(0, 4));
        //            Int64 Month1 = ClsPub.isInt(HYXQZ.Substring(4, 2));
        //            Int64 Day1 = ClsPub.isInt(HYXQZ.Substring(6, 2));
        //            DateTime HYXQZ1 = ClsPub.isDate(Year1 + "-" + Month1 + "-" + Day1);
        //            Int64 HQty = 0;
        //            HQty = ClsPub.isInt(sBarCodeNew.Substring(33, 3));
        //            DataSet Dss5;
        //            Dss5 = oCN.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
        //            if (Dss5.Tables[0].Rows.Count > 0)
        //            {
        //            }
        //            else
        //            {
        //                string ModName = "85";
        //                var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
        //                Int64 HSupID = 0;
        //                oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
        //                                   ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
        //                                   ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
        //                                   ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
        //                                   ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
        //                                   ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
        //                                   ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
        //                                   ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
        //                                   ") values ("
        //                                   + "'" + HTM + "','批次条码'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
        //                                   + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
        //                                   + ", 0,0,'','',0"
        //                                   + ", 0,'',0,0,0,''"
        //                                   + ",0,'','','" + HSCRQ1.ToShortDateString() + "','" + HYXQZ1.ToShortDateString() + "','',getdate()"
        //                                   + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
        //                                   + ",0,0,0"
        //                                   + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
        //            }
        //        }
        //        //领料出库校验
        //        if (HBillType == "1204")
        //        {
        //            string[] sArray = sBarCodeNew.Split('@');
        //            string HMaterNumber = "";
        //            HMaterNumber = sArray[0];
        //            Int64 HQty = 0;
        //            HQty = ClsPub.isInt(sArray[4]);
        //            string HBarchNo = "";
        //            HBarchNo = sArray[6];
        //            DateTime HSCRQ = ClsPub.isDate(sArray[3]);
        //            DateTime HYXQZ = ClsPub.isDate(sArray[5]);
        //            //采购订单号
        //            string HPOOrderBillNo = "";
        //            HPOOrderBillNo = ClsPub.isStrNull(sArray[8]);
        //            Int64 HMaterID = 0;
        //            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        //            DataSet Dss;
        //            Dss = oCn.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
        //            string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
        //            DataSet Dss1;
        //            Dss1 = oCn.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
        //            HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
        //            string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
        //            string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
        //            Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
        //            HTM = HOrgNumber + HMaterID + HBarchNo;
        //            DataSet Dss5;
        //            Dss5 = oCn.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
        //            if (Dss5.Tables[0].Rows.Count > 0)
        //            {
        //            }
        //            else
        //            {
        //                string ModName = "85";
        //                var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
        //                Int64 HSupID = 0;
        //                oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
        //                                   ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
        //                                   ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
        //                                   ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
        //                                   ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
        //                                   ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
        //                                   ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
        //                                   ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
        //                                   ") values ("
        //                                   + "'" + HTM + "','批次条码'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
        //                                   + ",'" + HBarchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
        //                                   + ", " + 0 + "," + 0 + ",'','',0"
        //                                   + ", 0,'',0,0,0,''"
        //                                   + ",0,'','','" + HSCRQ.ToShortDateString() + "','" + HYXQZ.ToShortDateString() + "','',getdate()"
        //                                   + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
        //                                   + ",0,0,0"
        //                                   + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
        //            }
        //        }
        //        //生产补料校验
        //        if (HBillType == "1254")
        //        {
        //            string[] sArray = sBarCodeNew.Split('@');
        //            string HMaterNumber = "";
        //            HMaterNumber = sArray[0];
        //            Int64 HQty = 0;
        //            HQty = ClsPub.isInt(sArray[4]);
        //            string HBarchNo = "";
        //            HBarchNo = sArray[6];
        //            DateTime HSCRQ = ClsPub.isDate(sArray[3]);
        //            DateTime HYXQZ = ClsPub.isDate(sArray[5]);
        //            //采购订单号
        //            string HPOOrderBillNo = "";
        //            HPOOrderBillNo = ClsPub.isStrNull(sArray[8]);
        //            Int64 HMaterID = 0;
        //            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        //            DataSet Dss;
        //            Dss = oCn.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
        //            string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
        //            DataSet Dss1;
        //            Dss1 = oCn.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
        //            HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
        //            string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
        //            string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
        //            Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
        //            HTM = HOrgNumber + HMaterID + HBarchNo;
        //            DataSet Dss5;
        //            Dss5 = oCn.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
        //            if (Dss5.Tables[0].Rows.Count > 0)
        //            {
        //            }
        //            else
        //            {
        //                string ModName = "85";
        //                var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
        //                Int64 HSupID = 0;
        //                oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
        //                                   ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
        //                                   ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
        //                                   ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
        //                                   ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
        //                                   ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
        //                                   ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
        //                                   ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
        //                                   ") values ("
        //                                   + "'" + HTM + "','批次条码'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
        //                                   + ",'" + HBarchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
        //                                   + ", " + 0 + "," + 0 + ",'','',0"
        //                                   + ", 0,'',0,0,0,''"
        //                                   + ",0,'','','" + HSCRQ.ToShortDateString() + "','" + HYXQZ.ToShortDateString() + "','',getdate()"
        //                                   + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
        //                                   + ",0,0,0"
        //                                   + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
        //            }
        //        }
        //        //销售出库校验
        //        if (HBillType == "1205")
        //        {
        //            string HMaterNumber = "";
        //            HMaterNumber = sBarCodeNew.Substring(0, 10);
        //            string HSCRQ = "";
        //            HSCRQ = "20" + sBarCodeNew.Substring(10, 6);
        //            Int64 Year = ClsPub.isInt(HSCRQ.Substring(0, 4));
        //            Int64 Month = ClsPub.isInt(HSCRQ.Substring(4, 2));
        //            Int64 Day = ClsPub.isInt(HSCRQ.Substring(6, 2));
        //            string HBatchNo = "";
        //            HBatchNo = sBarCodeNew.Substring(16, 11);
        //            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        //            Int64 HMaterID = 0;
        //            DataSet Dss1;
        //            Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
        //            HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
        //            string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
        //            string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
        //            Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
        //            DataSet Dss;
        //            Dss = oCN.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
        //            string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
        //            HTM = HOrgNumber + HMaterID + HBatchNo;
        //            DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
        //            string HYXQZ = "20" + sBarCodeNew.Substring(27, 6);
        //            Int64 Year1 = ClsPub.isInt(HYXQZ.Substring(0, 4));
        //            Int64 Month1 = ClsPub.isInt(HYXQZ.Substring(4, 2));
        //            Int64 Day1 = ClsPub.isInt(HYXQZ.Substring(6, 2));
        //            DateTime HYXQZ1 = ClsPub.isDate(Year1 + "-" + Month1 + "-" + Day1);
        //            Int64 HQty = 0;
        //            HQty = ClsPub.isInt(sBarCodeNew.Substring(33, 3));
        //            DataSet Dss5;
        //            Dss5 = oCN.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
        //            if (Dss5.Tables[0].Rows.Count > 0)
        //            {
        //            }
        //            else
        //            {
        //                string ModName = "85";
        //                var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
        //                Int64 HSupID = 0;
        //                oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
        //                                   ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
        //                                   ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
        //                                   ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
        //                                   ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
        //                                   ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
        //                                   ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
        //                                   ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
        //                                   ") values ("
        //                                   + "'" + HTM + "','批次条码'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
        //                                   + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
        //                                   + ", 0,0,'','',0"
        //                                   + ", 0,'',0,0,0,''"
        //                                   + ",0,'','','" + HSCRQ1.ToShortDateString() + "','" + HYXQZ1.ToShortDateString() + "','',getdate()"
        //                                   + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
        //                                   + ",0,0,0"
        //                                   + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
        //            }
        //        }
        //        //objJsonResult.code = "0";
        //        //objJsonResult.count = 1;
        //        //objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
        //        //objJsonResult.data = ;
        //        return HTM;
        //    }
        //    catch (Exception e)
        //    {
        //        //objJsonResult.code = "0";
        //        //objJsonResult.count = 1;
        //        //objJsonResult.Message = e.Message + ";" + e.StackTrace;
        //        //objJsonResult.data = null;
        //        return e.Message + ";" + e.StackTrace;
        //    }
        //}
        [Route("kf_PoStockInBill/JX_Json")]
        [HttpGet]
        public static string JX_Json(string sBarCodeNew, long hinterid, string HBillType, long HOrgID, string HBillNo, string HMaker)
        {
            string result;
            try
            {
                Pub_Class.ClsXt_SystemParameter clsXt_SystemParameter = new Pub_Class.ClsXt_SystemParameter();
                WebS.ClsXt_SystemParameterMain oSystemParameterMain = new WebS.ClsXt_SystemParameterMain();
                string text = "";
                string text1 = "";
                //gy_billnumber 单据类型表
                bool flag = HBillType == "1201"; //WMS 采购入库
                if (flag)
                {
                    string[] array = sBarCodeNew.Split(new char[]
                    {
                '@'
                    });
                    string str = array[0]; //物料代码
                    long num = (long)ClsPub.isInt(array[4]);
                    string text2 = array[6];
                    DateTime dateTime = ClsPub.isDate(array[3]);
                    DateTime dateTime2 = ClsPub.isDate(array[5]);
                    string str2 = ClsPub.isStrNull(array[8]);
                    ClsCN clsCN = new ClsCN();
                    DataSet dataSet = clsCN.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                    string str3 = ClsPub.isStrNull(dataSet.Tables[0].Rows[0]["HNumber"]);
                    //用拆分出来的物料代码查询物料表里的新物料编码
                    DataSet Dss7;
                    Dss7 = clsCN.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str + "'", "T_BD_MATERIAL");
                    if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                    {
                        //新物料表里没有返回数据则查询物料表里的旧物料编码
                        DataSet Dss8;
                        Dss8 = clsCN.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str + "'", "T_BD_MATERIAL");
                        str = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                    }
                    else
                    {
                        str = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                    }
                    DataSet dataSet2 = clsCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                    long num2 = ClsPub.isLong(dataSet2.Tables[0].Rows[0]["HItemID"]);
                    string text3 = ClsPub.isStrNull(dataSet2.Tables[0].Rows[0]["HName"]);
                    string text4 = ClsPub.isStrNull(dataSet2.Tables[0].Rows[0]["HModel"]);
                    long num3 = (long)ClsPub.isInt(dataSet2.Tables[0].Rows[0]["HUnitID"]);
                    text = str3 + num2.ToString() + text2  + "#" + num;
                    text1 = str3 + num2.ToString() + text2;
                    //找源单
                    DataSet dataSet3 = clsCN.RunProcReturn(" select fid,FMATERIALID,FENTRYID,FBILLNO from h_v_RECEIVEQuery where FSRCBILLNO= '" + str2 + "' and  FLOT_TEXT = '" + text2 + "' and  FMATERIALID = " + num2.ToString(), "h_v_RECEIVEQuery");
                    //DataSet dataSet3 = clsCN.RunProcReturn(" select fid,FMATERIALID,FENTRYID,FBILLNO from h_v_RECEIVEQuery where FLOT_TEXT= '" + text2 + "' and FPRODUCEDATE = '" + dateTime + "' and  FMATERIALID = " + num2.ToString(), "h_v_RECEIVEQuery");
                    num2 = ClsPub.isLong(dataSet3.Tables[0].Rows[0]["FMATERIALID"]);
                    long num4 = ClsPub.isLong(dataSet3.Tables[0].Rows[0]["fid"]);
                    long num5 = ClsPub.isLong(dataSet3.Tables[0].Rows[0]["FENTRYID"]);
                    string text5 = ClsPub.isStrNull(dataSet3.Tables[0].Rows[0]["FBILLNO"]);
                    DataSet dataSet4 = clsCN.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                    bool flag2 = dataSet4.Tables[0].Rows.Count > 0;
                    if (flag2)
                    {
                        DataSet dataSet5 = clsCN.RunProcReturn(string.Concat(new string[]
                        {
                    //扫码临时记录表
                    " select * from KF_PonderationBillMain_Temp where  HInterID = ",
                    hinterid.ToString(),
                    " and HBillType = '",
                    HBillType,
                    "' and hsourcebillno = '",
                    text5,
                    "' "
                        }), "KF_PonderationBillMain_Temp");
                        bool flag3 = dataSet5.Tables[0].Rows.Count > 0;
                        if (!flag3)
                        {
                            //POStockInBillController postockInBillController = new POStockInBillController();
                            ////扫源单方法
                            //postockInBillController.set_SavePonderationBillMain_Temp_Source_Fast_Json("1103", text5, hinterid, HBillNo);
                            WEBSController webscontroller4 = new WEBSController();
                            object obj4 = webscontroller4.get_SourceBarCode_POStockIn_Json(hinterid, HBillNo, HBillType, text5, "1103", HMaker, HOrgID);
                        }
                    }
                    else
                    {
                        string billCode = "85";
                        long num6 = ClsPub.CreateBillID_Prod(billCode, ref ClsPub.sExeReturnInfo);
                        long num7 = 0L;
                        clsCN.RunProc(string.Concat(new string[]
                        {
                    "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                    text1,
                    "','批次条码',",
                    num2.ToString(),
                    ",",
                    num3.ToString(),
                    ",",
                    num.ToString(),
                    ",'",
                    text2,
                    "',",
                    num7.ToString(),
                    ",0,'",
                    ClsPub.CurUserName,
                    "',getdate(),0,",
                    num.ToString(),
                    ", ",
                    num4.ToString(),
                    ",",
                    num5.ToString(),
                    ",'",
                    text5.ToString(),
                    "','1103',0, 0,'',0,0,0,'',0,'','','",
                    dateTime.ToShortDateString(),
                    "','",
                    dateTime2.ToShortDateString(),
                    "','',getdate(), ",
                    HOrgID.ToString(),
                    ",",
                    HOrgID.ToString(),
                    ",'',",
                    num6.ToString(),
                    ",1,0,0,0,'",
                    text3,
                    "','",
                    text4,
                    "','',0,'','',1)"
                        }));
                        DataSet dataSet6 = clsCN.RunProcReturn(string.Concat(new string[]
                        {
                    " select * from KF_PonderationBillMain_Temp where HBarCode= '",
                    text1,
                    "' and HInterID = ",
                    hinterid.ToString(),
                    " and HBillType = '",
                    HBillType,
                    "' and hsourcebillno = '",
                    text5,
                    "' "
                        }), "KF_PonderationBillMain_Temp");
                        bool flag4 = dataSet6.Tables[0].Rows.Count > 0;
                        if (!flag4)
                        {
                            //POStockInBillController postockInBillController2 = new POStockInBillController();
                            //postockInBillController2.set_SavePonderationBillMain_Temp_Source_Fast_Json("1103", text5, hinterid, HBillNo);
                            WEBSController webscontroller4 = new WEBSController();
                            object obj4 = webscontroller4.get_SourceBarCode_POStockIn_Json(hinterid, HBillNo, HBillType, text5, "1103", HMaker, HOrgID);
                        }
                    }
                }
                bool flag5 = HBillType == "1202"; //WMS 生产入库
                if (flag5)
                {
                    string text6 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 4);
                    string text7 = text6.Substring(0, 1);
                    bool flag6 = text7.Contains("W") || text7.Contains("N");
                    if (flag6)
                    {
                        string text8 = sBarCodeNew.Substring(0, 10);//商品码    商品码+物料代码+生产日期+批次+失效日期+一位字母+三位数字
                        string str4 = sBarCodeNew.Substring(10, 10);//物料代码
                        string text9 = "20" + sBarCodeNew.Substring(20, 6);
                        long num8 = (long)ClsPub.isInt(text9.Substring(0, 4));  //年
                        long num9 = (long)ClsPub.isInt(text9.Substring(4, 2));  //月
                        long num10 = (long)ClsPub.isInt(text9.Substring(6, 2)); //日
                        long num11 = (long)ClsPub.isInt(sBarCodeNew.Remove(0, sBarCodeNew.Length - 3));//后三位永远都是数字
                        string text10 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 10);//失效日期+一位字母+三位数字
                        string text11 = "20" + text10.Substring(0, 6);
                        long num12 = (long)ClsPub.isInt(text11.Substring(0, 4));
                        long num13 = (long)ClsPub.isInt(text11.Substring(4, 2));
                        long num14 = (long)ClsPub.isInt(text11.Substring(6, 2));
                        DateTime dateTime3 = ClsPub.isDate(string.Concat(new string[]
                        {
                    num12.ToString(),
                    "-",
                    num13.ToString(),
                    "-",
                    num14.ToString()
                        }));
                        string text12 = sBarCodeNew.Remove(0, 26);
                        string text13 = text12.Remove(text12.Length - 10, 10);
                        ClsCN clsCN2 = new ClsCN();
                        DataSet Dss7;
                        Dss7 = clsCN2.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str4 + "'", "T_BD_MATERIAL");
                        if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                        {
                            DataSet Dss8;
                            Dss8 = clsCN2.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str4 + "'", "T_BD_MATERIAL");
                            str4 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                        }
                        else
                        {
                            str4 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                        }
                        DataSet dataSet7 = clsCN2.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str4 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                        long num15 = ClsPub.isLong(dataSet7.Tables[0].Rows[0]["HItemID"]);
                        string text14 = ClsPub.isStrNull(dataSet7.Tables[0].Rows[0]["HName"]);
                        string text15 = ClsPub.isStrNull(dataSet7.Tables[0].Rows[0]["HModel"]);
                        long num16 = (long)ClsPub.isInt(dataSet7.Tables[0].Rows[0]["HUnitID"]);
                        DataSet dataSet8 = clsCN2.RunProcReturn(string.Concat(new string[]
                        {
                    "select * from h_v_SCStockInCheckBill_Json where  HYear =",
                    num8.ToString(),
                    " and HMonth = ",
                    num9.ToString(),
                    " and HDay = ",
                    num10.ToString(),
                    " and HMaterID = ",
                    num15.ToString(),
                    "and 批次 = '",
                    text13.ToString(),
                    "'"
                        }), "h_v_SCStockInCheckBill_Json");
                        long num17 = ClsPub.isLong(dataSet8.Tables[0].Rows[0]["HSourceInterID"]);
                        long num18 = ClsPub.isLong(dataSet8.Tables[0].Rows[0]["HSourceEntryID"]);
                        string text16 = ClsPub.isStrNull(dataSet8.Tables[0].Rows[0]["HBillNo"]);
                        DataSet dataSet9 = clsCN2.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                        string str5 = ClsPub.isStrNull(dataSet9.Tables[0].Rows[0]["HNumber"]);
                        text = str5 + num15.ToString() + text13 + text9 + "#" + num11;
                        text1 = str5 + num15.ToString() + text13 + text9;
                        DateTime dateTime4 = ClsPub.isDate(string.Concat(new string[]
                        {
                    num8.ToString(),
                    "-",
                    num9.ToString(),
                    "-",
                    num10.ToString()
                        }));
                        DataSet dataSet10 = clsCN2.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                        bool flag7 = dataSet10.Tables[0].Rows.Count > 0;
                        if (flag7)
                        {
                            DataSet dataSet11 = clsCN2.RunProcReturn(string.Concat(new string[]
                            {
                        " select * from KF_PonderationBillMain_Temp where HBarCode= '",
                        text1,
                        "' and HInterID = ",
                        hinterid.ToString(),
                        " and HBillType = '",
                        HBillType,
                        "' and hsourcebillno = '",
                        text16,
                        "' "
                            }), "KF_PonderationBillMain_Temp");
                            bool flag8 = dataSet11.Tables[0].Rows.Count > 0;
                            if (!flag8)
                            {
                                WEBSController webscontroller = new WEBSController();
                                object obj = webscontroller.get_SourceBarCode_ProductIn_Json(hinterid, HBillNo, HBillType, text16, "3714", HMaker, HOrgID);
                            }
                        }
                        else
                        {
                            string billCode2 = "85";
                            long num19 = ClsPub.CreateBillID_Prod(billCode2, ref ClsPub.sExeReturnInfo);
                            long num20 = 0L;
                            clsCN2.RunProc(string.Concat(new string[]
                            {
                        "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                        text1,
                        "','批次条码',",
                        num15.ToString(),
                        ",",
                        num16.ToString(),
                        ",",
                        num11.ToString(),
                        ",'",
                        text13,
                        "',",
                        num20.ToString(),
                        ",0,'",
                        ClsPub.CurUserName,
                        "',getdate(),0,",
                        num11.ToString(),
                        ", ",
                        num17.ToString(),
                        ",",
                        num18.ToString(),
                        ",'",
                        text16.ToString(),
                        "','3714',0, 0,'',0,0,0,'',0,'','','",
                        dateTime4.ToShortDateString(),
                        "','",
                        dateTime3.ToShortDateString(),
                        "','',getdate(), ",
                        HOrgID.ToString(),
                        ",",
                        HOrgID.ToString(),
                        ",'',",
                        num19.ToString(),
                        ",1,0,0,0,'",
                        text14,
                        "','",
                        text15,
                        "','',0,'','',1)"
                            }));
                            DataSet dataSet12 = clsCN2.RunProcReturn(string.Concat(new string[]
                            {
                        " select * from KF_PonderationBillMain_Temp where HBarCode= '",
                        text1,
                        "' and HInterID = ",
                        hinterid.ToString(),
                        " and HBillType = '",
                        HBillType,
                        "' and hsourcebillno = '",
                        text16,
                        "' "
                            }), "KF_PonderationBillMain_Temp");
                            bool flag9 = dataSet12.Tables[0].Rows.Count > 0;
                            if (!flag9)
                            {
                                WEBSController webscontroller2 = new WEBSController();
                                object obj2 = webscontroller2.get_SourceBarCode_ProductIn_Json(hinterid, HBillNo, HBillType, text16, "3714", HMaker, HOrgID);
                            }
                        }
                    }
                    else
                    {
                        /*前十位物料代码,后六位生效日期,倒数前三位是数字前六位是失效日期 */
                        string str6 = sBarCodeNew.Substring(0, 10);//物料代码
                        string text17 = "20" + sBarCodeNew.Substring(10, 6);
                        long num21 = (long)ClsPub.isInt(text17.Substring(0, 4));
                        long num22 = (long)ClsPub.isInt(text17.Substring(4, 2));
                        long num23 = (long)ClsPub.isInt(text17.Substring(6, 2));
                        long num24 = (long)ClsPub.isInt(sBarCodeNew.Remove(0, sBarCodeNew.Length - 3));
                        string text18 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 9);
                        string text19 = "20" + text18.Substring(0, 6);
                        long num25 = (long)ClsPub.isInt(text19.Substring(0, 4));
                        long num26 = (long)ClsPub.isInt(text19.Substring(4, 2));
                        long num27 = (long)ClsPub.isInt(text19.Substring(6, 2));
                        DateTime dateTime5 = ClsPub.isDate(string.Concat(new string[]
                        {
                    num25.ToString(),
                    "-",
                    num26.ToString(),
                    "-",
                    num27.ToString()
                        }));
                        string text20 = sBarCodeNew.Remove(0, 16); //SAE1300100 230309 2303704 250308 010
                        string text21 = text20.Remove(text20.Length - 9 , 9); //SAE1300100230309 2303704 250308010
                         ClsCN clsCN3 = new ClsCN();
                        DataSet dataSet13 = clsCN3.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str6 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                        long num28 = ClsPub.isLong(dataSet13.Tables[0].Rows[0]["HItemID"]);
                        string text22 = ClsPub.isStrNull(dataSet13.Tables[0].Rows[0]["HName"]);
                        string text23 = ClsPub.isStrNull(dataSet13.Tables[0].Rows[0]["HModel"]);
                        long num29 = (long)ClsPub.isInt(dataSet13.Tables[0].Rows[0]["HUnitID"]);
                        DataSet dataSet14 = clsCN3.RunProcReturn(string.Concat(new string[]
                        {
                    "select * from h_v_SCStockInCheckBill_Json where  HYear =",
                    num21.ToString(),
                    " and HMonth = ",
                    num22.ToString(),
                    " and HDay = ",
                    num23.ToString(),
                    " and HMaterID = ",
                    num28.ToString(),
                    "and 批次 = '",
                    text21.ToString(),
                    "'"
                        }), "h_v_SCStockInCheckBill_Json");
                        long num30 = ClsPub.isLong(dataSet14.Tables[0].Rows[0]["HSourceInterID"]);
                        long num31 = ClsPub.isLong(dataSet14.Tables[0].Rows[0]["HSourceEntryID"]);
                        string text24 = ClsPub.isStrNull(dataSet14.Tables[0].Rows[0]["HBillNo"]);
                        DataSet dataSet15 = clsCN3.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                        string str7 = ClsPub.isStrNull(dataSet15.Tables[0].Rows[0]["HNumber"]);
                        text = str7 + num28.ToString() + text21 + text17 + "#" + num24;
                        text1 = str7 + num28.ToString() + text21 + text17;
                        DateTime dateTime6 = ClsPub.isDate(string.Concat(new string[]
                        {
                    num21.ToString(),
                    "-",
                    num22.ToString(),
                    "-",
                    num23.ToString()
                        }));
                        DataSet dataSet16 = clsCN3.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                        bool flag10 = dataSet16.Tables[0].Rows.Count > 0;
                        if (flag10)
                        {
                            DataSet dataSet17 = clsCN3.RunProcReturn(string.Concat(new string[]
                            {
                        " select * from KF_PonderationBillMain_Temp where HBarCode= '",
                        text1,
                        "' and HInterID = ",
                        hinterid.ToString(),
                        " and HBillType = '",
                        HBillType,
                        "' and hsourcebillno = '",
                        text24,
                        "' "
                            }), "KF_PonderationBillMain_Temp");
                            bool flag11 = dataSet17.Tables[0].Rows.Count > 0;
                            if (!flag11)
                            {
                                WEBSController webscontroller3 = new WEBSController();
                                object obj3 = webscontroller3.get_SourceBarCode_ProductIn_Json(hinterid, HBillNo, HBillType, text24, "3714", HMaker, HOrgID);
                            }
                        }
                        else
                        {
                            //可能和他们的登录组织有关系
                            string billCode3 = "85";
                            long num32 = ClsPub.CreateBillID_Prod(billCode3, ref ClsPub.sExeReturnInfo);
                            long num33 = 0L;
                            clsCN3.RunProc(string.Concat(new string[]
                            {
                        "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                        text1,
                        "','批次条码',",
                        num28.ToString(),
                        ",",
                        num29.ToString(),
                        ",",
                        num24.ToString(),
                        ",'",
                        text21,
                        "',",
                        num33.ToString(),
                        ",0,'",
                        ClsPub.CurUserName,
                        "',getdate(),0,",
                        num24.ToString(),
                        ", ",
                        num30.ToString(),
                        ",",
                        num31.ToString(),
                        ",'",
                        text24.ToString(),
                        "','3714',0, 0,'',0,0,0,'',0,'','','",
                        dateTime6.ToShortDateString(),
                        "','",
                        dateTime5.ToShortDateString(),
                        "','',getdate(), ",
                        HOrgID.ToString(),
                        ",",
                        HOrgID.ToString(),
                        ",'',",
                        num32.ToString(),
                        ",1,0,0,0,'",
                        text22,
                        "','",
                        text23,
                        "','',0,'','',1)"
                            }));
                            DataSet dataSet18 = clsCN3.RunProcReturn(string.Concat(new string[]
                            {
                        " select * from KF_PonderationBillMain_Temp where HBarCode= '",
                        text1,
                        "' and HInterID = ",
                        hinterid.ToString(),
                        " and HBillType = '",
                        HBillType,
                        "' and hsourcebillno = '",
                        text24,
                        "' "
                            }), "KF_PonderationBillMain_Temp");
                            bool flag12 = dataSet18.Tables[0].Rows.Count > 0;
                            if (!flag12)
                            {
                                WEBSController webscontroller4 = new WEBSController();
                                object obj4 = webscontroller4.get_SourceBarCode_ProductIn_Json(hinterid, HBillNo, HBillType, text24, "3714", HMaker, HOrgID);
                            }
                        }
                    }
                }
                bool flag13 = HBillType == "1244"; //WMS 生产退料单
                if (flag13)
                {
                    bool flag14 = sBarCodeNew.Contains("@");
                    if (flag14)
                    {
                        string[] array2 = sBarCodeNew.Split(new char[]
                        {
                    '@'
                        });
                        string str8 = array2[0];
                        Double num34 = (long)ClsPub.isDoule(array2[4]);
                        string text25 = array2[6];
                        DateTime dateTime7 = ClsPub.isDate(array2[3]);
                        DateTime dateTime8 = ClsPub.isDate(array2[5]);
                        string text26 = ClsPub.isStrNull(array2[8]);
                        ClsCN clsCN4 = new ClsCN();
                        DataSet dataSet19 = clsCN4.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                        string str9 = ClsPub.isStrNull(dataSet19.Tables[0].Rows[0]["HNumber"]);
                        DataSet Dss7;
                        Dss7 = clsCN4.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str8 + "'", "T_BD_MATERIAL");
                        if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                        {
                            DataSet Dss8;
                            Dss8 = clsCN4.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str8 + "'", "T_BD_MATERIAL");
                            str8 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                        }
                        else
                        {
                            str8 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                        }
                        DataSet dataSet20 = clsCN4.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str8 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                        long num35 = ClsPub.isLong(dataSet20.Tables[0].Rows[0]["HItemID"]);
                        string text27 = ClsPub.isStrNull(dataSet20.Tables[0].Rows[0]["HName"]);
                        string text28 = ClsPub.isStrNull(dataSet20.Tables[0].Rows[0]["HModel"]);
                        long num36 = (long)ClsPub.isInt(dataSet20.Tables[0].Rows[0]["HUnitID"]);
                        //条码生成规则   组织代码 + 物料ID + 批次号 + # + 数量     用于批次码  每次扫码累计数量
                        text = str9 + num35.ToString() + text25 + "#" + num34;
                        text1 = str9 + num35.ToString() + text25;
                        DataSet dataSet21 = clsCN4.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                        bool flag15 = dataSet21.Tables[0].Rows.Count > 0;
                        if (!flag15)
                        {
                            string billCode4 = "85";
                            long num37 = ClsPub.CreateBillID_Prod(billCode4, ref ClsPub.sExeReturnInfo);
                            long num38 = 0L;
                            clsCN4.RunProc(string.Concat(new string[]
                            {
                        "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                        text1,
                        "','批次条码',",
                        num35.ToString(),
                        ",",
                        num36.ToString(),
                        ",",
                        num34.ToString(),
                        ",'",
                        text25,
                        "',",
                        num38.ToString(),
                        ",0,'",
                        ClsPub.CurUserName,
                        "',getdate(),0,",
                        num34.ToString(),
                        ", 0,0,'','1244',0, 0,'',0,0,0,'',0,'','','",
                        dateTime7.ToShortDateString(),
                        "','",
                        dateTime8.ToShortDateString(),
                        "','',getdate(), ",
                        HOrgID.ToString(),
                        ",",
                        HOrgID.ToString(),
                        ",'',",
                        num37.ToString(),
                        ",1,0,0,0,'",
                        text27,
                        "','",
                        text28,
                        "','',0,'','',1)"
                            }));
                        }
                    }
                    else
                    {
                        string text29 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 4);
                        string text30 = text29.Substring(0, 1);
                        bool flag16 = text30.Contains("W") || text30.Contains("N");
                        if (flag16)
                        {
                            string text31 = sBarCodeNew.Substring(0, 10);
                            string str10 = sBarCodeNew.Substring(10, 10);
                            string text32 = "20" + sBarCodeNew.Substring(20, 6);
                            long num39 = (long)ClsPub.isInt(text32.Substring(0, 4));
                            long num40 = (long)ClsPub.isInt(text32.Substring(4, 2));
                            long num41 = (long)ClsPub.isInt(text32.Substring(6, 2));
                            long num42 = (long)ClsPub.isInt(sBarCodeNew.Remove(0, sBarCodeNew.Length - 3));
                            string text33 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 10);
                            string text34 = "20" + text33.Substring(0, 6);
                            long num43 = (long)ClsPub.isInt(text34.Substring(0, 4));
                            long num44 = (long)ClsPub.isInt(text34.Substring(4, 2));
                            long num45 = (long)ClsPub.isInt(text34.Substring(6, 2));
                            DateTime dateTime9 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num43.ToString(),
                        "-",
                        num44.ToString(),
                        "-",
                        num45.ToString()
                            }));
                            string text35 = sBarCodeNew.Remove(0, 26);
                            string text36 = text35.Remove(text35.Length - 10, 10);
                            ClsCN clsCN5 = new ClsCN();
                            DataSet Dss7;
                            Dss7 = clsCN5.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str10 + "'", "T_BD_MATERIAL");
                            if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                            {
                                DataSet Dss8;
                                Dss8 = clsCN5.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str10 + "'", "T_BD_MATERIAL");
                                str10 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                            }
                            else
                            {
                                str10 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                            }
                            DataSet dataSet22 = clsCN5.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str10 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                            long num46 = ClsPub.isLong(dataSet22.Tables[0].Rows[0]["HItemID"]);
                            string text37 = ClsPub.isStrNull(dataSet22.Tables[0].Rows[0]["HName"]);
                            string text38 = ClsPub.isStrNull(dataSet22.Tables[0].Rows[0]["HModel"]);
                            long num47 = (long)ClsPub.isInt(dataSet22.Tables[0].Rows[0]["HUnitID"]);
                            DataSet dataSet23 = clsCN5.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                            string str11 = ClsPub.isStrNull(dataSet23.Tables[0].Rows[0]["HNumber"]);
                            text = str11 + num46.ToString() + text36 + "#" + num42;
                            text1 = str11 + num46.ToString() + text36;
                            DateTime dateTime10 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num39.ToString(),
                        "-",
                        num40.ToString(),
                        "-",
                        num41.ToString()
                            }));
                            DataSet dataSet24 = clsCN5.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                            bool flag17 = dataSet24.Tables[0].Rows.Count > 0;
                            if (!flag17)
                            {
                                string billCode5 = "85";
                                long num48 = ClsPub.CreateBillID_Prod(billCode5, ref ClsPub.sExeReturnInfo);
                                long num49 = 0L;
                                clsCN5.RunProc(string.Concat(new string[]
                                {
                            "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                            text1,
                            "','批次条码',",
                            num46.ToString(),
                            ",",
                            num47.ToString(),
                            ",",
                            num42.ToString(),
                            ",'",
                            text36,
                            "',",
                            num49.ToString(),
                            ",0,'",
                            ClsPub.CurUserName,
                            "',getdate(),0,",
                            num42.ToString(),
                            ", 0,0,'','',0, 0,'',0,0,0,'',0,'','','",
                            dateTime10.ToShortDateString(),
                            "','",
                            dateTime9.ToShortDateString(),
                            "','',getdate(), ",
                            HOrgID.ToString(),
                            ",",
                            HOrgID.ToString(),
                            ",'',",
                            num48.ToString(),
                            ",1,0,0,0,'",
                            text37,
                            "','",
                            text38,
                            "','',0,'','',1)"
                                }));
                            }
                        }
                        else
                        {
                            string str12 = sBarCodeNew.Substring(0, 10);
                            string text39 = "20" + sBarCodeNew.Substring(10, 6);
                            long num50 = (long)ClsPub.isInt(text39.Substring(0, 4));
                            long num51 = (long)ClsPub.isInt(text39.Substring(4, 2));
                            long num52 = (long)ClsPub.isInt(text39.Substring(6, 2));
                            long num53 = (long)ClsPub.isInt(sBarCodeNew.Remove(0, sBarCodeNew.Length - 3));
                            string text40 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 9);
                            string text41 = "20" + text40.Substring(0, 6);
                            long num54 = (long)ClsPub.isInt(text41.Substring(0, 4));
                            long num55 = (long)ClsPub.isInt(text41.Substring(4, 2));
                            long num56 = (long)ClsPub.isInt(text41.Substring(6, 2));
                            DateTime dateTime11 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num54.ToString(),
                        "-",
                        num55.ToString(),
                        "-",
                        num56.ToString()
                            }));
                            string text42 = sBarCodeNew.Remove(0, 16);
                            string text43 = text42.Remove(text42.Length - 9, 9);
                            ClsCN clsCN6 = new ClsCN();
                            DataSet Dss7;
                            Dss7 = clsCN6.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str12 + "'", "T_BD_MATERIAL");
                            if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                            {
                                DataSet Dss8;
                                Dss8 = clsCN6.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str12 + "'", "T_BD_MATERIAL");
                                str12 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                            }
                            else
                            {
                                str12 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                            }
                            DataSet dataSet25 = clsCN6.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str12 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                            long num57 = ClsPub.isLong(dataSet25.Tables[0].Rows[0]["HItemID"]);
                            string text44 = ClsPub.isStrNull(dataSet25.Tables[0].Rows[0]["HName"]);
                            string text45 = ClsPub.isStrNull(dataSet25.Tables[0].Rows[0]["HModel"]);
                            long num58 = (long)ClsPub.isInt(dataSet25.Tables[0].Rows[0]["HUnitID"]);
                            DataSet dataSet26 = clsCN6.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                            string str13 = ClsPub.isStrNull(dataSet26.Tables[0].Rows[0]["HNumber"]);
                            text = str13 + num57.ToString() + text43 + "#" + num53;
                            text1 = str13 + num57.ToString() + text43;
                            DateTime dateTime12 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num50.ToString(),
                        "-",
                        num51.ToString(),
                        "-",
                        num52.ToString()
                            }));
                            DataSet dataSet27 = clsCN6.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                            bool flag18 = dataSet27.Tables[0].Rows.Count > 0;
                            if (!flag18)
                            {
                                string billCode6 = "85";
                                long num59 = ClsPub.CreateBillID_Prod(billCode6, ref ClsPub.sExeReturnInfo);
                                long num60 = 0L;
                                clsCN6.RunProc(string.Concat(new string[]
                                {
                            "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                            text1,
                            "','批次条码',",
                            num57.ToString(),
                            ",",
                            num58.ToString(),
                            ",",
                            num53.ToString(),
                            ",'",
                            text43,
                            "',",
                            num60.ToString(),
                            ",0,'",
                            ClsPub.CurUserName,
                            "',getdate(),0,",
                            num53.ToString(),
                            ", 0,0,'','3714',0, 0,'',0,0,0,'',0,'','','",
                            dateTime12.ToShortDateString(),
                            "','",
                            dateTime11.ToShortDateString(),
                            "','',getdate(), ",
                            HOrgID.ToString(),
                            ",",
                            HOrgID.ToString(),
                            ",'',",
                            num59.ToString(),
                            ",1,0,0,0,'",
                            text44,
                            "','",
                            text45,
                            "','',0,'','',1)"
                                }));
                            }
                        }
                    }
                }
                bool flag19 = HBillType == "1207"; //WMS 直接调拨
                if (flag19)
                {
                    bool flag20 = sBarCodeNew.Contains("@");
                    if (flag20)
                    {
                        string[] array3 = sBarCodeNew.Split(new char[]
                        {
                    '@'
                        });
                        string str14 = array3[0];
                        //long num61 = (long)ClsPub.isInt(array3[4]);
                        Double num61 = ClsPub.isDoule(array3[4]);
                        string text46 = array3[6];
                        DateTime dateTime13 = ClsPub.isDate(array3[3]);
                        DateTime dateTime14 = ClsPub.isDate(array3[5]);
                        string text47 = ClsPub.isStrNull(array3[8]);
                        ClsCN clsCN7 = new ClsCN();
                        DataSet dataSet28 = clsCN7.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                        string str15 = ClsPub.isStrNull(dataSet28.Tables[0].Rows[0]["HNumber"]);
                        DataSet Dss7;
                        Dss7 = clsCN7.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str14 + "'", "T_BD_MATERIAL");
                        if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                        {
                            DataSet Dss8;
                            Dss8 = clsCN7.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str14 + "'", "T_BD_MATERIAL");
                            str14 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                        }
                        else
                        {
                            str14 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                        }
                        DataSet dataSet29 = clsCN7.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str14 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                        long num62 = ClsPub.isLong(dataSet29.Tables[0].Rows[0]["HItemID"]);
                        string text48 = ClsPub.isStrNull(dataSet29.Tables[0].Rows[0]["HName"]);
                        string text49 = ClsPub.isStrNull(dataSet29.Tables[0].Rows[0]["HModel"]);
                        long num63 = (long)ClsPub.isInt(dataSet29.Tables[0].Rows[0]["HUnitID"]);
                        text = str15 + num62.ToString() + text46 + dateTime13.Year.ToString() + dateTime13.Month.ToString() + dateTime13.Day.ToString() + "#" + num61;
                        text1 = str15 + num62.ToString() + text46 + dateTime13.Year.ToString() + dateTime13.Month.ToString() + dateTime13.Day.ToString();
                        DataSet dataSet30 = clsCN7.RunProcReturn(" select * from Gy_BarCodeBill where   HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                        bool flag21 = dataSet30.Tables[0].Rows.Count > 0;
                        if (!flag21)
                        {
                            string billCode7 = "85";
                            long num64 = ClsPub.CreateBillID_Prod(billCode7, ref ClsPub.sExeReturnInfo);
                            long num65 = 0L;
                            clsCN7.RunProc(string.Concat(new string[]
                            {
                        "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                        text1,
                        "','批次条码',",
                        num62.ToString(),
                        ",",
                        num63.ToString(),
                        ",",
                        num61.ToString(),
                        ",'",
                        text46,
                        "',",
                        num65.ToString(),
                        ",0,'",
                        ClsPub.CurUserName,
                        "',getdate(),0,",
                        num61.ToString(),
                        ", 0,0,'','1207',0, 0,'',0,0,0,'',0,'','','",
                        dateTime13.ToShortDateString(),
                        "','",
                        dateTime14.ToShortDateString(),
                        "','',getdate(), ",
                        HOrgID.ToString(),
                        ",",
                        HOrgID.ToString(),
                        ",'',",
                        num64.ToString(),
                        ",1,0,0,0,'",
                        text48,
                        "','",
                        text49,
                        "','',0,'','',1)"
                            }));
                        }
                    }
                    else
                    {
                        string text50 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 4);
                        string text51 = text50.Substring(0, 1);
                        bool flag22 = text51.Contains("W") || text51.Contains("N");
                        if (flag22)
                        {
                            string text52 = sBarCodeNew.Substring(0, 10);
                            string str16 = sBarCodeNew.Substring(10, 10);
                            string text53 = "20" + sBarCodeNew.Substring(20, 6);
                            long num66 = (long)ClsPub.isInt(text53.Substring(0, 4));
                            long num67 = (long)ClsPub.isInt(text53.Substring(4, 2));
                            long num68 = (long)ClsPub.isInt(text53.Substring(6, 2));
                            long num69 = (long)ClsPub.isInt(sBarCodeNew.Remove(0, sBarCodeNew.Length - 3));
                            string text54 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 10);
                            string text55 = "20" + text54.Substring(0, 6);
                            long num70 = (long)ClsPub.isInt(text55.Substring(0, 4));
                            long num71 = (long)ClsPub.isInt(text55.Substring(4, 2));
                            long num72 = (long)ClsPub.isInt(text55.Substring(6, 2));
                            DateTime dateTime15 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num70.ToString(),
                        "-",
                        num71.ToString(),
                        "-",
                        num72.ToString()
                            }));
                            string text56 = sBarCodeNew.Remove(0, 26);
                            string text57 = text56.Remove(text56.Length - 10, 10);
                            ClsCN clsCN8 = new ClsCN();
                            DataSet Dss7;
                            Dss7 = clsCN8.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str16 + "'", "T_BD_MATERIAL");
                            if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                            {
                                DataSet Dss8;
                                Dss8 = clsCN8.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str16 + "'", "T_BD_MATERIAL");
                                str16 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                            }
                            else
                            {
                                str16 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                            }
                            DataSet dataSet31 = clsCN8.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str16 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                            long num73 = ClsPub.isLong(dataSet31.Tables[0].Rows[0]["HItemID"]);
                            string text58 = ClsPub.isStrNull(dataSet31.Tables[0].Rows[0]["HName"]);
                            string text59 = ClsPub.isStrNull(dataSet31.Tables[0].Rows[0]["HModel"]);
                            long num74 = (long)ClsPub.isInt(dataSet31.Tables[0].Rows[0]["HUnitID"]);
                            DataSet dataSet32 = clsCN8.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                            string str17 = ClsPub.isStrNull(dataSet32.Tables[0].Rows[0]["HNumber"]);
                            text = str17 + num73.ToString() + text57 + text53 + "#" + num69;
                            text1 = str17 + num73.ToString() + text57 + text53;
                            DateTime dateTime16 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num66.ToString(),
                        "-",
                        num67.ToString(),
                        "-",
                        num68.ToString()
                            }));
                            DataSet dataSet33 = clsCN8.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                            bool flag23 = dataSet33.Tables[0].Rows.Count > 0;
                            if (!flag23)
                            {
                                string billCode8 = "85";
                                long num75 = ClsPub.CreateBillID_Prod(billCode8, ref ClsPub.sExeReturnInfo);
                                long num76 = 0L;
                                clsCN8.RunProc(string.Concat(new string[]
                                {
                            "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                            text1,
                            "','批次条码',",
                            num73.ToString(),
                            ",",
                            num74.ToString(),
                            ",",
                            num69.ToString(),
                            ",'",
                            text57,
                            "',",
                            num76.ToString(),
                            ",0,'",
                            ClsPub.CurUserName,
                            "',getdate(),0,",
                            num69.ToString(),
                            ", 0,0,'','',0, 0,'',0,0,0,'',0,'','','",
                            dateTime16.ToShortDateString(),
                            "','",
                            dateTime15.ToShortDateString(),
                            "','',getdate(), ",
                            HOrgID.ToString(),
                            ",",
                            HOrgID.ToString(),
                            ",'',",
                            num75.ToString(),
                            ",1,0,0,0,'",
                            text58,
                            "','",
                            text59,
                            "','',0,'','',1)"
                                }));
                            }
                        }
                        else
                        {
                            string str18 = sBarCodeNew.Substring(0, 10);
                            string text60 = "20" + sBarCodeNew.Substring(10, 6);
                            long num77 = (long)ClsPub.isInt(text60.Substring(0, 4));
                            long num78 = (long)ClsPub.isInt(text60.Substring(4, 2));
                            long num79 = (long)ClsPub.isInt(text60.Substring(6, 2));
                            long num80 = (long)ClsPub.isInt(sBarCodeNew.Remove(0, sBarCodeNew.Length - 3));
                            string text61 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 9);
                            string text62 = "20" + text61.Substring(0, 6);
                            long num81 = (long)ClsPub.isInt(text62.Substring(0, 4));
                            long num82 = (long)ClsPub.isInt(text62.Substring(4, 2));
                            long num83 = (long)ClsPub.isInt(text62.Substring(6, 2));
                            DateTime dateTime17 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num81.ToString(),
                        "-",
                        num82.ToString(),
                        "-",
                        num83.ToString()
                            }));
                            string text63 = sBarCodeNew.Remove(0, 16);
                            string text64 = text63.Remove(text63.Length - 9, 9);
                            ClsCN clsCN9 = new ClsCN();
                            DataSet dataSet34 = clsCN9.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str18 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                            long num84 = ClsPub.isLong(dataSet34.Tables[0].Rows[0]["HItemID"]);
                            string text65 = ClsPub.isStrNull(dataSet34.Tables[0].Rows[0]["HName"]);
                            string text66 = ClsPub.isStrNull(dataSet34.Tables[0].Rows[0]["HModel"]);
                            long num85 = (long)ClsPub.isInt(dataSet34.Tables[0].Rows[0]["HUnitID"]);
                            DataSet dataSet35 = clsCN9.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                            string str19 = ClsPub.isStrNull(dataSet35.Tables[0].Rows[0]["HNumber"]);
                            text = str19 + num84.ToString() + text64 + text60 + "#" + num80;
                            text1 = str19 + num84.ToString() + text64 + text60;
                            DateTime dateTime18 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num77.ToString(),
                        "-",
                        num78.ToString(),
                        "-",
                        num79.ToString()
                            }));
                            DataSet dataSet36 = clsCN9.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "' and HProduceDate = '" + dateTime18 + "'", "Gy_BarCodeBill");
                            bool flag24 = dataSet36.Tables[0].Rows.Count > 0;
                            if (!flag24)
                            {
                                string billCode9 = "85";
                                long num86 = ClsPub.CreateBillID_Prod(billCode9, ref ClsPub.sExeReturnInfo);
                                long num87 = 0L;
                                clsCN9.RunProc(string.Concat(new string[]
                                {
                            "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                            text1,
                            "','批次条码',",
                            num84.ToString(),
                            ",",
                            num85.ToString(),
                            ",",
                            num80.ToString(),
                            ",'",
                            text64,
                            "',",
                            num87.ToString(),
                            ",0,'",
                            ClsPub.CurUserName,
                            "',getdate(),0,",
                            num80.ToString(),
                            ", 0,0,'','3714',0, 0,'',0,0,0,'',0,'','','",
                            dateTime18.ToShortDateString(),
                            "','",
                            dateTime17.ToShortDateString(),
                            "','',getdate(), ",
                            HOrgID.ToString(),
                            ",",
                            HOrgID.ToString(),
                            ",'',",
                            num86.ToString(),
                            ",1,0,0,0,'",
                            text65,
                            "','",
                            text66,
                            "','',0,'','',1)"
                                }));
                            }
                        }
                    }
                }
                bool flag25 = HBillType == "1206"; //WMS 销售出库
                if (flag25)
                {
                    bool flag26 = sBarCodeNew.Contains("@");
                    if (flag26)
                    {
                        string[] array4 = sBarCodeNew.Split(new char[]
                        {
                    '@'
                        });
                        string str20 = array4[0];
                        long num88 = (long)ClsPub.isInt(array4[4]);
                        string text67 = array4[6];
                        DateTime dateTime19 = ClsPub.isDate(array4[3]);
                        DateTime dateTime20 = ClsPub.isDate(array4[5]);
                        string text68 = ClsPub.isStrNull(array4[8]);
                        ClsCN clsCN10 = new ClsCN();
                        DataSet dataSet37 = clsCN10.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                        string str21 = ClsPub.isStrNull(dataSet37.Tables[0].Rows[0]["HNumber"]);
                        DataSet Dss7;
                        Dss7 = clsCN10.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str20 + "'", "T_BD_MATERIAL");
                        if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                        {
                            DataSet Dss8;
                            Dss8 = clsCN10.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str20 + "'", "T_BD_MATERIAL");
                            str20 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                        }
                        else
                        {
                            str20 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                        }
                        DataSet dataSet38 = clsCN10.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str20 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                        long num89 = ClsPub.isLong(dataSet38.Tables[0].Rows[0]["HItemID"]);
                        string text69 = ClsPub.isStrNull(dataSet38.Tables[0].Rows[0]["HName"]);
                        string text70 = ClsPub.isStrNull(dataSet38.Tables[0].Rows[0]["HModel"]);
                        long num90 = (long)ClsPub.isInt(dataSet38.Tables[0].Rows[0]["HUnitID"]);
                        text = str21 + num89.ToString() + text67 + "#" + num88;
                        text1 = str21 + num89.ToString() + text67;
                        DataSet dataSet39 = clsCN10.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                        bool flag27 = dataSet39.Tables[0].Rows.Count > 0;
                        if (!flag27)
                        {
                            string billCode10 = "85";
                            long num91 = ClsPub.CreateBillID_Prod(billCode10, ref ClsPub.sExeReturnInfo);
                            long num92 = 0L;
                            clsCN10.RunProc(string.Concat(new string[]
                            {
                        "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                        text1,
                        "','批次条码',",
                        num89.ToString(),
                        ",",
                        num90.ToString(),
                        ",",
                        num88.ToString(),
                        ",'",
                        text67,
                        "',",
                        num92.ToString(),
                        ",0,'",
                        ClsPub.CurUserName,
                        "',getdate(),0,",
                        num88.ToString(),
                        ", 0,0,'','1206',0, 0,'',0,0,0,'',0,'','','",
                        dateTime19.ToShortDateString(),
                        "','",
                        dateTime20.ToShortDateString(),
                        "','',getdate(), ",
                        HOrgID.ToString(),
                        ",",
                        HOrgID.ToString(),
                        ",'',",
                        num91.ToString(),
                        ",1,0,0,0,'",
                        text69,
                        "','",
                        text70,
                        "','',0,'','',1)"
                            }));
                        }
                    }
                    else
                    {
                        string text71 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 4);
                        string text72 = text71.Substring(0, 1);
                        bool flag28 = text72.Contains("W") || text72.Contains("N");
                        if (flag28)
                        {
                            string text73 = sBarCodeNew.Substring(0, 10);
                            string str22 = sBarCodeNew.Substring(10, 10);
                            string text74 = "20" + sBarCodeNew.Substring(20, 6);
                            long num93 = (long)ClsPub.isInt(text74.Substring(0, 4));
                            long num94 = (long)ClsPub.isInt(text74.Substring(4, 2));
                            long num95 = (long)ClsPub.isInt(text74.Substring(6, 2));
                            long num96 = (long)ClsPub.isInt(sBarCodeNew.Remove(0, sBarCodeNew.Length - 3));
                            string text75 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 10);
                            string text76 = "20" + text75.Substring(0, 6);
                            long num97 = (long)ClsPub.isInt(text76.Substring(0, 4));
                            long num98 = (long)ClsPub.isInt(text76.Substring(4, 2));
                            long num99 = (long)ClsPub.isInt(text76.Substring(6, 2));
                            DateTime dateTime21 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num97.ToString(),
                        "-",
                        num98.ToString(),
                        "-",
                        num99.ToString()
                            }));
                            string text77 = sBarCodeNew.Remove(0, 26);
                            string text78 = text77.Remove(text77.Length - 10, 10);
                            ClsCN clsCN11 = new ClsCN();
                            DataSet Dss7;
                            Dss7 = clsCN11.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str22 + "'", "T_BD_MATERIAL");
                            if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                            {
                                DataSet Dss8;
                                Dss8 = clsCN11.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str22 + "'", "T_BD_MATERIAL");
                                str22 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                            }
                            else
                            {
                                str22 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                            }
                            DataSet dataSet40 = clsCN11.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str22 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                            long num100 = ClsPub.isLong(dataSet40.Tables[0].Rows[0]["HItemID"]);
                            string text79 = ClsPub.isStrNull(dataSet40.Tables[0].Rows[0]["HName"]);
                            string text80 = ClsPub.isStrNull(dataSet40.Tables[0].Rows[0]["HModel"]);
                            long num101 = (long)ClsPub.isInt(dataSet40.Tables[0].Rows[0]["HUnitID"]);
                            DataSet dataSet41 = clsCN11.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                            string str23 = ClsPub.isStrNull(dataSet41.Tables[0].Rows[0]["HNumber"]);
                            text = str23 + num100.ToString() + text78 + "#" + num96;
                            text1 = str23 + num100.ToString() + text78;
                            DateTime dateTime22 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num93.ToString(),
                        "-",
                        num94.ToString(),
                        "-",
                        num95.ToString()
                            }));
                            DataSet dataSet42 = clsCN11.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                            bool flag29 = dataSet42.Tables[0].Rows.Count > 0;
                            if (!flag29)
                            {
                                string billCode11 = "85";
                                long num102 = ClsPub.CreateBillID_Prod(billCode11, ref ClsPub.sExeReturnInfo);
                                long num103 = 0L;
                                clsCN11.RunProc(string.Concat(new string[]
                                {
                            "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                            text1,
                            "','批次条码',",
                            num100.ToString(),
                            ",",
                            num101.ToString(),
                            ",",
                            num96.ToString(),
                            ",'",
                            text78,
                            "',",
                            num103.ToString(),
                            ",0,'",
                            ClsPub.CurUserName,
                            "',getdate(),0,",
                            num96.ToString(),
                            ", 0,0,'','',0, 0,'',0,0,0,'',0,'','','",
                            dateTime22.ToShortDateString(),
                            "','",
                            dateTime21.ToShortDateString(),
                            "','',getdate(), ",
                            HOrgID.ToString(),
                            ",",
                            HOrgID.ToString(),
                            ",'',",
                            num102.ToString(),
                            ",1,0,0,0,'",
                            text79,
                            "','",
                            text80,
                            "','',0,'','',1)"
                                }));
                            }
                        }
                        else
                        {
                            string str24 = sBarCodeNew.Substring(0, 10);
                            string text81 = "20" + sBarCodeNew.Substring(10, 6);
                            long num104 = (long)ClsPub.isInt(text81.Substring(0, 4));
                            long num105 = (long)ClsPub.isInt(text81.Substring(4, 2));
                            long num106 = (long)ClsPub.isInt(text81.Substring(6, 2));
                            long num107 = (long)ClsPub.isInt(sBarCodeNew.Remove(0, sBarCodeNew.Length - 3));
                            string text82 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 9);
                            string text83 = "20" + text82.Substring(0, 6);
                            long num108 = (long)ClsPub.isInt(text83.Substring(0, 4));
                            long num109 = (long)ClsPub.isInt(text83.Substring(4, 2));
                            long num110 = (long)ClsPub.isInt(text83.Substring(6, 2));
                            DateTime dateTime23 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num108.ToString(),
                        "-",
                        num109.ToString(),
                        "-",
                        num110.ToString()
                            }));
                            string text84 = sBarCodeNew.Remove(0, 16);
                            string text85 = text84.Remove(text84.Length - 9, 9);
                            ClsCN clsCN12 = new ClsCN();
                            DataSet Dss7;
                            Dss7 = clsCN12.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str24 + "'", "T_BD_MATERIAL");
                            if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                            {
                                DataSet Dss8;
                                Dss8 = clsCN12.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str24 + "'", "T_BD_MATERIAL");
                                str24 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                            }
                            else
                            {
                                str24 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                            }
                            DataSet dataSet43 = clsCN12.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str24 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                            long num111 = ClsPub.isLong(dataSet43.Tables[0].Rows[0]["HItemID"]);
                            string text86 = ClsPub.isStrNull(dataSet43.Tables[0].Rows[0]["HName"]);
                            string text87 = ClsPub.isStrNull(dataSet43.Tables[0].Rows[0]["HModel"]);
                            long num112 = (long)ClsPub.isInt(dataSet43.Tables[0].Rows[0]["HUnitID"]);
                            DataSet dataSet44 = clsCN12.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                            string str25 = ClsPub.isStrNull(dataSet44.Tables[0].Rows[0]["HNumber"]);
                            text = str25 + num111.ToString() + text85 + "#" + num107;
                            text1 = str25 + num111.ToString() + text85;
                            DateTime dateTime24 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num104.ToString(),
                        "-",
                        num105.ToString(),
                        "-",
                        num106.ToString()
                            }));
                            DataSet dataSet45 = clsCN12.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                            bool flag30 = dataSet45.Tables[0].Rows.Count > 0;
                            if (!flag30)
                            {
                                string billCode12 = "85";
                                long num113 = ClsPub.CreateBillID_Prod(billCode12, ref ClsPub.sExeReturnInfo);
                                long num114 = 0L;
                                clsCN12.RunProc(string.Concat(new string[]
                                {
                            "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                            text1,
                            "','批次条码',",
                            num111.ToString(),
                            ",",
                            num112.ToString(),
                            ",",
                            num107.ToString(),
                            ",'",
                            text85,
                            "',",
                            num114.ToString(),
                            ",0,'",
                            ClsPub.CurUserName,
                            "',getdate(),0,",
                            num107.ToString(),
                            ", 0,0,'','3714',0, 0,'',0,0,0,'',0,'','','",
                            dateTime24.ToShortDateString(),
                            "','",
                            dateTime23.ToShortDateString(),
                            "','',getdate(), ",
                            HOrgID.ToString(),
                            ",",
                            HOrgID.ToString(),
                            ",'',",
                            num113.ToString(),
                            ",1,0,0,0,'",
                            text86,
                            "','",
                            text87,
                            "','',0,'','',1)"
                                }));
                            }
                        }
                    }
                }
                bool flag31 = HBillType == "1204"; //WMS 生产领料
                if (flag31)
                {
                    bool flag32 = sBarCodeNew.Contains("@");
                    if (flag32)
                    {
                        string[] array5 = sBarCodeNew.Split(new char[]
                        {
                    '@'
                        });
                        string str26 = array5[0];
                        long num115 = (long)ClsPub.isInt(array5[4]);
                        string text88 = array5[6];
                        DateTime dateTime25 = ClsPub.isDate(array5[3]);
                        DateTime dateTime26 = ClsPub.isDate(array5[5]);
                        string text89 = ClsPub.isStrNull(array5[8]);
                        ClsCN clsCN13 = new ClsCN();
                        DataSet dataSet46 = clsCN13.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                        string str27 = ClsPub.isStrNull(dataSet46.Tables[0].Rows[0]["HNumber"]);
                        DataSet Dss7;
                        Dss7 = clsCN13.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str26 + "'", "T_BD_MATERIAL");
                        if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                        {
                            DataSet Dss8;
                            Dss8 = clsCN13.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str26 + "'", "T_BD_MATERIAL");
                            str26 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                        }
                        else
                        {
                            str26 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                        }
                        DataSet dataSet47 = clsCN13.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str26 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                        long num116 = ClsPub.isLong(dataSet47.Tables[0].Rows[0]["HItemID"]);
                        string text90 = ClsPub.isStrNull(dataSet47.Tables[0].Rows[0]["HName"]);
                        string text91 = ClsPub.isStrNull(dataSet47.Tables[0].Rows[0]["HModel"]);
                        long num117 = (long)ClsPub.isInt(dataSet47.Tables[0].Rows[0]["HUnitID"]);
                        text = str27 + num116.ToString() + text88 + "#" + num115;
                        text1 = str27 + num116.ToString() + text88;
                        DataSet dataSet48 = clsCN13.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                        bool flag33 = dataSet48.Tables[0].Rows.Count > 0;
                        if (!flag33)
                        {
                            string billCode13 = "85";
                            long num118 = ClsPub.CreateBillID_Prod(billCode13, ref ClsPub.sExeReturnInfo);
                            long num119 = 0L;
                            clsCN13.RunProc(string.Concat(new string[]
                            {
                        "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                        text1,
                        "','批次条码',",
                        num116.ToString(),
                        ",",
                        num117.ToString(),
                        ",",
                        num115.ToString(),
                        ",'",
                        text88,
                        "',",
                        num119.ToString(),
                        ",0,'",
                        ClsPub.CurUserName,
                        "',getdate(),0,",
                        num115.ToString(),
                        ", 0,0,'','1103',0, 0,'',0,0,0,'',0,'','','",
                        dateTime25.ToShortDateString(),
                        "','",
                        dateTime26.ToShortDateString(),
                        "','',getdate(), ",
                        HOrgID.ToString(),
                        ",",
                        HOrgID.ToString(),
                        ",'',",
                        num118.ToString(),
                        ",1,0,0,0,'",
                        text90,
                        "','",
                        text91,
                        "','',0,'','',1)"
                            }));
                        }
                    }
                    else
                    {
                        string text92 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 4);
                        string text93 = text92.Substring(0, 1);
                        bool flag34 = text93.Contains("W") || text93.Contains("N");
                        if (flag34)
                        {
                            string text94 = sBarCodeNew.Substring(0, 10);
                            string str28 = sBarCodeNew.Substring(10, 10);
                            string text95 = "20" + sBarCodeNew.Substring(20, 6);
                            long num120 = (long)ClsPub.isInt(text95.Substring(0, 4));
                            long num121 = (long)ClsPub.isInt(text95.Substring(4, 2));
                            long num122 = (long)ClsPub.isInt(text95.Substring(6, 2));
                            long num123 = (long)ClsPub.isInt(sBarCodeNew.Remove(0, sBarCodeNew.Length - 3));
                            string text96 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 10);
                            string text97 = "20" + text96.Substring(0, 6);
                            long num124 = (long)ClsPub.isInt(text97.Substring(0, 4));
                            long num125 = (long)ClsPub.isInt(text97.Substring(4, 2));
                            long num126 = (long)ClsPub.isInt(text97.Substring(6, 2));
                            DateTime dateTime27 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num124.ToString(),
                        "-",
                        num125.ToString(),
                        "-",
                        num126.ToString()
                            }));
                            string text98 = sBarCodeNew.Remove(0, 26);
                            string text99 = text98.Remove(text98.Length - 10, 10);
                            ClsCN clsCN14 = new ClsCN();
                            DataSet Dss7;
                            Dss7 = clsCN14.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str28 + "'", "T_BD_MATERIAL");
                            if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                            {
                                DataSet Dss8;
                                Dss8 = clsCN14.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str28 + "'", "T_BD_MATERIAL");
                                str28 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                            }
                            else
                            {
                                str28 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                            }
                            DataSet dataSet49 = clsCN14.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str28 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                            long num127 = ClsPub.isLong(dataSet49.Tables[0].Rows[0]["HItemID"]);
                            string text100 = ClsPub.isStrNull(dataSet49.Tables[0].Rows[0]["HName"]);
                            string text101 = ClsPub.isStrNull(dataSet49.Tables[0].Rows[0]["HModel"]);
                            long num128 = (long)ClsPub.isInt(dataSet49.Tables[0].Rows[0]["HUnitID"]);
                            DataSet dataSet50 = clsCN14.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                            string str29 = ClsPub.isStrNull(dataSet50.Tables[0].Rows[0]["HNumber"]);
                            text = str29 + num127.ToString() + text99 + "#" + num123;
                            text1 = str29 + num127.ToString() + text99;
                            DateTime dateTime28 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num120.ToString(),
                        "-",
                        num121.ToString(),
                        "-",
                        num122.ToString()
                            }));
                            DataSet dataSet51 = clsCN14.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                            bool flag35 = dataSet51.Tables[0].Rows.Count > 0;
                            if (!flag35)
                            {
                                string billCode14 = "85";
                                long num129 = ClsPub.CreateBillID_Prod(billCode14, ref ClsPub.sExeReturnInfo);
                                long num130 = 0L;
                                clsCN14.RunProc(string.Concat(new string[]
                                {
                            "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                            text1,
                            "','批次条码',",
                            num127.ToString(),
                            ",",
                            num128.ToString(),
                            ",",
                            num123.ToString(),
                            ",'",
                            text99,
                            "',",
                            num130.ToString(),
                            ",0,'",
                            ClsPub.CurUserName,
                            "',getdate(),0,",
                            num123.ToString(),
                            ", 0,0,'','',0, 0,'',0,0,0,'',0,'','','",
                            dateTime28.ToShortDateString(),
                            "','",
                            dateTime27.ToShortDateString(),
                            "','',getdate(), ",
                            HOrgID.ToString(),
                            ",",
                            HOrgID.ToString(),
                            ",'',",
                            num129.ToString(),
                            ",1,0,0,0,'",
                            text100,
                            "','",
                            text101,
                            "','',0,'','',1)"
                                }));
                            }
                        }
                        else
                        {
                            string str30 = sBarCodeNew.Substring(0, 10);
                            string text102 = "20" + sBarCodeNew.Substring(10, 6);
                            long num131 = (long)ClsPub.isInt(text102.Substring(0, 4));
                            long num132 = (long)ClsPub.isInt(text102.Substring(4, 2));
                            long num133 = (long)ClsPub.isInt(text102.Substring(6, 2));
                            long num134 = (long)ClsPub.isInt(sBarCodeNew.Remove(0, sBarCodeNew.Length - 3));
                            string text103 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 9);
                            string text104 = "20" + text103.Substring(0, 6);
                            long num135 = (long)ClsPub.isInt(text104.Substring(0, 4));
                            long num136 = (long)ClsPub.isInt(text104.Substring(4, 2));
                            long num137 = (long)ClsPub.isInt(text104.Substring(6, 2));
                            DateTime dateTime29 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num135.ToString(),
                        "-",
                        num136.ToString(),
                        "-",
                        num137.ToString()
                            }));
                            string text105 = sBarCodeNew.Remove(0, 16);
                            string text106 = text105.Remove(text105.Length - 9, 9);
                            ClsCN clsCN15 = new ClsCN();
                            DataSet Dss7;
                            Dss7 = clsCN15.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str30 + "'", "T_BD_MATERIAL");
                            if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                            {
                                DataSet Dss8;
                                Dss8 = clsCN15.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str30 + "'", "T_BD_MATERIAL");
                                str30 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                            }
                            else
                            {
                                str30 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                            }
                            DataSet dataSet52 = clsCN15.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str30 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                            long num138 = ClsPub.isLong(dataSet52.Tables[0].Rows[0]["HItemID"]);
                            string text107 = ClsPub.isStrNull(dataSet52.Tables[0].Rows[0]["HName"]);
                            string text108 = ClsPub.isStrNull(dataSet52.Tables[0].Rows[0]["HModel"]);
                            long num139 = (long)ClsPub.isInt(dataSet52.Tables[0].Rows[0]["HUnitID"]);
                            DataSet dataSet53 = clsCN15.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                            string str31 = ClsPub.isStrNull(dataSet53.Tables[0].Rows[0]["HNumber"]);
                            text = str31 + num138.ToString() + text106 + "#" + num134;
                            text1 = str31 + num138.ToString() + text106;
                            DateTime dateTime30 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num131.ToString(),
                        "-",
                        num132.ToString(),
                        "-",
                        num133.ToString()
                            }));
                            DataSet dataSet54 = clsCN15.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                            bool flag36 = dataSet54.Tables[0].Rows.Count > 0;
                            if (!flag36)
                            {
                                string billCode15 = "85";
                                long num140 = ClsPub.CreateBillID_Prod(billCode15, ref ClsPub.sExeReturnInfo);
                                long num141 = 0L;
                                clsCN15.RunProc(string.Concat(new string[]
                                {
                            "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                            text1,
                            "','批次条码',",
                            num138.ToString(),
                            ",",
                            num139.ToString(),
                            ",",
                            num134.ToString(),
                            ",'",
                            text106,
                            "',",
                            num141.ToString(),
                            ",0,'",
                            ClsPub.CurUserName,
                            "',getdate(),0,",
                            num134.ToString(),
                            ", 0,0,'','3714',0, 0,'',0,0,0,'',0,'','','",
                            dateTime30.ToShortDateString(),
                            "','",
                            dateTime29.ToShortDateString(),
                            "','',getdate(), ",
                            HOrgID.ToString(),
                            ",",
                            HOrgID.ToString(),
                            ",'',",
                            num140.ToString(),
                            ",1,0,0,0,'",
                            text107,
                            "','",
                            text108,
                            "','',0,'','',1)"
                                }));
                            }
                        }
                    }
                }
                bool flag37 = HBillType == "1254" /*生产补料*/ || HBillType == "1211" || HBillType == "1255";
                if (flag37)
                {
                    bool flag38 = sBarCodeNew.Contains("@");
                    if (flag38)
                    {
                        string[] array6 = sBarCodeNew.Split(new char[]
                        {
                    '@'
                        });
                        string str32 = array6[0];
                        long num142 = (long)ClsPub.isInt(array6[4]);
                        string text109 = array6[6];
                        DateTime dateTime31 = ClsPub.isDate(array6[3]);
                        DateTime dateTime32 = ClsPub.isDate(array6[5]);
                        string text110 = ClsPub.isStrNull(array6[8]);
                        ClsCN clsCN16 = new ClsCN();
                        DataSet dataSet55 = clsCN16.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                        string str33 = ClsPub.isStrNull(dataSet55.Tables[0].Rows[0]["HNumber"]);
                        DataSet Dss7;
                        Dss7 = clsCN16.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str32 + "'", "T_BD_MATERIAL");
                        if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                        {
                            DataSet Dss8;
                            Dss8 = clsCN16.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str32 + "'", "T_BD_MATERIAL");
                            str32 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                        }
                        else
                        {
                            str32 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                        }
                        DataSet dataSet56 = clsCN16.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str32 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                        long num143 = ClsPub.isLong(dataSet56.Tables[0].Rows[0]["HItemID"]);
                        string text111 = ClsPub.isStrNull(dataSet56.Tables[0].Rows[0]["HName"]);
                        string text112 = ClsPub.isStrNull(dataSet56.Tables[0].Rows[0]["HModel"]);
                        long num144 = (long)ClsPub.isInt(dataSet56.Tables[0].Rows[0]["HUnitID"]);
                        text = str33 + num143.ToString() + text109 + "#" + num142;
                        text1 = str33 + num143.ToString() + text109;
                        DataSet dataSet57 = clsCN16.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                        bool flag39 = dataSet57.Tables[0].Rows.Count > 0;
                        if (!flag39)
                        {
                            string billCode16 = "85";
                            long num145 = ClsPub.CreateBillID_Prod(billCode16, ref ClsPub.sExeReturnInfo);
                            long num146 = 0L;
                            clsCN16.RunProc(string.Concat(new string[]
                            {
                        "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                        text1,
                        "','批次条码',",
                        num143.ToString(),
                        ",",
                        num144.ToString(),
                        ",",
                        num142.ToString(),
                        ",'",
                        text109,
                        "',",
                        num146.ToString(),
                        ",0,'",
                        ClsPub.CurUserName,
                        "',getdate(),0,",
                        num142.ToString(),
                        ", 0,0,'','1103',0, 0,'',0,0,0,'',0,'','','",
                        dateTime31.ToShortDateString(),
                        "','",
                        dateTime32.ToShortDateString(),
                        "','',getdate(), ",
                        HOrgID.ToString(),
                        ",",
                        HOrgID.ToString(),
                        ",'',",
                        num145.ToString(),
                        ",1,0,0,0,'",
                        text111,
                        "','",
                        text112,
                        "','',0,'','',1)"
                            }));
                        }
                    }
                    else
                    {
                        string text113 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 4);
                        string text114 = text113.Substring(0, 1);
                        bool flag40 = text114.Contains("W") || text114.Contains("N");
                        if (flag40)
                        {
                            string text115 = sBarCodeNew.Substring(0, 10);
                            string str34 = sBarCodeNew.Substring(10, 10);
                            string text116 = "20" + sBarCodeNew.Substring(20, 6);
                            long num147 = (long)ClsPub.isInt(text116.Substring(0, 4));
                            long num148 = (long)ClsPub.isInt(text116.Substring(4, 2));
                            long num149 = (long)ClsPub.isInt(text116.Substring(6, 2));
                            long num150 = (long)ClsPub.isInt(sBarCodeNew.Remove(0, sBarCodeNew.Length - 3));
                            string text117 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 10);
                            string text118 = "20" + text117.Substring(0, 6);
                            long num151 = (long)ClsPub.isInt(text118.Substring(0, 4));
                            long num152 = (long)ClsPub.isInt(text118.Substring(4, 2));
                            long num153 = (long)ClsPub.isInt(text118.Substring(6, 2));
                            DateTime dateTime33 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num151.ToString(),
                        "-",
                        num152.ToString(),
                        "-",
                        num153.ToString()
                            }));
                            string text119 = sBarCodeNew.Remove(0, 26);
                            string text120 = text119.Remove(text119.Length - 10, 10);
                            ClsCN clsCN17 = new ClsCN();
                            DataSet Dss7;
                            Dss7 = clsCN17.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str34 + "'", "T_BD_MATERIAL");
                            if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                            {
                                DataSet Dss8;
                                Dss8 = clsCN17.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str34 + "'", "T_BD_MATERIAL");
                                str34 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                            }
                            else
                            {
                                str34 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                            }
                            DataSet dataSet58 = clsCN17.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str34 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                            long num154 = ClsPub.isLong(dataSet58.Tables[0].Rows[0]["HItemID"]);
                            string text121 = ClsPub.isStrNull(dataSet58.Tables[0].Rows[0]["HName"]);
                            string text122 = ClsPub.isStrNull(dataSet58.Tables[0].Rows[0]["HModel"]);
                            long num155 = (long)ClsPub.isInt(dataSet58.Tables[0].Rows[0]["HUnitID"]);
                            DataSet dataSet59 = clsCN17.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                            string str35 = ClsPub.isStrNull(dataSet59.Tables[0].Rows[0]["HNumber"]);
                            text = str35 + num154.ToString() + text120 + "#" + num150;
                            text1 = str35 + num154.ToString() + text120;
                            DateTime dateTime34 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num147.ToString(),
                        "-",
                        num148.ToString(),
                        "-",
                        num149.ToString()
                            }));
                            DataSet dataSet60 = clsCN17.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                            bool flag41 = dataSet60.Tables[0].Rows.Count > 0;
                            if (!flag41)
                            {
                                string billCode17 = "85";
                                long num156 = ClsPub.CreateBillID_Prod(billCode17, ref ClsPub.sExeReturnInfo);
                                long num157 = 0L;
                                clsCN17.RunProc(string.Concat(new string[]
                                {
                            "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                            text1,
                            "','批次条码',",
                            num154.ToString(),
                            ",",
                            num155.ToString(),
                            ",",
                            num150.ToString(),
                            ",'",
                            text120,
                            "',",
                            num157.ToString(),
                            ",0,'",
                            ClsPub.CurUserName,
                            "',getdate(),0,",
                            num150.ToString(),
                            ", 0,0,'','',0, 0,'',0,0,0,'',0,'','','",
                            dateTime34.ToShortDateString(),
                            "','",
                            dateTime33.ToShortDateString(),
                            "','',getdate(), ",
                            HOrgID.ToString(),
                            ",",
                            HOrgID.ToString(),
                            ",'',",
                            num156.ToString(),
                            ",1,0,0,0,'",
                            text121,
                            "','",
                            text122,
                            "','',0,'','',1)"
                                }));
                            }
                        }
                        else
                        {
                            string str36 = sBarCodeNew.Substring(0, 10);
                            string text123 = "20" + sBarCodeNew.Substring(10, 6);
                            long num158 = (long)ClsPub.isInt(text123.Substring(0, 4));
                            long num159 = (long)ClsPub.isInt(text123.Substring(4, 2));
                            long num160 = (long)ClsPub.isInt(text123.Substring(6, 2));
                            long num161 = (long)ClsPub.isInt(sBarCodeNew.Remove(0, sBarCodeNew.Length - 3));
                            string text124 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 9);
                            string text125 = "20" + text124.Substring(0, 6);
                            long num162 = (long)ClsPub.isInt(text125.Substring(0, 4));
                            long num163 = (long)ClsPub.isInt(text125.Substring(4, 2));
                            long num164 = (long)ClsPub.isInt(text125.Substring(6, 2));
                            DateTime dateTime35 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num162.ToString(),
                        "-",
                        num163.ToString(),
                        "-",
                        num164.ToString()
                            }));
                            string text126 = sBarCodeNew.Remove(0, 16);
                            string text127 = text126.Remove(text126.Length - 9, 9);
                            ClsCN clsCN18 = new ClsCN();
                            DataSet Dss7;
                            Dss7 = clsCN18.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str36 + "'", "T_BD_MATERIAL");
                            if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                            {
                                DataSet Dss8;
                                Dss8 = clsCN18.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str36 + "'", "T_BD_MATERIAL");
                                str36 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                            }
                            else
                            {
                                str36 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                            }
                            DataSet dataSet61 = clsCN18.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str36 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                            long num165 = ClsPub.isLong(dataSet61.Tables[0].Rows[0]["HItemID"]);
                            string text128 = ClsPub.isStrNull(dataSet61.Tables[0].Rows[0]["HName"]);
                            string text129 = ClsPub.isStrNull(dataSet61.Tables[0].Rows[0]["HModel"]);
                            long num166 = (long)ClsPub.isInt(dataSet61.Tables[0].Rows[0]["HUnitID"]);
                            DataSet dataSet62 = clsCN18.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                            string str37 = ClsPub.isStrNull(dataSet62.Tables[0].Rows[0]["HNumber"]);
                            text = str37 + num165.ToString() + text127 + "#" + num161;
                            text1 = str37 + num165.ToString() + text127;
                            DateTime dateTime36 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num158.ToString(),
                        "-",
                        num159.ToString(),
                        "-",
                        num160.ToString()
                            }));
                            DataSet dataSet63 = clsCN18.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                            bool flag42 = dataSet63.Tables[0].Rows.Count > 0;
                            if (!flag42)
                            {
                                string billCode18 = "85";
                                long num167 = ClsPub.CreateBillID_Prod(billCode18, ref ClsPub.sExeReturnInfo);
                                long num168 = 0L;
                                clsCN18.RunProc(string.Concat(new string[]
                                {
                            "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                            text1,
                            "','批次条码',",
                            num165.ToString(),
                            ",",
                            num166.ToString(),
                            ",",
                            num161.ToString(),
                            ",'",
                            text127,
                            "',",
                            num168.ToString(),
                            ",0,'",
                            ClsPub.CurUserName,
                            "',getdate(),0,",
                            num161.ToString(),
                            ", 0,0,'','3714',0, 0,'',0,0,0,'',0,'','','",
                            dateTime36.ToShortDateString(),
                            "','",
                            dateTime35.ToShortDateString(),
                            "','',getdate(), ",
                            HOrgID.ToString(),
                            ",",
                            HOrgID.ToString(),
                            ",'',",
                            num167.ToString(),
                            ",1,0,0,0,'",
                            text128,
                            "','",
                            text129,
                            "','',0,'','',1)"
                                }));
                            }
                        }
                    }
                }
                bool flag43 = HBillType == "1205";
                if (flag43)
                {
                    bool flag44 = sBarCodeNew.Contains("@");
                    if (flag44)
                    {
                        string[] array7 = sBarCodeNew.Split(new char[]
                        {
                    '@'
                        });
                        string str38 = array7[0];
                        long num169 = (long)ClsPub.isInt(array7[4]);
                        string text130 = array7[6];
                        DateTime dateTime37 = ClsPub.isDate(array7[3]);
                        DateTime dateTime38 = ClsPub.isDate(array7[5]);
                        string text131 = ClsPub.isStrNull(array7[8]);
                        ClsCN clsCN19 = new ClsCN();
                        DataSet dataSet64 = clsCN19.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                        string str39 = ClsPub.isStrNull(dataSet64.Tables[0].Rows[0]["HNumber"]);
                        DataSet Dss7;
                        Dss7 = clsCN19.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str38 + "'", "T_BD_MATERIAL");
                        if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                        {
                            DataSet Dss8;
                            Dss8 = clsCN19.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str38 + "'", "T_BD_MATERIAL");
                            str38 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                        }
                        else
                        {
                            str38 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                        }
                        DataSet dataSet65 = clsCN19.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str38 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                        long num170 = ClsPub.isLong(dataSet65.Tables[0].Rows[0]["HItemID"]);
                        string text132 = ClsPub.isStrNull(dataSet65.Tables[0].Rows[0]["HName"]);
                        string text133 = ClsPub.isStrNull(dataSet65.Tables[0].Rows[0]["HModel"]);
                        long num171 = (long)ClsPub.isInt(dataSet65.Tables[0].Rows[0]["HUnitID"]);
                        text = str39 + num170.ToString() + text130 + "#" + num169;
                        text1 = str39 + num170.ToString() + text130;
                        DataSet dataSet66 = clsCN19.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                        bool flag45 = dataSet66.Tables[0].Rows.Count > 0;
                        if (!flag45)
                        {
                            string billCode19 = "85";
                            long num172 = ClsPub.CreateBillID_Prod(billCode19, ref ClsPub.sExeReturnInfo);
                            long num173 = 0L;
                            clsCN19.RunProc(string.Concat(new string[]
                            {
                        "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                        text1,
                        "','批次条码',",
                        num170.ToString(),
                        ",",
                        num171.ToString(),
                        ",",
                        num169.ToString(),
                        ",'",
                        text130,
                        "',",
                        num173.ToString(),
                        ",0,'",
                        ClsPub.CurUserName,
                        "',getdate(),0,",
                        num169.ToString(),
                        ", 0,0,'','1103',0, 0,'',0,0,0,'',0,'','','",
                        dateTime37.ToShortDateString(),
                        "','",
                        dateTime38.ToShortDateString(),
                        "','',getdate(), ",
                        HOrgID.ToString(),
                        ",",
                        HOrgID.ToString(),
                        ",'',",
                        num172.ToString(),
                        ",1,0,0,0,'",
                        text132,
                        "','",
                        text133,
                        "','',0,'','',1)"
                            }));
                        }
                    }
                    else
                    {
                        string text134 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 4);
                        string text135 = text134.Substring(0, 1);
                        bool flag46 = text135.Contains("W") || text135.Contains("N");
                        if (flag46)
                        {
                            string text136 = sBarCodeNew.Substring(0, 10);
                            string str40 = sBarCodeNew.Substring(10, 10);
                            string text137 = "20" + sBarCodeNew.Substring(20, 6);
                            long num174 = (long)ClsPub.isInt(text137.Substring(0, 4));
                            long num175 = (long)ClsPub.isInt(text137.Substring(4, 2));
                            long num176 = (long)ClsPub.isInt(text137.Substring(6, 2));
                            long num177 = (long)ClsPub.isInt(sBarCodeNew.Remove(0, sBarCodeNew.Length - 3));
                            string text138 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 10);
                            string text139 = "20" + text138.Substring(0, 6);
                            long num178 = (long)ClsPub.isInt(text139.Substring(0, 4));
                            long num179 = (long)ClsPub.isInt(text139.Substring(4, 2));
                            long num180 = (long)ClsPub.isInt(text139.Substring(6, 2));
                            DateTime dateTime39 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num178.ToString(),
                        "-",
                        num179.ToString(),
                        "-",
                        num180.ToString()
                            }));
                            string text140 = sBarCodeNew.Remove(0, 26);
                            string text141 = text140.Remove(text140.Length - 10, 10);
                            ClsCN clsCN20 = new ClsCN();
                            DataSet Dss7;
                            Dss7 = clsCN20.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str40 + "'", "T_BD_MATERIAL");
                            if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                            {
                                DataSet Dss8;
                                Dss8 = clsCN20.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str40 + "'", "T_BD_MATERIAL");
                                str40 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                            }
                            else
                            {
                                str40 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                            }
                            DataSet dataSet67 = clsCN20.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str40 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                            long num181 = ClsPub.isLong(dataSet67.Tables[0].Rows[0]["HItemID"]);
                            string text142 = ClsPub.isStrNull(dataSet67.Tables[0].Rows[0]["HName"]);
                            string text143 = ClsPub.isStrNull(dataSet67.Tables[0].Rows[0]["HModel"]);
                            long num182 = (long)ClsPub.isInt(dataSet67.Tables[0].Rows[0]["HUnitID"]);
                            DataSet dataSet68 = clsCN20.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                            string str41 = ClsPub.isStrNull(dataSet68.Tables[0].Rows[0]["HNumber"]);
                            text = str41 + num181.ToString() + text141 + "#" + num177;
                            text1 = str41 + num181.ToString() + text141;
                            DateTime dateTime40 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num174.ToString(),
                        "-",
                        num175.ToString(),
                        "-",
                        num176.ToString()
                            }));
                            DataSet dataSet69 = clsCN20.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                            bool flag47 = dataSet69.Tables[0].Rows.Count > 0;
                            if (!flag47)
                            {
                                string billCode20 = "85";
                                long num183 = ClsPub.CreateBillID_Prod(billCode20, ref ClsPub.sExeReturnInfo);
                                long num184 = 0L;
                                clsCN20.RunProc(string.Concat(new string[]
                                {
                            "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                            text1,
                            "','批次条码',",
                            num181.ToString(),
                            ",",
                            num182.ToString(),
                            ",",
                            num177.ToString(),
                            ",'",
                            text141,
                            "',",
                            num184.ToString(),
                            ",0,'",
                            ClsPub.CurUserName,
                            "',getdate(),0,",
                            num177.ToString(),
                            ", 0,0,'','',0, 0,'',0,0,0,'',0,'','','",
                            dateTime40.ToShortDateString(),
                            "','",
                            dateTime39.ToShortDateString(),
                            "','',getdate(), ",
                            HOrgID.ToString(),
                            ",",
                            HOrgID.ToString(),
                            ",'',",
                            num183.ToString(),
                            ",1,0,0,0,'",
                            text142,
                            "','",
                            text143,
                            "','',0,'','',1)"
                                }));
                            }
                        }
                        else
                        {
                            string str42 = sBarCodeNew.Substring(0, 10);
                            string text144 = "20" + sBarCodeNew.Substring(10, 6);
                            long num185 = (long)ClsPub.isInt(text144.Substring(0, 4));
                            long num186 = (long)ClsPub.isInt(text144.Substring(4, 2));
                            long num187 = (long)ClsPub.isInt(text144.Substring(6, 2));
                            long num188 = (long)ClsPub.isInt(sBarCodeNew.Remove(0, sBarCodeNew.Length - 3));
                            string text145 = sBarCodeNew.Remove(0, sBarCodeNew.Length - 9);
                            string text146 = "20" + text145.Substring(0, 6);
                            long num189 = (long)ClsPub.isInt(text146.Substring(0, 4));
                            long num190 = (long)ClsPub.isInt(text146.Substring(4, 2));
                            long num191 = (long)ClsPub.isInt(text146.Substring(6, 2));
                            DateTime dateTime41 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num189.ToString(),
                        "-",
                        num190.ToString(),
                        "-",
                        num191.ToString()
                            }));
                            string text147 = sBarCodeNew.Remove(0, 16);
                            string text148 = text147.Remove(text147.Length - 9, 9);
                            ClsCN clsCN21 = new ClsCN();
                            DataSet Dss7;
                            Dss7 = clsCN21.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + str42 + "'", "T_BD_MATERIAL");
                            if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                            {
                                DataSet Dss8;
                                Dss8 = clsCN21.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + str42 + "'", "T_BD_MATERIAL");
                                str42 = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                            }
                            else
                            {
                                str42 = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                            }
                            DataSet dataSet70 = clsCN21.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + str42 + "' and  huseorgid = " + HOrgID.ToString(), "Gy_Material");
                            long num192 = ClsPub.isLong(dataSet70.Tables[0].Rows[0]["HItemID"]);
                            string text149 = ClsPub.isStrNull(dataSet70.Tables[0].Rows[0]["HName"]);
                            string text150 = ClsPub.isStrNull(dataSet70.Tables[0].Rows[0]["HModel"]);
                            long num193 = (long)ClsPub.isInt(dataSet70.Tables[0].Rows[0]["HUnitID"]);
                            DataSet dataSet71 = clsCN21.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID.ToString(), "h_v_CLD_ORGANIZATIONSList");
                            string str43 = ClsPub.isStrNull(dataSet71.Tables[0].Rows[0]["HNumber"]);
                            text = str43 + num192.ToString() + text148 + "#" + num188;
                            text1 = str43 + num192.ToString() + text148;
                            DateTime dateTime42 = ClsPub.isDate(string.Concat(new string[]
                            {
                        num185.ToString(),
                        "-",
                        num186.ToString(),
                        "-",
                        num187.ToString()
                            }));
                            DataSet dataSet72 = clsCN21.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + text1 + "'", "Gy_BarCodeBill");
                            bool flag48 = dataSet72.Tables[0].Rows.Count > 0;
                            if (!flag48)
                            {
                                string billCode21 = "85";
                                long num194 = ClsPub.CreateBillID_Prod(billCode21, ref ClsPub.sExeReturnInfo);
                                long num195 = 0L;
                                clsCN21.RunProc(string.Concat(new string[]
                                {
                            "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty ,HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark ,HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate ,HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID ,HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID ,HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag ) values ('",
                            text1,
                            "','批次条码',",
                            num192.ToString(),
                            ",",
                            num193.ToString(),
                            ",",
                            num188.ToString(),
                            ",'",
                            text148,
                            "',",
                            num195.ToString(),
                            ",0,'",
                            ClsPub.CurUserName,
                            "',getdate(),0,",
                            num188.ToString(),
                            ", 0,0,'','3714',0, 0,'',0,0,0,'',0,'','','",
                            dateTime42.ToShortDateString(),
                            "','",
                            dateTime41.ToShortDateString(),
                            "','',getdate(), ",
                            HOrgID.ToString(),
                            ",",
                            HOrgID.ToString(),
                            ",'',",
                            num194.ToString(),
                            ",1,0,0,0,'",
                            text149,
                            "','",
                            text150,
                            "','',0,'','',1)"
                                }));
                            }
                        }
                    }
                }
                 result = text;
            }
            catch (Exception ex)
            {
                result = ex.Message + ";" + ex.StackTrace;
            }
            return result;
        }
@@ -417,12 +3375,230 @@
        [Route("Kf_QCStockInCheckBill_Fast/BarCode_Json")]
        [HttpGet]
        public object BarCode_Json(string HBarCode)
        public object BarCode_Json(string HBarCode,Int64 HOrgID)
        {
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                ds = oCN.RunProcReturn("select * from h_v_QCStockInCheckBill_Json where  条码编号 ='" + HBarCode.ToString() + "'" , "h_v_QCStockInCheckBill_Json");
                //string[] sArray = HBarCode.Split('@');
                //string HMaterNumber = "";
                //HMaterNumber = sArray[0];
                ////采购订单号
                //string HPOOrderBillNo = "";
                //HPOOrderBillNo = ClsPub.isStrNull(sArray[8]);
                //Int64 HMaterID = 0;
                //DataSet Dss1;
                //Dss1 = oCn.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
                //HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
                ////根据物料 + 批次  +   采购订单号 找到对应的收料通知单号
                //DataSet Dss2;
                //Dss2 = oCn.RunProcReturn(" select fid,FMATERIALID,FENTRYID,FBILLNO from h_v_RECEIVEQuery where FSRCBILLNO= '" + HPOOrderBillNo + "' and  FMATERIALID = " + HMaterID, "h_v_RECEIVEQuery");
                //HMaterID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["FMATERIALID"]);
                //string HSourceBillNo = Pub_Class.ClsPub.isStrNull(Dss2.Tables[0].Rows[0]["FBILLNO"]);
                string HTM = "";
                string[] sArray = HBarCode.Split('@');
                string HMaterNumber = "";
                HMaterNumber = sArray[0];
                Int64 HQty = 0;
                HQty = ClsPub.isInt(sArray[4]);
                string HBarchNo = "";
                HBarchNo = sArray[6];
                DateTime HSCRQ = ClsPub.isDate(sArray[3]);
                DateTime HYXQZ = ClsPub.isDate(sArray[5]);
                //采购订单号
                string HPOOrderBillNo = "";
                HPOOrderBillNo = ClsPub.isStrNull(sArray[8]);
                Int64 HMaterID = 0;
                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                DataSet Dss;
                Dss = oCn.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
                string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
                DataSet Dss1;
                Dss1 = oCn.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
                HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
                string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
                string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
                Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
                HTM = HOrgNumber + HMaterID + HBarchNo;
                //如果条码档案不存在  进行存入条码档案的动作
                //根据物料 + 批次  +   采购订单号 找到对应的收料通知单号
                DataSet Dss2;
                Dss2 = oCn.RunProcReturn(" select fid,FMATERIALID,FENTRYID,FBILLNO from h_v_RECEIVEQuery where FSRCBILLNO= '" + HPOOrderBillNo + "' and  FMATERIALID = " + HMaterID, "h_v_RECEIVEQuery");
                HMaterID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["FMATERIALID"]);
                Int64 HSourceInterID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["fid"]);
                Int64 HSourceEntryID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["FENTRYID"]);
                string HSourceBillNo = Pub_Class.ClsPub.isStrNull(Dss2.Tables[0].Rows[0]["FBILLNO"]);
                //判断条码档案是否存在该条码
                //如果存在 再判断扫码临时表是否存在该条码
                //如果不存在  进行扫源单的方法
                DataSet Dss5;
                Dss5 = oCn.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
                if (Dss5.Tables[0].Rows.Count > 0)
                {
                    DataSet ds;
                    ds = oCN.RunProcReturn("select * from h_v_QCStockInCheckBill_Json where  HSourceBillNo ='" + HSourceBillNo.ToString() + "'", "h_v_QCStockInCheckBill_Json");
                    if (ds == null || ds.Tables[0].Rows.Count <= 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "没有返回任何记录!";
                        objJsonResult.data = null;
                        return objJsonResult;
                        //DBUtility.ClsPub.MessageBeep((int)DBUtility.ClsPub.BeepType.Warning);
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "获取信息成功!";
                        objJsonResult.data = ds.Tables[0];
                        return objJsonResult;
                    }
                }
                else
                {
                    string ModName = "85";
                    var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
                    Int64 HSupID = 0;
                    oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
                                       ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
                                       ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
                                       ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
                                       ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
                                       ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
                                       ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
                                       ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
                                       ") values ("
                                       + "'" + HTM + "','批次条码'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
                                       + ",'" + HBarchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
                                       + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo.ToString() + "','1103',0"
                                       + ", 0,'',0,0,0,''"
                                       + ",0,'','','" + HSCRQ.ToShortDateString() + "','" + HYXQZ.ToShortDateString() + "','',getdate()"
                                       + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
                                       + ",0,0,0"
                                       + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
                    DataSet ds;
                    ds = oCN.RunProcReturn("select * from h_v_QCStockInCheckBill_Json where  HSourceBillNo ='" + HSourceBillNo.ToString() + "'", "h_v_QCStockInCheckBill_Json");
                    if (ds == null || ds.Tables[0].Rows.Count <= 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "没有返回任何记录!";
                        objJsonResult.data = null;
                        return objJsonResult;
                        //DBUtility.ClsPub.MessageBeep((int)DBUtility.ClsPub.BeepType.Warning);
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "获取信息成功!";
                        objJsonResult.data = ds.Tables[0];
                        return objJsonResult;
                    }
                }
                //ds = oCN.RunProcReturn("select * from h_v_QCStockInCheckBill_Json where  条码编号 ='" + HBarCode.ToString() + "'", "h_v_QCStockInCheckBill_Json");
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        [Route("Kf_SCStockInCheckBill_Fast/BarCode_Json1")]
        [HttpGet]
        public object BarCode_Json1(string HBarCode,Int64 HOrgID)
        {
            try
            {
                string HMaterNumber = "";
                string HSCRQ = "";
                string HFour = HBarCode.Remove(0, HBarCode.Length - 4);
                string HZM = HFour.Substring(0, 1);
                string HBatchNo_Old = "";
                string HBatchNo = "";
                Int64 Year = 0;
                Int64 Month = 0;
                Int64 Day = 0;
                if (HZM.Contains("W") || HZM.Contains("N"))
                {
                    string HOldNumber = HBarCode.Substring(0, 10);   //商品码 不是物料编码
                    HMaterNumber = HBarCode.Substring(10, 10);    //物料编码
                    HSCRQ = "20" + HBarCode.Substring(20, 6);    //生产日期
                     Year = ClsPub.isInt(HSCRQ.Substring(0, 4));  //年
                     Month = ClsPub.isInt(HSCRQ.Substring(4, 2));  //月
                     Day = ClsPub.isInt(HSCRQ.Substring(6, 2));     //日
                     HBatchNo_Old = HBarCode.Remove(0, 26);
                     HBatchNo = HBatchNo_Old.Remove(HBatchNo_Old.Length - 10, 10);
                }
                else
                {
                    HMaterNumber = HBarCode.Substring(0,10);
                    HSCRQ = "20" + HBarCode.Substring(10, 6);    //生产日期
                     Year = ClsPub.isInt(HSCRQ.Substring(0, 4));  //年
                     Month = ClsPub.isInt(HSCRQ.Substring(4, 2));  //月
                     Day = ClsPub.isInt(HSCRQ.Substring(6, 2));     //日
                     HBatchNo_Old = HBarCode.Remove(0, 16);
                     HBatchNo = HBatchNo_Old.Remove(HBatchNo_Old.Length - 9, 9);
                }
                //根据拆分的物料ID +  批次 +  生产日期 能找到唯一的工序汇报单
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                DataSet ds;
                Int64 HMaterID = 0;
                DataSet Dss1;
                Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
                HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
                string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
                string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
                Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
                //DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
                //Int64 HQty = 0;
                //HQty = ClsPub.isInt(HBarCode.Substring(33, 3));
                ds = oCN.RunProcReturn("select * from h_v_SCStockInCheckBill_Json where  HYear =" + Year.ToString() + "and HMonth = " + Month.ToString() + "and HDay = " + Day.ToString() + " and HMaterID = " + HMaterID.ToString() + "and 批次 = '" + HBatchNo.ToString() + "'", "h_v_SCStockInCheckBill_Json");
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                {
@@ -745,8 +3921,8 @@
                List<Model.ClsKf_POStockInBillMain> lsmain = new List<Model.ClsKf_POStockInBillMain>();
                ListModels oListModels = new ListModels();
                lsmain = oListModels.getPOStockInBillMainByJson(msg1);
                lsmain[0].HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
                lsmain[0].HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));
                //lsmain[0].HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
                //lsmain[0].HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));
                string sSourceBillType = lsmain[0].HBillType;
                WebAPI.WebS.ClsKf_POStockInBillMain websLsmain = new WebS.ClsKf_POStockInBillMain();
@@ -778,7 +3954,8 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "成功!单据号为:";
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //成功!
                    //objJsonResult.Message = "成功!单据号为:";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -786,7 +3963,8 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "上传失败!" + DBUtility.ClsPub.sErrInfo;
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //失败!
                    //objJsonResult.Message = "上传失败!" + DBUtility.ClsPub.sErrInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -800,6 +3978,70 @@
                return objJsonResult;
            }
        }
        //[Route("POStockInBill/set_SavePOStockInBill_Json")]
        //[HttpPost]
        //public object set_SavePOStockInBill_Json([FromBody] JObject oMain)
        //{
        //    string text = oMain["oMain"].ToString();
        //    string jsonString = text.ToString();
        //    object result;
        //    try
        //    {
        //        List<ClsKf_POStockInBillMain> list = new List<ClsKf_POStockInBillMain>();
        //        ListModels listModels = new ListModels();
        //        list = listModels.getPOStockInBillMainByJson(jsonString);
        //        list[0].HYear = ClsPub.isLong(DateTime.Now.Year);
        //        list[0].HDate = ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));
        //        string hbillType = list[0].HBillType;
        //        WebAPI.WebS.ClsKf_POStockInBillMain clsKf_POStockInBillMain = new WebAPI.WebS.ClsKf_POStockInBillMain();
        //        clsKf_POStockInBillMain.HInterID = list[0].HInterID;
        //        clsKf_POStockInBillMain.HBillNo = list[0].HBillNo;
        //        clsKf_POStockInBillMain.HBillType = "1201";
        //        clsKf_POStockInBillMain.HDate = list[0].HDate;
        //        clsKf_POStockInBillMain.HDeptID = list[0].HDeptID;
        //        clsKf_POStockInBillMain.HWHID = list[0].HWHID;
        //        clsKf_POStockInBillMain.HSCWHID = 0L;
        //        clsKf_POStockInBillMain.HSupID = list[0].HSupID;
        //        clsKf_POStockInBillMain.HKeeperID = list[0].HKeeperID;
        //        clsKf_POStockInBillMain.HSecManagerID = list[0].HSecManagerID;
        //        clsKf_POStockInBillMain.HEmpID = 0L;
        //        clsKf_POStockInBillMain.HManagerID = 0L;
        //        clsKf_POStockInBillMain.HBillerID = list[0].HBillerID;
        //        clsKf_POStockInBillMain.HRemark = "";
        //        clsKf_POStockInBillMain.HInnerBillNo = "";
        //        clsKf_POStockInBillMain.HRedBlueFlag = false;
        //        clsKf_POStockInBillMain.HMainSourceBillType = list[0].HBillType;
        //        clsKf_POStockInBillMain.HExplanation = list[0].HExplanation;
        //        bool flag = this.webserver.set_SavePOStockInBill_New(clsKf_POStockInBillMain, hbillType, ref ClsPub.sErrInfo);
        //        if (flag)
        //        {
        //            this.objJsonResult.code = "0";
        //            this.objJsonResult.count = 1;
        //            this.objJsonResult.Message = "成功!单据号为:";
        //            this.objJsonResult.data = null;
        //            result = this.objJsonResult;
        //        }
        //        else
        //        {
        //            this.objJsonResult.code = "0";
        //            this.objJsonResult.count = 0;
        //            this.objJsonResult.Message = "上传失败!" + ClsPub.sErrInfo;
        //            this.objJsonResult.data = null;
        //            result = this.objJsonResult;
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        this.objJsonResult.code = "0";
        //        this.objJsonResult.count = 0;
        //        this.objJsonResult.Message = "上传失败!" + ex.ToString();
        //        this.objJsonResult.data = null;
        //        result = this.objJsonResult;
        //    }
        //    return result;
        //}
        /// <summary>
@@ -1042,34 +4284,432 @@
        }
        #region 到货确认
        [Route("POStockInBillList/Get_ReciveBill")]
        [Route("POStockInBillList/AuditPOInStockBillPost_AR")]
        [HttpPost]
        public object AuditPOInStockBillPost_AR([FromBody] JObject msg)
        {
            object result;
            try
            {
                string text = msg["msg"].ToString();
                text = text.Replace("\\", "");
                text = text.Replace("\n", "");
                List<ReciveBill_FastModel> list = JsonConvert.DeserializeObject<List<ReciveBill_FastModel>>(text);
                ClsCg_POInStockBill clsCg_POInStockBill = new ClsCg_POInStockBill();
                string hinterID = list[0].HInterID;
                string text2 = list[0].FID;
                string singleSystemParameter = this.oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref ClsPub.sExeReturnInfo);
                string singleSystemParameter2 = this.oSystemParameter.GetSingleSystemParameter("Cg_POInStockBill_ErpAduit", ref ClsPub.sExeReturnInfo);
                string singleSystemParameter3 = this.oSystemParameter.GetSingleSystemParameter("Cg_POInStockBill_BarCodeCtl", ref ClsPub.sExeReturnInfo);
                string configKey = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "DataBaseName");
                string empty = string.Empty;
                this.oCn.BeginTran();
                this.oCn.Commit();
                bool flag = singleSystemParameter.Contains("安瑞");
                bool flag2 = flag;
                bool flag3 = flag2;
                if (flag3)
                {
                    DataSet dataSet = this.oCn.RunProcReturn("exec h_p_ReceiveBill_Fast " + hinterID, "h_p_ReceiveBill_Fast");
                    DataRow dataRow = dataSet.Tables[0].Rows[0];
                    if (dataSet.Tables[0].Rows.Count == 1 && dataSet.Tables[0].Rows[0]["FRECEIVENumber"].ToString() == "0")
                    {
                        this.objJsonResult.code = "0";
                        this.objJsonResult.count = 0;
                        this.objJsonResult.Message = "存在多个采购订单单据类型,不允许提交!";
                        this.objJsonResult.data = null;
                        return this.objJsonResult;
                    }
                    bool flag4 = dataSet.Tables[0].Rows.Count <= 0;
                    bool flag5 = flag4;
                    bool flag6 = flag5;
                    if (flag6)
                    {
                        this.objJsonResult.code = "0";
                        this.objJsonResult.count = 0;
                        this.objJsonResult.Message = "未找到对应的单据";
                        this.objJsonResult.data = null;
                        return this.objJsonResult;
                    }
                    bool flag7 = dataSet.Tables[0].Rows.Count >= 0;
                    bool flag8 = flag7;
                    bool flag9 = flag8;
                    if (flag9)
                    {
                        JObject jobject = new JObject();
                        string text3 = "SLD01_SYS";
                        string text4 = "CG";
                        bool flag10 = dataRow["FTYPENAME"].ToString().Contains("委外");
                        bool flag11 = flag10;
                        bool flag12 = flag11;
                        if (flag12)
                        {
                            text3 = "SLD03_SYS";
                            text4 = "WW";
                        }
                        bool flag13 = dataRow["FTYPENAME"].ToString().Contains("资产");
                        bool flag14 = flag13;
                        bool flag15 = flag14;
                        if (flag15)
                        {
                            text3 = "SLD04_SYS";
                            text4 = "ZCCG";
                        }
                        JObject jobject2 = jobject;
                        string text5 = "FBILLTYPEID";
                        JObject jobject3 = new JObject();
                        jobject3["Fnumber"] = text3;
                        jobject2.Add(text5, jobject3);
                        jobject.Add("FBusinessType", text4);
                        jobject.Add("FBILLNO", dataRow["HBillNo"].ToString());
                        jobject.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd"));
                        JObject jobject4 = jobject;
                        string text6 = "FStockOrgId";
                        JObject jobject5 = new JObject();
                        jobject5["Fnumber"] = dataRow["FRECEIVENUMBER"].ToString();
                        jobject4.Add(text6, jobject5);
                        JObject jobject6 = jobject;
                        string text7 = "FPurOrgId";
                        JObject jobject7 = new JObject();
                        jobject7["Fnumber"] = dataRow["FPURCHASEORGNUMBER"].ToString();
                        jobject6.Add(text7, jobject7);
                        JObject jobject8 = jobject;
                        string text8 = "FSupplierId";
                        JObject jobject9 = new JObject();
                        jobject9["Fnumber"] = dataRow["FSUPPLIERNUMBER"].ToString();
                        jobject8.Add(text8, jobject9);
                        JObject jobject10 = jobject;
                        string text9 = "FPURCHASERID";
                        JObject jobject11 = new JObject();
                        jobject11["Fnumber"] = dataRow["FPURCHASERNUMBER"].ToString();
                        jobject10.Add(text9, jobject11);
                        jobject.Add("FOwnerTypeIdHead", "BD_Supplier");
                        JObject jobject12 = jobject;
                        string text10 = "FOwnerIdHead";
                        JObject jobject13 = new JObject();
                        jobject13["Fnumber"] = dataRow["FSUPPLIERNUMBER"].ToString();
                        jobject12.Add(text10, jobject13);
                        JObject jobject14 = jobject;
                        string text11 = "F_RYMA_Assistant";
                        JObject jobject15 = new JObject();
                        jobject15["Fnumber"] = dataRow["F_UJDY_Assistant"].ToString();
                        jobject14.Add(text11, jobject15);
                        JArray jarray = new JArray();
                        foreach (object obj in dataSet.Tables[0].Rows)
                        {
                            DataRow dataRow2 = (DataRow)obj;
                            JObject jobject16 = new JObject();
                            JObject jobject17 = jobject16;
                            string text12 = "FMaterialId";
                            JObject jobject18 = new JObject();
                            jobject18["Fnumber"] = dataRow2["FMATERIALNUMBER"].ToString();
                            jobject17.Add(text12, jobject18);
                            JObject jobject19 = jobject16;
                            string text13 = "FUnitID";
                            JObject jobject20 = new JObject();
                            jobject20["Fnumber"] = dataRow2["FUNITNUMBER"].ToString();
                            jobject19.Add(text13, jobject20);
                            jobject16.Add("FPreDeliveryDate", DateTime.Now.ToString("yyyy-MM-dd"));
                            JObject jobject21 = jobject16;
                            string text14 = "FPriceUnitId";
                            JObject jobject22 = new JObject();
                            jobject22["Fnumber"] = dataRow2["FUNITNUMBER"].ToString();
                            jobject21.Add(text14, jobject22);
                            JObject jobject23 = jobject16;
                            string text15 = "FStockUnitID";
                            JObject jobject24 = new JObject();
                            jobject24["Fnumber"] = dataRow2["FUNITNUMBER"].ToString();
                            jobject23.Add(text15, jobject24);
                            JObject jobject25 = jobject16;
                            string text16 = "FStockID";
                            JObject jobject26 = new JObject();
                            jobject26["Fnumber"] = "BJCK-SH.01.005";
                            jobject25.Add(text16, jobject26);
                            jobject16.Add("FActReceiveQty", Convert.ToDecimal(dataRow2["HQTY"]));
                            jobject16.Add("FOwnerTypeId", "BD_OwnerOrg");
                            JObject jobject27 = jobject16;
                            string text17 = "FOwnerID";
                            JObject jobject28 = new JObject();
                            jobject28["Fnumber"] = dataRow["FPURCHASEORGNUMBER"].ToString();
                            jobject27.Add(text17, jobject28);
                            jobject16.Add("FSrcId", dataRow2["FID"].ToString());
                            jobject16.Add("FSRCFORMID", "PUR_PurchaseOrder");
                            jobject16.Add("FSrcBillNo", dataRow2["FBILLNO"].ToString());
                            jobject16.Add("FSRCENTRYID", dataRow2["FENTRYID"].ToString());
                            jobject16.Add("FORDERBILLNO", dataRow2["FBILLNO"].ToString());
                            jobject16.Add("FPOORDERENTRYID", dataRow2["FENTRYID"].ToString());
                            jobject16.Add("FGiveAway", dataRow2["FGIVEAWAY"].ToString());//是否赠品
                            //jobject16.Add("FPrice", dataRow2["FPRICE"].ToString());
                            //jobject16.Add("FTaxPrice", dataRow2["FTAXPRICE"].ToString());
                            //jobject16.Add("FEntryTaxRate", dataRow2["FTAXRATE"].ToString());
                            JObject jobject29 = jobject16;
                            string text18 = "FLOT";
                            JObject jobject30 = new JObject();
                            jobject30["Fnumber"] = dataRow2["hbatchno"].ToString();
                            jobject29.Add(text18, jobject30);
                            jobject16.Add("FLOT_TEXT", dataRow2["hbatchno"].ToString());
                            jobject16.Add("FProduceDate", dataRow2["HBeginDate"].ToString());
                            jobject16.Add("FExpiryDate", dataRow2["HEndDate"].ToString());
                            jobject16.Add("F_BGP_ShouldQty", dataRow2["F_BGP_ShouldQty"].ToString());
                            jobject16.Add("FPrice", dataRow2["FPRICE"].ToString());
                            jobject16.Add("FTaxPrice", dataRow2["FTAXPRICE"].ToString());
                            jobject16.Add("FEntryTaxRate", dataRow2["FTAXRATE"].ToString());
                            //jobject16.Add("F_UJDY_Qty", dataRow2["HQTY"].ToString());
                            JObject jobject31 = jobject16;
                            string text19 = "FDetailEntity_Link";
                            JArray jarray2 = new JArray();
                            JObject jobject32 = new JObject();
                            jobject32.Add("FDetailEntity_Link_FRULEID", "PUR_PurchaseOrder-PUR_ReceiveBill");
                            jobject32.Add("FDetailEntity_Link_FSTableName", "t_PUR_POOrderEntry");
                            jobject32.Add("FDetailEntity_Link_FSBillId", dataRow2["FID"].ToString());
                            jobject32.Add("FDetailEntity_Link_FSId", dataRow2["FEntryID"].ToString());
                            jarray2.Add(jobject32);
                            jobject31.Add(text19, jarray2);
                            jarray.Add(jobject16);
                        }
                        jobject.Add("FDetailEntity", jarray);
                        JObject jobject33 = new JObject();
                        JObject jobject34 = jobject33;
                        string text20 = "FSettleOrgId";
                        JObject jobject35 = new JObject();
                        jobject35["Fnumber"] = dataRow["FSETTLEORGNUMBER"].ToString();
                        jobject34.Add(text20, jobject35);
                        JObject jobject36 = jobject33;
                        string text21 = "FSettleCurrId";
                        JObject jobject37 = new JObject();
                        jobject37["Fnumber"] = dataRow["FSETTLECURRNUMBER"].ToString();
                        jobject36.Add(text21, jobject37);
                        jobject33.Add("FPricePoint", 0);
                        jobject.Add("FinanceEntity ", jobject33);
                        JObject jobject38 = new JObject();
                        jobject38["Creator"] = "";
                        jobject38["NeedUpDateFields"] = new JArray();
                        jobject38["NeedReturnFields"] = new JArray();
                        jobject38["IsDeleteEntry"] = "false";
                        jobject38["SubSystemId"] = "";
                        jobject38["IsVerifyBaseDataField"] = "false";
                        jobject38["Model"] = jobject;
                        JObject jobject39 = jobject38;
                        string text22 = InvokeHelper.Login();
                        int num = Extensions.Value<int>(JObject.Parse(text22)["LoginResultType"]);
                        bool flag16 = num == 0;
                        bool flag17 = flag16;
                        bool flag18 = flag17;
                        if (flag18)
                        {
                            this.objJsonResult.code = "0";
                            this.objJsonResult.count = 0;
                            this.objJsonResult.Message = text22;
                            this.objJsonResult.data = null;
                            return this.objJsonResult;
                        }
                        string text23 = InvokeHelper.Save("PUR_ReceiveBill", jobject39.ToString());
                        bool flag19 = JObject.Parse(text23)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() == "TRUE";
                        bool flag20 = !flag19;
                        bool flag21 = flag20;
                        if (flag21)
                        {
                            this.objJsonResult.code = "0";
                            this.objJsonResult.count = 0;
                            this.objJsonResult.Message = text23;
                            this.objJsonResult.data = null;
                            return this.objJsonResult;
                        }
                        string text24 = JObject.Parse(text23)["Result"]["Number"].ToString();
                        text2 = JObject.Parse(text23)["Result"]["Id"].ToString();
                    }
                    else
                    {
                        LogService.Write("收料通知单审核无数据:" + empty, "Vlog", true);
                    }
                }
                else
                {
                    JObject jobject40 = new JObject();
                    jobject40.Add("Creator", "");
                    jobject40.Add("NeedUpDateFields", new JArray());
                    jobject40.Add("NeedReturnFields", new JArray());
                    jobject40.Add("IsDeleteEntry", "false");
                    jobject40.Add("SubSystemId", "");
                    jobject40.Add("IsVerifyBaseDataField", "");
                    JObject jobject41 = new JObject();
                    jobject41.Add("FID", text2);
                    JArray jarray3 = new JArray();
                    foreach (ReciveBill_FastModel reciveBill_FastModel in list)
                    {
                        bool flag22 = reciveBill_FastModel.HSQty == 0m;
                        bool flag23 = !flag22;
                        bool flag24 = flag23;
                        if (flag24)
                        {
                            JArray jarray4 = jarray3;
                            JObject jobject42 = new JObject();
                            jobject42.Add("FEntryID", reciveBill_FastModel.FEntryID);
                            jobject42.Add("FActReceiveQty ", reciveBill_FastModel.HSQty);
                            jarray4.Add(jobject42);
                        }
                    }
                    jobject41.Add("FDetailEntity", jarray3);
                    jobject40.Add("Model", jobject41);
                    string text25 = InvokeHelper.Login();
                    int num2 = Extensions.Value<int>(JObject.Parse(text25)["LoginResultType"]);
                    bool flag25 = num2 <= 0;
                    bool flag26 = flag25;
                    bool flag27 = flag26;
                    if (flag27)
                    {
                        this.objJsonResult.code = "0";
                        this.objJsonResult.count = 0;
                        this.objJsonResult.Message = text25;
                        this.objJsonResult.data = null;
                        return this.objJsonResult;
                    }
                    string text26 = InvokeHelper.Save("PUR_ReceiveBill", jobject40.ToString());
                    bool flag28 = JObject.Parse(text26)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE";
                    bool flag29 = flag28;
                    bool flag30 = flag29;
                    if (flag30)
                    {
                        LogService.Write("收料通知单修改失败jsonRoot:" + jobject40.ToString(), "Vlog", true);
                        this.objJsonResult.code = "0";
                        this.objJsonResult.count = 0;
                        this.objJsonResult.Message = "金蝶收料通知单更新失败" + text26;
                        this.objJsonResult.data = null;
                        return this.objJsonResult;
                    }
                }
                var f__AnonymousType = new
                {
                    Ids = text2
                };
                string text27 = InvokeHelper.Submit("PUR_ReceiveBill", JsonConvert.SerializeObject(f__AnonymousType));
                JObject jobject43 = JObject.Parse(text27);
                bool flag31 = jobject43["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE";
                bool flag32 = flag31;
                bool flag33 = flag32;
                if (flag33)
                {
                    LogService.Write("收料通知单提交失败jsonRoot:" + f__AnonymousType.ToString(), "Vlog", true);
                    this.objJsonResult.code = "0";
                    this.objJsonResult.count = 0;
                    this.objJsonResult.Message = "金蝶收料通知单提交失败" + text27;
                    this.objJsonResult.data = null;
                    result = this.objJsonResult;
                }
                else
                {
                    text27 = InvokeHelper.Audit("PUR_ReceiveBill", JsonConvert.SerializeObject(f__AnonymousType));
                    jobject43 = JObject.Parse(text27);
                    bool flag34 = jobject43["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE";
                    bool flag35 = flag34;
                    bool flag36 = flag35;
                    if (flag36)
                    {
                        LogService.Write("收料通知单审核失败jsonRoot:" + f__AnonymousType.ToString(), "Vlog", true);
                        this.objJsonResult.code = "0";
                        this.objJsonResult.count = 0;
                        this.objJsonResult.Message = "金蝶收料通知单审核失败jsonRoot" + text27;
                        this.objJsonResult.data = null;
                        result = this.objJsonResult;
                    }
                    else
                    {
                        this.objJsonResult.code = "1";
                        this.objJsonResult.count = 1;
                        this.objJsonResult.Message = "操作成功!";
                        this.objJsonResult.data = null;
                        result = this.objJsonResult;
                    }
                }
            }
            catch (Exception ex)
            {
                this.objJsonResult.code = "0";
                this.objJsonResult.count = 0;
                this.objJsonResult.Message = "异常!" + ex.ToString();
                this.objJsonResult.data = null;
                result = this.objJsonResult;
            }
            return result;
        }
        //public object AuditPOInStockBillPost_AR([FromBody] JObject msg)
        //{
        //    string msg1 = msg["msg"].ToString();
        //    msg1 = msg1.Replace("\\", "");
        //    msg1 = msg1.Replace("\n", "");
        //    msg1 = msg1.Substring(1, msg1.Length-2);
        //    try
        //    {
        //        List<Model.ClsCg_POInStockBillMain> lsmain = new List<Model.ClsCg_POInStockBillMain>();
        //        ListModels oListModels = new ListModels();
        //        lsmain = oListModels.getPOInStockBillMainByJson(msg1);
        //        lsmain[0].HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
        //        lsmain[0].HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));
        //        string sSourceBillType = "1103";
        //        WebAPI.WebS.ClsCg_POInStockBillMain websLsmain = new WebS.ClsCg_POInStockBillMain();
        //        websLsmain.HInterID = lsmain[0].HInterID;
        //        websLsmain.HBillNo = lsmain[0].HBillNo;
        //        //websLsmain.HBillType = "1103";//固定值
        //        websLsmain.HDate = lsmain[0].HDate;
        //        //websLsmain.HDeptID = lsmain[0].HDeptID;
        //        //websLsmain.HEmpID = 0;
        //        //websLsmain.HBillerID = lsmain[0].HBillerID;
        //        //websLsmain.HRemark = "";
        //        //websLsmain.HMainSourceBillType = lsmain[0].HBillType;
        //        if (webserver.set_SavePOInStockBill_NEW_Json(websLsmain, ref DBUtility.ClsPub.sErrInfo))
        //        {
        //            objJsonResult.code = "0";
        //            objJsonResult.count = 1;
        //            objJsonResult.Message = "成功!单据号为:";
        //            objJsonResult.data = null;
        //            return objJsonResult;
        //        }
        //        else
        //        {
        //            objJsonResult.code = "0";
        //            objJsonResult.count = 0;
        //            objJsonResult.Message = "上传失败!" + DBUtility.ClsPub.sErrInfo;
        //            objJsonResult.data = null;
        //            return objJsonResult;
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        objJsonResult.code = "0";
        //        objJsonResult.count = 0;
        //        objJsonResult.Message = "上传失败!" + e.ToString();
        //        objJsonResult.data = null;
        //        return objJsonResult;
        //    }
        //}
        #region PDA其他出库
        //到货确认删除
        [Route("Kf_ReciveBill_Fast_AR/Delete_Json_AN")]
        [HttpGet]
        public object get_InfoByBillNo(string HBillno)
        public object Delete_Json_AN(string HBillNo, Int64 HMaterID)
        {
            try
            {
                json result = Get_ReciveBillCheckDate(HBillno);
                return result;
                //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                //string sql = $"select * from H_v_SRM_POInStockBillList where 单据号 ='{HBillno}'";
                //ds = oCn.RunProcReturn(sql, "H_v_SRM_POInStockBillList");
                //if (ds == null || ds.Tables[0].Rows.Count == 0)
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "没有返回任何记录!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                //else
                //{
                //    objJsonResult.code = "1";
                //    objJsonResult.count = 1;
                //    objJsonResult.Message = "Sucess!";
                //    objJsonResult.data = ds.Tables[0];
                //    return objJsonResult;
                //}
                //根据条码在条码档案中找到对应的托条码,再在临时表中删除该托条码的全部记录
                string sql = string.Format(@"delete from KF_PonderationBillMain_Temp where HBillType=1103 and HMaterID=" + HMaterID + " and HBillNo =  '" + HBillNo + "'");
                oCn.RunProc(sql);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "删除成功!";
                objJsonResult.data = 1;
                return objJsonResult;
            }
            catch (Exception e)
            {
@@ -1079,371 +4719,223 @@
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        [Route("POStockInBillList/AuditPOInStockBill")]
        #endregion
        [Route("Kf_ReciveBill_Fast_AR/Display111")]
        [HttpGet]
        public object AuditPOInStockBill(string HInterID, string CurUserName, string HBillNo)
        public object Display111(string HBillNo)
        {
            Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
            json objjson = new json();
            try
            {
                SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM();
                //采购订单 生成送货单列表
                if (!String.IsNullOrEmpty(HBillNo))
                    HInterID = GetHinterIDByBillNo(HBillNo, "Aduit").ToString();
                if (HInterID == "0")
                //根据条码在条码档案中找到对应的托条码,再在临时表中删除该托条码的全部记录
                DataSet dataSet4 = this.oCn.RunProcReturn(" select sum(a.HQty) HQty ,a.HMaterID,b.HNumber,b.HName,b.HModel,a.HSourceBillNo,a.HInterID,a.HBillNo from KF_PonderationBillMain_Temp a inner join Gy_Material b on a.hmaterid = b.hitemid where a.HBillNo = '" + HBillNo.ToString() + "' group by  a.HMaterID,b.HNumber,b.HName,b.HModel,a.HSourceBillNo,a.HInterID,a.HBillNo", "Gy_Material");
                bool flag5 = dataSet4 == null || dataSet4.Tables[0].Rows.Count == 0;
                if (flag5)
                {
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "操作失败,请先保存订单";
                    objjson.data = null;
                    return objjson;
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                string parameterSql = $"select HValue from Xt_SystemParameter where HKey ='Cg_POInStockBill_ErpAduit'";
                var HValue = oCn.RunProcReturn(parameterSql, "dt").Tables[0].Rows[0][0].ToString();
                string sql = string.Empty;
                if (HValue == "Y")
                else
                {
                    var kdTbaleName = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "DataBaseName");
                    string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo);
                    DataTable dt = new DataTable();
                    List<string> fidList = new List<string>();
                    if (FCusName == "瑞与祺" || FCusName == "")
                    {
                        sql = string.Format(@"
SELECT T3.FNAME AS FTYPENAME,M.HBILLNO,B.HINTERID,B.HENTRYID,C.FID,C.FENTRYID, D.FBILLNO,B.HQTY,CD.FRECEIVEORGID,CDOO.FNUMBER AS FRECEIVENUMBER
,D.FSUPPLIERID,DS.FNUMBER AS FSUPPLIERNUMBER,D.FPURCHASEORGID,DOO.FNUMBER AS FPURCHASEORGNUMBER,CROO.FNUMBER  AS FSETTLEORGNUMBER,
E.FPRICETIMEPOINT,E.FSETTLECURRID,EC.FNUMBER AS FSETTLECURRNUMBER,C.FMATERIALID,CM.FNUMBER AS FMATERIALNUMBER ,C.FUNITID
,CU.FNUMBER AS FUNITNUMBER,CR.FPRICE,CR.FTAXPRICE,CR.FTAXRATE,D.FPURCHASERID,isnull(T4.FNUMBER,'') AS FPURCHASERNUMBER
FROM CG_POINSTOCKBILLSUB B
JOIN CG_POINSTOCKBILLMAIN M ON B.HINTERID = M.HINTERID
JOIN {0}..T_PUR_POORDERENTRY C ON B.HSOURCEINTERID = C.FID AND B.HSOURCEENTRYID = C.FENTRYID
LEFT JOIN {0}..T_BD_MATERIAL CM ON C.FMATERIALID =CM.FMATERIALID
LEFT JOIN {0}..T_BD_UNIT CU ON C.FUNITID =CU.FUNITID
JOIN {0}..T_PUR_POORDERENTRY_D CD ON    C.FENTRYID = CD.FENTRYID
LEFT JOIN {0}..T_ORG_ORGANIZATIONS CDOO ON CD.FRECEIVEORGID = CDOO.FORGID
JOIN {0}..T_PUR_POORDERENTRY_F CR ON    C.FENTRYID = CR.FENTRYID
LEFT JOIN {0}..T_ORG_ORGANIZATIONS CROO ON CR.FSETTLEORGID = CROO.FORGID
LEFT JOIN {0}..T_PUR_POORDER D ON C.FID =D.FID
LEFT JOIN {0}..T_BAS_BILLTYPE T2 ON D.FBILLTYPEID = T2.FBILLTYPEID
LEFT JOIN {0}..T_BAS_BILLTYPE_L T3 ON T2.FBILLTYPEID = T3.FBILLTYPEID and FLOCALEID=2052
LEFT JOIN  {0}..V_BD_BUYER T4 ON D.FPURCHASERID =T4.FID
LEFT JOIN {0}..T_BD_SUPPLIER DS ON D.FSUPPLIERID = DS.FSUPPLIERID
LEFT JOIN {0}..T_ORG_ORGANIZATIONS DOO ON D.FPURCHASEORGID = DOO.FORGID
JOIN {0}..T_PUR_POORDERFIN E ON C.FID =E.FID
LEFT JOIN {0}..T_BD_CURRENCY EC ON E. FSETTLECURRID =EC.FCURRENCYID
 WHERE b.hinterid in ({1}) and M.HERPInterID = 0
", kdTbaleName, HInterID);
                        //LEFT JOIN  {0}..T_HR_EMPINFO T5 ON D.F_XBKF_BASE1 = T5.FID
                        dt = oCn.RunProcReturn(sql, "sltz").Tables[0];
                        if (dt.Rows.Count > 0)
                        {
                            foreach (DataRow dr in dt.Rows)
                            {
                                if (fidList.Contains(dr["FID"].ToString() + dr["HINTERID"].ToString()))
                                    continue;
                                else
                                    fidList.Add(dr["FID"].ToString() + dr["HINTERID"].ToString());
                                DataRow[] drs = dt.Select("FID = " + dr["FID"].ToString() + " and HINTERID = " + dr["HINTERID"].ToString());
                                JObject model = new JObject();
                                string fTypeName = "SLD01_SYS";//标准采购订单类型
                                string ywTypeName = "CG";//标准业务类型
                                if (dr["FTYPENAME"].ToString().Contains("委外"))
                                {
                                    fTypeName = "SLD03_SYS";
                                    ywTypeName = "WW";
                                }
                                if (dr["FTYPENAME"].ToString().Contains("资产"))
                                {
                                    fTypeName = "SLD04_SYS";
                                    ywTypeName = "ZCCG";
                                }
                                model.Add("FBILLTYPEID", new JObject() { ["Fnumber"] = fTypeName }); //单据类型
                                model.Add("FBusinessType", ywTypeName); //业务类型
                                model.Add("FBILLNO", dr["HBillNo"].ToString()); //单据编号
                                model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //通知日期
                                model.Add("FStockOrgId", new JObject() { ["Fnumber"] = dr["FRECEIVENUMBER"].ToString() }); // 收料组织
                                model.Add("FPurOrgId", new JObject() { ["Fnumber"] = dr["FPURCHASEORGNUMBER"].ToString() }); //采购组织
                                model.Add("FSupplierId", new JObject() { ["Fnumber"] = dr["FSUPPLIERNUMBER"].ToString() }); //供应商
                                model.Add("FPURCHASERID", new JObject() { ["Fnumber"] = dr["FPURCHASERNUMBER"].ToString() }); //采购员
                                model.Add("FOwnerTypeIdHead", "BD_Supplier");//  货主类型
                                model.Add("FOwnerIdHead", new JObject() { ["Fnumber"] = dr["FSUPPLIERNUMBER"].ToString() });//货主 供应商
                                JArray Fentity = new JArray();
                                foreach (var item in drs)
                                {
                                    JObject FentityModel = new JObject();
                                    FentityModel.Add("FMaterialId", new JObject() { ["Fnumber"] = item["FMATERIALNUMBER"].ToString() }); // 物料编码
                                    FentityModel.Add("FUnitID", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); // 单位
                                    FentityModel.Add("FPreDeliveryDate", DateTime.Now.ToString("yyyy-MM-dd")); //预计到货日期
                                    FentityModel.Add("FPriceUnitId", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); // 计价单位
                                    FentityModel.Add("FStockUnitID", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); //  库存单位
                                    FentityModel.Add("FActReceiveQty", Convert.ToDecimal(item["HQTY"])); // 供应商送货数量(提料计划数量 - 已生成送货单数量)
                                    FentityModel.Add("FOwnerTypeId", "BD_OwnerOrg");//货主类型
                                    FentityModel.Add("FOwnerID", new JObject() { ["Fnumber"] = dr["FPURCHASEORGNUMBER"].ToString() });//货主
                                    FentityModel.Add("FSrcId", item["FID"].ToString());//源单内码
                                    FentityModel.Add("FSRCFORMID", "PUR_PurchaseOrder");//源单类型
                                    FentityModel.Add("FSrcBillNo", item["FBILLNO"].ToString());//源单单号
                                    FentityModel.Add("FSRCENTRYID", item["FENTRYID"].ToString());//源单分录内码
                                    FentityModel.Add("FORDERBILLNO", item["FBILLNO"].ToString());//源单单号
                                    FentityModel.Add("FPOORDERENTRYID", item["FENTRYID"].ToString());//源单分录内码
                                    FentityModel.Add("FSRMENTRYID", item["HENTRYID"].ToString());//SRM hentryid
                                    FentityModel.Add("FPrice", item["FPRICE"].ToString());//单价
                                    FentityModel.Add("FTaxPrice", item["FTAXPRICE"].ToString());//含税单价
                                    FentityModel.Add("FEntryTaxRate", item["FTAXRATE"].ToString());//税率
                                    JArray Fentity2 = new JArray();
                                    JObject FentityModel2 = new JObject();
                                    FentityModel2.Add("FDetailEntity_Link_FRULEID", "PUR_PurchaseOrder-PUR_ReceiveBill");
                                    FentityModel2.Add("FDetailEntity_Link_FSTableName", "t_PUR_POOrderEntry");
                                    FentityModel2.Add("FDetailEntity_Link_FSBillId", item["FID"].ToString());
                                    FentityModel2.Add("FDetailEntity_Link_FSId", item["FEntryID"].ToString());
                                    Fentity2.Add(FentityModel2);
                                    FentityModel.Add("FDetailEntity_Link", Fentity2);
                                    Fentity.Add(FentityModel);
                                }
                                model.Add("FDetailEntity", Fentity); //明细信息
                                JObject _FentityModel = new JObject();
                                _FentityModel.Add("FSettleOrgId", new JObject() { ["Fnumber"] = dr["FSETTLEORGNUMBER"].ToString() }); //  结算组织
                                _FentityModel.Add("FSettleCurrId", new JObject() { ["Fnumber"] = dr["FSETTLECURRNUMBER"].ToString() }); //  结算币别
                                _FentityModel.Add("FPricePoint", 0); //  定价时点
                                model.Add("FinanceEntity ", _FentityModel);//财务信息
                                JObject jsonRoot = new JObject()
                                {
                                    ["Creator"] = "",
                                    ["NeedUpDateFields"] = new JArray(),
                                    ["NeedReturnFields"] = new JArray(),
                                    ["IsDeleteEntry"] = "false",
                                    ["SubSystemId"] = "",
                                    ["IsVerifyBaseDataField"] = "false",
                                    ["Model"] = model
                                };
                                var loginRet = InvokeHelper.Login();
                                var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
                                if (isSuccess <= 0)
                                {
                                    objjson.code = "0";
                                    objjson.count = 0;
                                    objjson.Message = loginRet;
                                    objjson.data = null;
                                    return objjson;
                                }
                                //LogService.Write("jsonRoot:" + jsonRoot.ToString());
                                var result = InvokeHelper.Save("PUR_ReceiveBill", jsonRoot.ToString());
                                //LogService.Write(result);
                                if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() == "TRUE")
                                {
                                    //更新送货单 主表 ERP单据号 以及 ERP主内玛
                                    string FBillNo = JObject.Parse(result)["Result"]["Number"].ToString();
                                    string FID = JObject.Parse(result)["Result"]["Id"].ToString();
                                    string updateSql = string.Format(@"
                                                      update a set
                                                      a.HERPInterID = {0} ,
                                                      a.HERPBillNO   ='{1}'
                                                      from Cg_POInStockBillMain a
                                                      join Cg_POInStockBillSub b on a.hinterid = b.hinterid
                                                      where b.HInterID = ({2})
                                                      and b. HSOURCEINTERID = {3}
                                                      and a.HERPInterID = 0
                                                     ", FID, FBillNo, dr["HINTERID"].ToString(), dr["FID"].ToString());
                                    oCn.RunProc(updateSql);
                                }
                                else
                                {
                                    objjson.code = "0";
                                    objjson.count = 0;
                                    objjson.Message = result;
                                    objjson.data = null;
                                    return objjson;
                                }
                            }
                        }
                    }
                    else if (FCusName == "夏宝电器")
                    {
                        sql = string.Format(@"
SELECT T3.FNAME AS FTYPENAME,M.HBILLNO,B.HINTERID,B.HENTRYID,C.FID,C.FENTRYID, D.FBILLNO,B.HQTY,CD.FRECEIVEORGID,CDOO.FNUMBER AS FRECEIVENUMBER
,D.FSUPPLIERID,DS.FNUMBER AS FSUPPLIERNUMBER,D.FPURCHASEORGID,DOO.FNUMBER AS FPURCHASEORGNUMBER,CROO.FNUMBER  AS FSETTLEORGNUMBER,
E.FPRICETIMEPOINT,E.FSETTLECURRID,EC.FNUMBER AS FSETTLECURRNUMBER,C.FMATERIALID,CM.FNUMBER AS FMATERIALNUMBER ,C.FUNITID
,CU.FNUMBER AS FUNITNUMBER,D.F_XBKF_COMBO1,CR.FPRICE,CR.FTAXPRICE,CR.FTAXRATE,D.FPURCHASERID,isnull(T4.FNUMBER,'') AS FPURCHASERNUMBER,D.F_XBKF_BASE1,isnull(T5.FNUMBER,'') AS FRECEIVEMENNUMBER
FROM CG_POINSTOCKBILLSUB B
JOIN CG_POINSTOCKBILLMAIN M ON B.HINTERID = M.HINTERID
JOIN {0}..T_PUR_POORDERENTRY C ON B.HSOURCEINTERID = C.FID AND B.HSOURCEENTRYID = C.FENTRYID
LEFT JOIN {0}..T_BD_MATERIAL CM ON C.FMATERIALID =CM.FMATERIALID
LEFT JOIN {0}..T_BD_UNIT CU ON C.FUNITID =CU.FUNITID
JOIN {0}..T_PUR_POORDERENTRY_D CD ON    C.FENTRYID = CD.FENTRYID
LEFT JOIN {0}..T_ORG_ORGANIZATIONS CDOO ON CD.FRECEIVEORGID = CDOO.FORGID
JOIN {0}..T_PUR_POORDERENTRY_F CR ON    C.FENTRYID = CR.FENTRYID
LEFT JOIN {0}..T_ORG_ORGANIZATIONS CROO ON CR.FSETTLEORGID = CROO.FORGID
LEFT JOIN {0}..T_PUR_POORDER D ON C.FID =D.FID
LEFT JOIN {0}..T_BAS_BILLTYPE T2 ON D.FBILLTYPEID = T2.FBILLTYPEID
LEFT JOIN {0}..T_BAS_BILLTYPE_L T3 ON T2.FBILLTYPEID = T3.FBILLTYPEID  and FLOCALEID=2052
LEFT JOIN  {0}..V_BD_BUYER T4 ON D.FPURCHASERID =T4.FID
LEFT JOIN  {0}..T_HR_EMPINFO T5 ON D.F_XBKF_BASE1 = T5.FID
LEFT JOIN {0}..T_BD_SUPPLIER DS ON D.FSUPPLIERID = DS.FSUPPLIERID
LEFT JOIN {0}..T_ORG_ORGANIZATIONS DOO ON D.FPURCHASEORGID = DOO.FORGID
JOIN {0}..T_PUR_POORDERFIN E ON C.FID =E.FID
LEFT JOIN {0}..T_BD_CURRENCY EC ON E. FSETTLECURRID =EC.FCURRENCYID
 WHERE b.hinterid in ({1}) and M.HERPInterID = 0
", kdTbaleName, HInterID);
                        dt = oCn.RunProcReturn(sql, "sltz").Tables[0];
                        if (dt.Rows.Count > 0)
                        {
                            foreach (DataRow dr in dt.Rows)
                            {
                                if (fidList.Contains(dr["FID"].ToString() + dr["HINTERID"].ToString()))
                                    continue;
                                else
                                    fidList.Add(dr["FID"].ToString() + dr["HINTERID"].ToString());
                                DataRow[] drs = dt.Select("FID = " + dr["FID"].ToString() + " and HINTERID = " + dr["HINTERID"].ToString());
                                JObject model = new JObject();
                                string fTypeName = "SLD01_SYS";//标准采购订单类型
                                string ywTypeName = "CG";//标准业务类型
                                if (dr["FTYPENAME"].ToString().Contains("委外"))
                                {
                                    fTypeName = "SLD03_SYS";
                                    ywTypeName = "WW";
                                }
                                if (dr["FTYPENAME"].ToString().Contains("资产"))
                                {
                                    fTypeName = "SLD04_SYS";
                                    ywTypeName = "ZCCG";
                                }
                                model.Add("FBILLTYPEID", new JObject() { ["Fnumber"] = fTypeName }); //单据类型
                                model.Add("FBusinessType", ywTypeName); //业务类型
                                model.Add("FBILLNO", dr["HBillNo"].ToString()); //单据编号
                                model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //通知日期
                                model.Add("FStockOrgId", new JObject() { ["Fnumber"] = dr["FRECEIVENUMBER"].ToString() }); // 收料组织
                                model.Add("FPurOrgId", new JObject() { ["Fnumber"] = dr["FPURCHASEORGNUMBER"].ToString() }); //采购组织
                                model.Add("FSupplierId", new JObject() { ["Fnumber"] = dr["FSUPPLIERNUMBER"].ToString() }); //供应商
                                model.Add("FPURCHASERID", new JObject() { ["Fnumber"] = dr["FPURCHASERNUMBER"].ToString() }); //采购员
                                model.Add("F_xbkf_Base", new JObject() { ["Fnumber"] = dr["FRECEIVEMENNUMBER"].ToString() }); //收料员
                                model.Add("FOwnerTypeIdHead", "BD_Supplier");//  货主类型
                                model.Add("FOwnerIdHead", new JObject() { ["Fnumber"] = dr["FSUPPLIERNUMBER"].ToString() });//货主 供应商
                                model.Add("F_XBKF_COMBO", dr["F_xbkf_Combo1"].ToString());//是否有票
                                JArray Fentity = new JArray();
                                foreach (var item in drs)
                                {
                                    JObject FentityModel = new JObject();
                                    FentityModel.Add("FMaterialId", new JObject() { ["Fnumber"] = item["FMATERIALNUMBER"].ToString() }); // 物料编码
                                    FentityModel.Add("FUnitID", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); // 单位
                                    FentityModel.Add("FPreDeliveryDate", DateTime.Now.ToString("yyyy-MM-dd")); //预计到货日期
                                    FentityModel.Add("FPriceUnitId", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); // 计价单位
                                    FentityModel.Add("FStockUnitID", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); //  库存单位
                                    FentityModel.Add("FActReceiveQty", Convert.ToDecimal(item["HQTY"])); // 供应商送货数量(提料计划数量 - 已生成送货单数量)
                                    FentityModel.Add("FOwnerTypeId", "BD_OwnerOrg");//货主类型
                                    FentityModel.Add("FOwnerID", new JObject() { ["Fnumber"] = dr["FPURCHASEORGNUMBER"].ToString() });//货主
                                    FentityModel.Add("FSrcId", item["FID"].ToString());//源单内码
                                    FentityModel.Add("FSRCFORMID", "PUR_PurchaseOrder");//源单类型
                                    FentityModel.Add("FSrcBillNo", item["FBILLNO"].ToString());//源单单号
                                    FentityModel.Add("FSRCENTRYID", item["FENTRYID"].ToString());//源单分录内码
                                    FentityModel.Add("FORDERBILLNO", item["FBILLNO"].ToString());//源单单号
                                    FentityModel.Add("FPOORDERENTRYID", item["FENTRYID"].ToString());//源单分录内码
                                    FentityModel.Add("FSRMENTRYID", item["HENTRYID"].ToString());//SRM hentryid
                                    FentityModel.Add("FPrice", item["FPRICE"].ToString());//单价
                                    FentityModel.Add("FTaxPrice", item["FTAXPRICE"].ToString());//含税单价
                                    FentityModel.Add("FEntryTaxRate", item["FTAXRATE"].ToString());//税率
                                    JArray Fentity2 = new JArray();
                                    JObject FentityModel2 = new JObject();
                                    FentityModel2.Add("FDetailEntity_Link_FRULEID", "PUR_PurchaseOrder-PUR_ReceiveBill");
                                    FentityModel2.Add("FDetailEntity_Link_FSTableName", "t_PUR_POOrderEntry");
                                    FentityModel2.Add("FDetailEntity_Link_FSBillId", item["FID"].ToString());
                                    FentityModel2.Add("FDetailEntity_Link_FSId", item["FEntryID"].ToString());
                                    Fentity2.Add(FentityModel2);
                                    FentityModel.Add("FDetailEntity_Link", Fentity2);
                                    Fentity.Add(FentityModel);
                                }
                                model.Add("FDetailEntity", Fentity); //明细信息
                                JObject _FentityModel = new JObject();
                                _FentityModel.Add("FSettleOrgId", new JObject() { ["Fnumber"] = dr["FSETTLEORGNUMBER"].ToString() }); //  结算组织
                                _FentityModel.Add("FSettleCurrId", new JObject() { ["Fnumber"] = dr["FSETTLECURRNUMBER"].ToString() }); //  结算币别
                                _FentityModel.Add("FPricePoint", 0); //  定价时点
                                model.Add("FinanceEntity ", _FentityModel);//财务信息
                                JObject jsonRoot = new JObject()
                                {
                                    ["Creator"] = "",
                                    ["NeedUpDateFields"] = new JArray(),
                                    ["NeedReturnFields"] = new JArray(),
                                    ["IsDeleteEntry"] = "false",
                                    ["SubSystemId"] = "",
                                    ["IsVerifyBaseDataField"] = "false",
                                    ["Model"] = model
                                };
                                var loginRet = InvokeHelper.Login();
                                var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
                                if (isSuccess < 0)
                                {
                                    objjson.code = "0";
                                    objjson.count = 0;
                                    objjson.Message = loginRet;
                                    objjson.data = null;
                                    return objjson;
                                }
                                //LogService.Write("jsonRoot:" + jsonRoot.ToString());
                                var result = InvokeHelper.Save("PUR_ReceiveBill", jsonRoot.ToString());
                                //LogService.Write(result);
                                if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() == "TRUE")
                                {
                                    //更新送货单 主表 ERP单据号 以及 ERP主内玛
                                    string FBillNo = JObject.Parse(result)["Result"]["Number"].ToString();
                                    string FID = JObject.Parse(result)["Result"]["Id"].ToString();
                                    string updateSql = string.Format(@"
                                                      update a set
                                                      a.HERPInterID = {0} ,
                                                      a.HERPBillNO   ='{1}'
                                                      from Cg_POInStockBillMain a
                                                      join Cg_POInStockBillSub b on a.hinterid = b.hinterid
                                                      where b.HInterID = ({2})
                                                      and b. HSOURCEINTERID = {3}
                                                      and a.HERPInterID = 0
                                                     ", FID, FBillNo, dr["HINTERID"].ToString(), dr["FID"].ToString());
                                    oCn.RunProc(updateSql);
                                }
                                else
                                {
                                    objjson.code = "0";
                                    objjson.count = 0;
                                    objjson.Message = result;
                                    objjson.data = null;
                                    return objjson;
                                }
                            }
                        }
                    }
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "Sucess!";
                    objJsonResult.data = dataSet4.Tables[0]; ;
                    return objJsonResult;
                }
                var check = Exec_ReciveBillCheck(HBillNo);
                if (check.code == "0")
                    return check;
                //if(check)
                //更新主表状态 审核
                sql = string.Format(@"update Cg_POInStockBillMain set
HBillStatus = 2 ,
HChecker   ='{0}',
HCheckDate   = getdate()
where HInterID in ({1})", CurUserName, HInterID);
                oCn.RunProc(sql);
                objjson.code = "1";
                objjson.count = 1;
                objjson.Message = "操作成功";
                objjson.data = null;
                return objjson;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        [Route("POStockInBillList/Get_ReciveBillByBarcode_AR")]
        [HttpGet]
        public object Get_ReciveBillByBarcode_AR(string HBarcode, long HOrgID, long HInterID, string HBillNo)
        {
            object result;
            try
            {
                string singleSystemParameter = this.oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref ClsPub.sExeReturnInfo);
                string empty = string.Empty;
                bool flag = singleSystemParameter.Contains("安瑞");
                if (flag)
                {
                    string[] array = HBarcode.Split(new char[]
                    {
                        '@'
                    });
                    string text = array[0];
                    Double num = ClsPub.isDoule(array[4]);
                    string text2 = array[6];
                    DateTime dateTime = ClsPub.isDate(array[3]);
                    DateTime dateTime2 = ClsPub.isDate(array[5]);
                    DataSet Dss7;
                    Dss7 = oCn.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + text + "'", "T_BD_MATERIAL");
                    if (Dss7 == null || Dss7.Tables[0].Rows.Count == 0)
                    {
                        DataSet Dss8;
                        Dss8 = oCn.RunProcReturn(" select * from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + text + "'", "T_BD_MATERIAL");
                        text = DBUtility.ClsPub.isStrNull(Dss8.Tables[0].Rows[0]["FNumber"]);
                    }
                    else
                    {
                        text = DBUtility.ClsPub.isStrNull(Dss7.Tables[0].Rows[0]["FNumber"]);
                    }
                    DataSet dataSet = this.oCn.RunProcReturn(string.Concat(new string[]
                    {
                        " select max(HItemID) HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '",
                        text,
                        "' and  huseorgid = ",
                        HOrgID.ToString(),
                        " group by HName,HModel,HUnitID"
                    }), "Gy_Material");
                    bool flag2 = dataSet == null || dataSet.Tables[0].Rows.Count == 0;
                    if (flag2)
                    {
                        this.objJsonResult.code = "0";
                        this.objJsonResult.count = 0;
                        this.objJsonResult.Message = "没有物料数据!";
                        this.objJsonResult.data = null;
                        return this.objJsonResult;
                    }
                    long num2 = ClsPub.isLong(dataSet.Tables[0].Rows[0]["HItemID"]);
                    string text3 = ClsPub.isStrNull(dataSet.Tables[0].Rows[0]["HName"]);
                    string text4 = ClsPub.isStrNull(dataSet.Tables[0].Rows[0]["HModel"]);
                    long num3 = (long)ClsPub.isInt(dataSet.Tables[0].Rows[0]["HUnitID"]);
                    string text5 = ClsPub.isStrNull(array[8]);
                    DataSet dataSet2 = this.oCn.RunProcReturn(string.Concat(new string[]
                    {
                        "select  *  from KF_PonderationBillMain_Temp Where HBillNo='",
                        text5,
                        "' and HMaterID = ",
                        num2.ToString(),
                        " and HInterID = ",
                        HInterID.ToString(),
                        " and HQty = ",
                        num.ToString()
                    }), "KF_PonderationBillMain_Temp");
                    bool flag3 = dataSet2.Tables[0].Rows.Count > 0;
                    if (flag3)
                    {
                        this.objJsonResult.code = "0";
                        this.objJsonResult.count = 0;
                        this.objJsonResult.Message = "该收料通知单已存在扫码记录!";
                        this.objJsonResult.data = null;
                        return this.objJsonResult;
                    }
                    DataSet dataSet3 = this.oCn.RunProcReturn(" select a.HInterID,b.HEntryID,a.HBillNo from Cg_POOrderBillMain a inner join Cg_POOrderBillSub b on a.hinterid = b.hinterid where a.HBillNo = '" + text5.ToString() + "' and  b.HMaterID = " + num2.ToString(), "Cg_POOrderBillMain");
                    bool flag4 = dataSet3 == null || dataSet3.Tables[0].Rows.Count == 0;
                    if (flag4)
                    {
                        this.objJsonResult.code = "0";
                        this.objJsonResult.count = 0;
                        this.objJsonResult.Message = "没有采购订单记录!" + text5 + num2.ToString();
                        this.objJsonResult.data = null;
                        return this.objJsonResult;
                    }
                    long num4 = ClsPub.isLong(dataSet3.Tables[0].Rows[0]["HInterID"]);
                    long num5 = ClsPub.isLong(dataSet3.Tables[0].Rows[0]["HEntryID"]);
                    string text6 = ClsPub.isStrNull(dataSet3.Tables[0].Rows[0]["HBillNo"]);
                    this.oCn.RunProc(string.Concat(new string[]
                    {
                        "insert into KF_PonderationBillMain_Temp (HInterID,HBillNo,HBeginDate,HEndDate,HBillType,HMaterID,HProcID" +
                        ",HWhID,HSCWHID,HStockPlaceID,HOutStockPlaceID,HGroupID" +
                        ",HQty,HQtyMust,HPieceQty,HAuxPropID,HBatchNo" +
                        ",HBarCode,HAddr,HMaker,HMakeDate ,HSourceInterID" +
                        ",HSourceEntryID,HSourceBillType,HSourceBillNo,HMTONo ,HSTOCKORGID" +
                        ",HOWNERID,HExpressNumber,HSubBillType,HRelationInterID,HRelationEntryID" +
                        ",HRelationBillNo,HRedBlueFlag,HCusID) values (",
                        HInterID.ToString(),
                        ",'",
                        HBillNo.ToString(),
                          "','",
                        dateTime.ToString(),
                          "','",
                        dateTime2.ToString(),
                        "','1103',",
                        num2.ToString(),
                        ",0,0,0,0,0,0,",
                        num.ToString(),
                        ",",
                        num.ToString(),
                        ",0,0,'",
                        text2.ToString(),
                        "','",
                        HBarcode.ToString(),
                        "','','System',getdate(), ",
                        num4.ToString(),
                        ",",
                        num5.ToString(),
                        ",'1102','",
                        text6.ToString(),
                        "','',0,0,'','',0,0,'',0,0)"
                    }));
                }
                DataSet dataSet4 = this.oCn.RunProcReturn(" select sum(a.HQty) HQty ,a.HMaterID,b.HNumber,b.HName,b.HModel,a.HSourceBillNo,a.HInterID,a.HBillNo from KF_PonderationBillMain_Temp a inner join Gy_Material b on a.hmaterid = b.hitemid where a.HBillNo = '" + HBillNo.ToString() + "' group by  a.HMaterID,b.HNumber,b.HName,b.HModel,a.HSourceBillNo,a.HInterID,a.HBillNo", "Gy_Material");
                bool flag5 = dataSet4 == null || dataSet4.Tables[0].Rows.Count == 0;
                if (flag5)
                {
                    this.objJsonResult.code = "0";
                    this.objJsonResult.count = 0;
                    this.objJsonResult.Message = "没有返回任何记录!";
                    this.objJsonResult.data = null;
                    result = this.objJsonResult;
                }
                else
                {
                    this.objJsonResult.code = "1";
                    this.objJsonResult.count = 1;
                    this.objJsonResult.Message = "Sucess!";
                    this.objJsonResult.data = dataSet4.Tables[0];
                    result = this.objJsonResult;
                }
            }
            catch (Exception ex)
            {
                objjson.code = "0";
                objjson.count = 0;
                objjson.Message = "操作失败" + ex.Message.ToString();
                objjson.data = null;
                return objjson;
                this.objJsonResult.code = "0";
                this.objJsonResult.count = 0;
                this.objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                this.objJsonResult.data = null;
                result = this.objJsonResult;
            }
            return result;
        }
        #region 到货确认
        [Route("POStockInBillList/Get_ReciveBill")]
        [HttpGet]
        public object get_InfoByBillNo(string HBillno)
        {
            try
            {
                json result = Get_ReciveBillCheckDate(HBillno);
                return result;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        public int GetHinterIDByBillNo(string HBillNo, string type)
@@ -1470,7 +4962,12 @@
            try
            {
                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                DataSet Ds = oCn.RunProcReturn("exec h_p_KF_PonderationBillMain_Temp_Add_POInStockCheck2 '" + HBarCode + "'", "h_p_KF_PonderationBillMain_Temp_Add_POInStockCheck2");
                DataSet Ds;
                string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo);//客户名称
                if (FCusName.Contains("安瑞"))
                    Ds = oCn.RunProcReturn("exec h_p_GetPOInStockByBarCode'" + HBarCode + "'", "h_p_GetPOInStockByBarCode");
                else
                    Ds = oCn.RunProcReturn("exec h_p_KF_PonderationBillMain_Temp_Add_POInStockCheck2 '" + HBarCode + "'", "h_p_KF_PonderationBillMain_Temp_Add_POInStockCheck2");
                if (Ds == null || Ds.Tables[0].Rows.Count == 0)
                {
                    objjson.code = "0";
@@ -1523,12 +5020,29 @@
                DAL.ClsCg_POInStockBill oBill = new DAL.ClsCg_POInStockBill();
                var hinterID = list[0].HInterID;
                var FID = list[0].FID;
                #region 金蝶审核后会重新同步单据到mes 故不需要更新mes的收料通知单
                /*
                oCn.BeginTran();
                string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo);//客户名称
                string FisRealess = oSystemParameter.GetSingleSystemParameter("Cg_POInStockBill_ErpAduit", ref DBUtility.ClsPub.sExeReturnInfo);//送货单到货确认后同步金蝶云收料通知单
                string FishaveBarcode = oSystemParameter.GetSingleSystemParameter("Cg_POInStockBill_BarCodeCtl", ref DBUtility.ClsPub.sExeReturnInfo);//到货确认必须扫码箱条码
                var kdTbaleName = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "DataBaseName");
                string sql = string.Empty;
                #region 校验是否扫描条码
                if (FishaveBarcode == "Y")
                {
                    var HInterID = list[0].HInterID;
                    string jysql = string.Format(@"select * from KF_PonderationBillMain_Temp where HSourceInterID = {0}", HInterID);
                    DataTable jyDt = oCn.RunProcReturn(jysql, "jysql").Tables[0];
                    if (jyDt.Rows.Count == 0 || jyDt == null)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "请扫描条码";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                #endregion
                #region 金蝶审核后会重新同步单据到mes 故不需要更新mes的收料通知单
                oCn.BeginTran();
                foreach (var item in list)
                {
                    if (item.HSQty == 0)
@@ -1536,70 +5050,233 @@
                    sql = $"update Cg_POInStockBillSub set Hqty = {item.HSQty} where HInterID ={item.HInterID} and HEntryID = {item.HEntryID}";
                    oCn.RunProc(sql);
                }
                oCn.RunProc("exec h_p_Cg_UpDatePOOrderRelation_Del " + hinterID);//删除关联关系
                sql = string.Format(@"update Cg_POInStockBillMain set
HBillStatus = 2 ,
HCheckDate   = getdate()
where HInterID in ({0})", HInterID);
                oCn.RunProc(sql);//更新mes状态
                //更新成功后 同步更新金蝶
                oCn.Commit();
                **/
                #endregion
                #endregion
                JObject jsonRoot = new JObject();
                jsonRoot.Add("Creator", "");
                jsonRoot.Add("NeedUpDateFields", new JArray());
                jsonRoot.Add("NeedReturnFields", new JArray());
                jsonRoot.Add("IsDeleteEntry", "false");
                jsonRoot.Add("SubSystemId", "");
                jsonRoot.Add("IsVerifyBaseDataField", "");
                if (FCusName.Contains("安瑞"))
                {
                    sql = string.Format(@"
SELECT T3.FNAME AS FTYPENAME,M.HBILLNO,B.HINTERID,B.HENTRYID,C.FID,C.FENTRYID, D.FBILLNO,B.HQTY,CD.FRECEIVEORGID,CDOO.FNUMBER AS FRECEIVENUMBER
,D.FSUPPLIERID,DS.FNUMBER AS FSUPPLIERNUMBER,D.FPURCHASEORGID,DOO.FNUMBER AS FPURCHASEORGNUMBER,CROO.FNUMBER  AS FSETTLEORGNUMBER,
E.FPRICETIMEPOINT,E.FSETTLECURRID,EC.FNUMBER AS FSETTLECURRNUMBER,C.FMATERIALID,CM.FNUMBER AS FMATERIALNUMBER ,C.FUNITID
,CU.FNUMBER AS FUNITNUMBER,CR.FPRICE,CR.FTAXPRICE,CR.FTAXRATE,D.FPURCHASERID,isnull(T4.FNUMBER,'') AS FPURCHASERNUMBER
,C.FGIVEAWAY AS FGIVEAWAY
FROM CG_POINSTOCKBILLSUB B
JOIN CG_POINSTOCKBILLMAIN M ON B.HINTERID = M.HINTERID
JOIN {0}..T_PUR_POORDERENTRY C ON B.HSOURCEINTERID = C.FID AND B.HSOURCEENTRYID = C.FENTRYID
LEFT JOIN {0}..T_BD_MATERIAL CM ON C.FMATERIALID =CM.FMATERIALID
LEFT JOIN {0}..T_BD_UNIT CU ON C.FUNITID =CU.FUNITID
JOIN {0}..T_PUR_POORDERENTRY_D CD ON    C.FENTRYID = CD.FENTRYID
LEFT JOIN {0}..T_ORG_ORGANIZATIONS CDOO ON CD.FRECEIVEORGID = CDOO.FORGID
JOIN {0}..T_PUR_POORDERENTRY_F CR ON    C.FENTRYID = CR.FENTRYID
LEFT JOIN {0}..T_ORG_ORGANIZATIONS CROO ON CR.FSETTLEORGID = CROO.FORGID
LEFT JOIN {0}..T_PUR_POORDER D ON C.FID =D.FID
LEFT JOIN {0}..T_BAS_BILLTYPE T2 ON D.FBILLTYPEID = T2.FBILLTYPEID
LEFT JOIN {0}..T_BAS_BILLTYPE_L T3 ON T2.FBILLTYPEID = T3.FBILLTYPEID and FLOCALEID = 2052
LEFT JOIN  {0}..V_BD_BUYER T4 ON D.FPURCHASERID =T4.FID
LEFT JOIN {0}..T_BD_SUPPLIER DS ON D.FSUPPLIERID = DS.FSUPPLIERID
LEFT JOIN {0}..T_ORG_ORGANIZATIONS DOO ON D.FPURCHASEORGID = DOO.FORGID
JOIN {0}..T_PUR_POORDERFIN E ON C.FID =E.FID
LEFT JOIN {0}..T_BD_CURRENCY EC ON E. FSETTLECURRID =EC.FCURRENCYID
 WHERE b.hinterid in ({1}) and M.HERPInterID = 0
", kdTbaleName, hinterID);
                    DataTable dt = oCn.RunProcReturn(sql, "sltz").Tables[0];
                    List<string> fidList = new List<string>();
                    if (dt.Rows.Count > 0)
                    {
                        //foreach (DataRow dr in dt.Rows)
                        //{
                        //    //采购订单下推生成送货单 时候 判断是否有生成采购订单变更单 如果有且变更单状态不为已审核 限制下推
                        //    objJsonResult = TestPOOrder(dr["FEntryID"].ToString());
                        //    if (objJsonResult.code == "0")
                        //        return objJsonResult;
                        //}
                        foreach (DataRow dr in dt.Rows)
                        {
                            if (fidList.Contains(dr["HINTERID"].ToString()))
                                continue;
                            else
                                fidList.Add(dr["HINTERID"].ToString());
                            DataRow[] drs = dt.Select("HINTERID = " + dr["HINTERID"].ToString());
                            JObject model = new JObject();
                            string fTypeName = "SLD01_SYS";//标准采购订单类型
                            string ywTypeName = "CG";//标准业务类型
                            if (dr["FTYPENAME"].ToString().Contains("委外"))
                            {
                                fTypeName = "SLD03_SYS";
                                ywTypeName = "WW";
                            }
                            if (dr["FTYPENAME"].ToString().Contains("资产"))
                            {
                                fTypeName = "SLD04_SYS";
                                ywTypeName = "ZCCG";
                            }
                            model.Add("FBILLTYPEID", new JObject() { ["Fnumber"] = fTypeName }); //单据类型
                            model.Add("FBusinessType", ywTypeName); //业务类型
                            model.Add("FBILLNO", dr["HBillNo"].ToString()); //单据编号
                            model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //通知日期
                            model.Add("FStockOrgId", new JObject() { ["Fnumber"] = dr["FRECEIVENUMBER"].ToString() }); // 收料组织
                            model.Add("FPurOrgId", new JObject() { ["Fnumber"] = dr["FPURCHASEORGNUMBER"].ToString() }); //采购组织
                            model.Add("FSupplierId", new JObject() { ["Fnumber"] = dr["FSUPPLIERNUMBER"].ToString() }); //供应商
                            model.Add("FPURCHASERID", new JObject() { ["Fnumber"] = dr["FPURCHASERNUMBER"].ToString() }); //采购员
                            model.Add("FOwnerTypeIdHead", "BD_Supplier");//  货主类型
                            model.Add("FOwnerIdHead", new JObject() { ["Fnumber"] = dr["FSUPPLIERNUMBER"].ToString() });//货主 供应商
                            JArray Fentity = new JArray();
                            foreach (var item in drs)
                            {
                                JObject FentityModel = new JObject();
                                FentityModel.Add("FMaterialId", new JObject() { ["Fnumber"] = item["FMATERIALNUMBER"].ToString() }); // 物料编码
                                FentityModel.Add("FUnitID", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); // 单位
                                FentityModel.Add("FPreDeliveryDate", DateTime.Now.ToString("yyyy-MM-dd")); //预计到货日期
                                FentityModel.Add("FPriceUnitId", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); // 计价单位
                                FentityModel.Add("FStockUnitID", new JObject() { ["Fnumber"] = item["FUNITNUMBER"].ToString() }); //  库存单位
                                FentityModel.Add("FStockID", new JObject() { ["Fnumber"] = "BJCK-SH.01.005" }); //  库存单位
                                FentityModel.Add("FActReceiveQty", Convert.ToDecimal(item["HQTY"])); // 供应商送货数量(提料计划数量 - 已生成送货单数量)
                                FentityModel.Add("FOwnerTypeId", "BD_OwnerOrg");//货主类型
                                FentityModel.Add("FOwnerID", new JObject() { ["Fnumber"] = dr["FPURCHASEORGNUMBER"].ToString() });//货主
                                FentityModel.Add("FSrcId", item["FID"].ToString());//源单内码
                                FentityModel.Add("FSRCFORMID", "PUR_PurchaseOrder");//源单类型
                                FentityModel.Add("FSrcBillNo", item["FBILLNO"].ToString());//源单单号
                                FentityModel.Add("FSRCENTRYID", item["FENTRYID"].ToString());//源单分录内码
                                FentityModel.Add("FORDERBILLNO", item["FBILLNO"].ToString());//源单单号
                                FentityModel.Add("FPOORDERENTRYID", item["FENTRYID"].ToString());//源单分录内码
                                FentityModel.Add("FSRMENTRYID", item["HENTRYID"].ToString());//SRM hentryid
                                FentityModel.Add("FPrice", item["FPRICE"].ToString());//单价
                                FentityModel.Add("FTaxPrice", item["FTAXPRICE"].ToString());//含税单价
                                FentityModel.Add("FEntryTaxRate", item["FTAXRATE"].ToString());//税率
                                FentityModel.Add("FGiveAway", item["FGIVEAWAY"].ToString());//是否赠品
                JObject jsonModel = new JObject();
                jsonModel.Add("FID", FID);
                JArray Entry = new JArray();
                foreach (var item in list)
                {
                    if (item.HSQty == 0)
                        continue;
                    JObject jsonFPOOrderEntry = new JObject();
                    jsonFPOOrderEntry.Add("FEntryID", item.FEntryID);
                    jsonFPOOrderEntry.Add("FActReceiveQty ", item.HSQty); ;
                    Entry.Add(jsonFPOOrderEntry);
                                JArray Fentity2 = new JArray();
                                JObject FentityModel2 = new JObject();
                                FentityModel2.Add("FDetailEntity_Link_FRULEID", "PUR_PurchaseOrder-PUR_ReceiveBill");
                                FentityModel2.Add("FDetailEntity_Link_FSTableName", "t_PUR_POOrderEntry");
                                FentityModel2.Add("FDetailEntity_Link_FSBillId", item["FID"].ToString());
                                FentityModel2.Add("FDetailEntity_Link_FSId", item["FEntryID"].ToString());
                                Fentity2.Add(FentityModel2);
                                FentityModel.Add("FDetailEntity_Link", Fentity2);
                                Fentity.Add(FentityModel);
                            }
                            model.Add("FDetailEntity", Fentity); //明细信息
                            JObject _FentityModel = new JObject();
                            _FentityModel.Add("FSettleOrgId", new JObject() { ["Fnumber"] = dr["FSETTLEORGNUMBER"].ToString() }); //  结算组织
                            _FentityModel.Add("FSettleCurrId", new JObject() { ["Fnumber"] = dr["FSETTLECURRNUMBER"].ToString() }); //  结算币别
                            _FentityModel.Add("FPricePoint", 0); //  定价时点
                            model.Add("FinanceEntity ", _FentityModel);//财务信息
                            JObject jsonRoot = new JObject()
                            {
                                ["Creator"] = "",
                                ["NeedUpDateFields"] = new JArray(),
                                ["NeedReturnFields"] = new JArray(),
                                ["IsDeleteEntry"] = "false",
                                ["SubSystemId"] = "",
                                ["IsVerifyBaseDataField"] = "false",
                                ["Model"] = model
                            };
                            var loginRet = InvokeHelper.Login();
                            var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
                            if (isSuccess == 0)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = loginRet;
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            //LogService.Write("jsonRoot:" + jsonRoot.ToString());
                            var result = InvokeHelper.Save("PUR_ReceiveBill", jsonRoot.ToString());
                            //LogService.Write(result);
                            if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() == "TRUE")
                            {
                                //更新送货单 主表 ERP单据号 以及 ERP主内玛
                                string FBillNo = JObject.Parse(result)["Result"]["Number"].ToString();
                                FID = JObject.Parse(result)["Result"]["Id"].ToString();
                                string updateSql = string.Format(@"
                                                      update a set
                                                      a.HERPInterID = {0} ,
                                                      a.HERPBillNO   ='{1}'
                                                      from Cg_POInStockBillMain a
                                                      join Cg_POInStockBillSub b on a.hinterid = b.hinterid
                                                      where b.HInterID = ({2})
                                                      and b. HSOURCEINTERID = {3}
                                                      and a.HERPInterID = 0
                                                     ", FID, FBillNo, dr["HINTERID"].ToString(), dr["FID"].ToString());
                                oCn.RunProc(updateSql);
                            }
                            else
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = result;
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                        }
                    }
                    else
                    {
                        LogService.Write("收料通知单审核无数据:" + sql);
                    }
                }
                jsonModel.Add("FDetailEntity", Entry);
                jsonRoot.Add("Model", jsonModel);
                var loginRet = InvokeHelper.Login();
                var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
                if (isSuccess <= 0)
                else //夏宝 ,更新erp信息
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = loginRet;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                var result = InvokeHelper.Save("PUR_ReceiveBill", jsonRoot.ToString());
                //LogService.Write(result);
                if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
                {
                    LogService.Write("收料通知单修改失败jsonRoot:" + jsonRoot.ToString());
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "金蝶收料通知单更新失败" + result;
                    objJsonResult.data = null;
                    return objJsonResult;
                    JObject jsonRoot = new JObject();
                    jsonRoot.Add("Creator", "");
                    jsonRoot.Add("NeedUpDateFields", new JArray());
                    jsonRoot.Add("NeedReturnFields", new JArray());
                    jsonRoot.Add("IsDeleteEntry", "false");
                    jsonRoot.Add("SubSystemId", "");
                    jsonRoot.Add("IsVerifyBaseDataField", "");
                    JObject jsonModel = new JObject();
                    jsonModel.Add("FID", FID);
                    JArray Entry = new JArray();
                    foreach (var item in list)
                    {
                        if (item.HSQty == 0)
                            continue;
                        JObject jsonFPOOrderEntry = new JObject();
                        jsonFPOOrderEntry.Add("FEntryID", item.FEntryID);
                        jsonFPOOrderEntry.Add("FActReceiveQty ", item.HSQty); ;
                        Entry.Add(jsonFPOOrderEntry);
                    }
                    jsonModel.Add("FDetailEntity", Entry);
                    jsonRoot.Add("Model", jsonModel);
                    var loginRet = InvokeHelper.Login();
                    var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
                    if (isSuccess <= 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = loginRet;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    var result = InvokeHelper.Save("PUR_ReceiveBill", jsonRoot.ToString());
                    //LogService.Write(result);
                    if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
                    {
                        LogService.Write("收料通知单修改失败jsonRoot:" + jsonRoot.ToString());
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "金蝶收料通知单更新失败" + result;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                var json = new
                {
                    Ids = FID,
                };
                //LogService.Write(json);
                //提交
                var _result = InvokeHelper.Submit("PUR_ReceiveBill", JsonConvert.SerializeObject(json));
                var _saveObj = JObject.Parse(_result);
                if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
                {
                    LogService.Write("收料通知单提交失败jsonRoot:" + jsonRoot.ToString());
                    LogService.Write("收料通知单提交失败jsonRoot:" + json.ToString());
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "金蝶收料通知单提交失败" + _result;
@@ -1612,7 +5289,7 @@
                _saveObj = JObject.Parse(_result);
                if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
                {
                    LogService.Write("收料通知单审核失败jsonRoot:" + jsonRoot.ToString());
                    LogService.Write("收料通知单审核失败jsonRoot:" + json.ToString());
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "金蝶收料通知单审核失败jsonRoot" + _result;
@@ -1640,6 +5317,82 @@
        }
        [Route("POStockInBillList/AuditPOInStockBillPost_TianKang")]
        [HttpGet]
        public object AuditPOInStockBill_TianKang(long FID,string user)
        {
            try
            {
                //string _msg = msg["msg"].ToString();
                //_msg = _msg.Replace("\\", "");
                //_msg = _msg.Replace("\n", "");
                //List<Models.ReciveBill_FastModel> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.ReciveBill_FastModel>>(_msg);
                //DAL.ClsCg_POInStockBill oBill = new DAL.ClsCg_POInStockBill();
                //var hinterID = list[0].HInterID;
                //var FID = list[0].FID;
                //string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo);//客户名称
                //var kdTbaleName = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "DataBaseName");
                //string sql = string.Empty;
                var json = new
                {
                    Ids = FID,
                };
                //LogService.Write(json);
                //登录
                var loginRet = InvokeHelper.LoginUser(user);
                var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
                if (isSuccess <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = loginRet;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //提交
                var _result = InvokeHelper.Submit("PUR_ReceiveBill", JsonConvert.SerializeObject(json));
                var _saveObj = JObject.Parse(_result);
                if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
                {
                    LogService.Write("收料通知单提交失败jsonRoot:" + json.ToString());
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "金蝶收料通知单提交失败" + _result;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //审核
                _result = InvokeHelper.Audit("PUR_ReceiveBill", JsonConvert.SerializeObject(json));
                _saveObj = JObject.Parse(_result);
                if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
                {
                    LogService.Write("收料通知单审核失败jsonRoot:" + json.ToString());
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "金蝶收料通知单审核失败jsonRoot" + _result;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "操作成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                //oCn.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "异常!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        /// <summary>
        /// 到货确认 扫条码 校验
        /// </summary>
@@ -1654,8 +5407,15 @@
            {
                //var code = HBarcode.Split('#')[0];
                //校验条码是否存在
                string sql = $"select* from  Gy_BarCodeBill where HSourceInterID ={HInterID} and HBarCode = '{HBarcode.Split('#')[0]}' and HQty = {HBarcode.Split('#')[1]}";
                DataSet ds = oCn.RunProcReturn(sql, "H_v_SRM_POOrderBillList");
                string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo);//客户名称
                string sql = string.Empty;
                if (FCusName.Contains("安瑞"))
                    sql = $"select top 1 HItemID,HSourceBillNo,HQty,HSourceInterID,HSourceEntryID from  Gy_BarCodeBill where HSourceInterID =(select distinct HSourceInterID from Cg_POInStockBillSub where HInterID ={HInterID}) and HBarCode = '{HBarcode}' and HBarCodeType ='箱号内条码'";
                else if(FCusName.Contains("添康科技"))
                    sql = $"select top 1 HItemID,HSourceBillNo,HQty,HSourceInterID,HSourceEntryID,HMaterID,HBatchNo,HProduceDate,HExpiryDate from  Gy_BarCodeBill where HSourceInterID = {HInterID} and HBarCode = '{HBarcode}' and HBarCodeType ='箱号内条码'";
                else
                    sql = $"select HItemID,HSourceBillNo,HQty,HSourceInterID,HSourceEntryID from  Gy_BarCodeBill where HSourceInterID ={HInterID} and HBarCode = '{HBarcode.Split('#')[0]}' and HQty = {HBarcode.Split('#')[1]}";
                DataSet ds = oCn.RunProcReturn(sql, "Gy_BarCodeBill");
                if (ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
@@ -1663,6 +5423,29 @@
                    objJsonResult.Message = "条码不存在!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
                else
                {
                    //存入条码临时表
                    sql = $"delete from KF_PonderationBillMain_Temp Where HBillNo='{ds.Tables[0].Rows[0]["HSourceBillNo"]}' ";
                    oCn.RunProc(sql);
                    sql = string.Format(@"Insert into KF_PonderationBillMain_Temp
   (HInterID,HBillNo,HBillType,HMaterID,HProcID,HWhID,HSCWHID
   ,HStockPlaceID,HOutStockPlaceID,HGroupID,HQty,HQtyMust,HPieceQty
   ,HAuxPropID,HBatchNo,HBarCode,HAddr,HMaker,HMakeDate
   ,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo,HMTONo
   ,HSTOCKORGID,HOWNERID,HExpressNumber,HSubBillType
   ,HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag
   ,HCusID)
   select HInterID,HSourceBillNo,HBillType,HMaterID,0,0,0
   ,0,0,0,HQty,HQty,0
   ,HAuxPropID,HBatchNo,'','','System',getdate()
   ,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo,HMTONo
   ,HSTOCKORGID,HOWNERID,'',HBillType
   ,0,0,'',0
   ,0 from Gy_BarCodeBill
   where HItemID = {0}", ds.Tables[0].Rows[0]["HItemID"]);
                    oCn.RunProc(sql);
                }
                objJsonResult.code = "1";
@@ -1726,7 +5509,7 @@
                };
                string result1 = string.Empty;
                string result2 = string.Empty;
                DataSet Ds = oCn.RunProcReturn("select FDOCUMENTSTATUS,FID from  AIS20210811135644..T_PUR_RECEIVE where FBILLNO='" + HBarCode + "'", "AIS20210811135644..T_PUR_RECEIVE");
                DataSet Ds = oCn.RunProcReturn("select FDOCUMENTSTATUS,FID from  AIS20220914133941..T_PUR_RECEIVE where FBILLNO='" + HBarCode + "'", "AIS20220914133941..T_PUR_RECEIVE");
                //判断当前收料通知单状态——已创建则先提交再审核、以提交则只审核
                if (Ds.Tables[0].Rows[0][0].ToString() == "A" || Ds.Tables[0].Rows[0][0].ToString() == "D")
                {