YL
2022-01-26 989c2a4d2777f74ade9e3597a4a8c98f957cbee8
加日志文件
2个文件已修改
1个文件已添加
1175 ■■■■ 已修改文件
CLOUDWEB/CLOUDWEB.csproj 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CLOUDWEB/Log.cs 91 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CLOUDWEB/WebService1.asmx.cs 1083 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CLOUDWEB/CLOUDWEB.csproj
@@ -317,6 +317,7 @@
    <Compile Include="Global.asax.cs">
      <DependentUpon>Global.asax</DependentUpon>
    </Compile>
    <Compile Include="Log.cs" />
    <Compile Include="LogService.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="Site.Master.cs">
CLOUDWEB/Log.cs
New file
@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
namespace CLOUDWEB
{
    public class Log
    {
        public static void WriteListToTextFile(List<string> list)
        {
            string uploadPath = System.Web.HttpContext.Current.Server.MapPath("./") + "Log\\";
            if (!Directory.Exists(uploadPath))
            {
                Directory.CreateDirectory(uploadPath);
            }
            string fileName = DateTime.Now.ToString("yyyy-MM-dd") + "_sql.log";
            string txtFile = uploadPath + fileName;
            //创建一个文件流,用以写入或者创建一个StreamWriter
            FileStream fs = new FileStream(txtFile, FileMode.OpenOrCreate, FileAccess.Write);
            StreamWriter sw = new StreamWriter(fs);
            sw.Flush();
            // 使用StreamWriter来往文件中写入内容
            sw.BaseStream.Seek(0, SeekOrigin.Begin);
            for (int i = 0; i < list.Count; i++) sw.WriteLine(list[i]);
            //关闭此文件t
            sw.Flush();
            sw.Close();
            fs.Close();
        }
        public static void LogInfo(string msg)
        {
            string uploadPath = System.Web.HttpContext.Current.Server.MapPath("./") + "Log\\";
            if (!Directory.Exists(uploadPath))
            {
                Directory.CreateDirectory(uploadPath);
            }
            string fileName = DateTime.Now.Ticks.ToString() + ".log";
            FileStream fs;
            StreamWriter sw;
            string sFileName = uploadPath + fileName;
            if (File.Exists(sFileName))
            //验证文件是否存在,有则追加,无则创建
            {
                fs = new FileStream(sFileName, FileMode.Append, FileAccess.Write);
            }
            else
            {
                fs = new FileStream(sFileName, FileMode.Create, FileAccess.Write);
            }
            sw = new StreamWriter(fs);
            msg = String.Format("------------------------{0}------------------------------\r\n", DateTime.Now) + msg;
            msg += "\r\n";
            sw.WriteLine(msg);
            sw.Close();
            fs.Close();
        }
        public static void LogSaveInfo(string msg)
        {
            string uploadPath = System.Web.HttpContext.Current.Server.MapPath("./") + "Log\\";
            if (!Directory.Exists(uploadPath))
            {
                Directory.CreateDirectory(uploadPath);
            }
            string fileName = DateTime.Now.ToString("yyyy-MM-dd") + ".log";
            FileStream fs;
            StreamWriter sw;
            string sFileName = uploadPath + fileName;
            if (File.Exists(sFileName))
            //验证文件是否存在,有则追加,无则创建
            {
                fs = new FileStream(sFileName, FileMode.Append, FileAccess.Write);
            }
            else
            {
                fs = new FileStream(sFileName, FileMode.Create, FileAccess.Write);
            }
            sw = new StreamWriter(fs);
            msg = String.Format("------------------------{0}------------------------------\r\n", DateTime.Now) + msg;
            msg += "\r\n";
            sw.WriteLine(msg);
            sw.Close();
            fs.Close();
        }
    }
}
CLOUDWEB/WebService1.asmx.cs
@@ -5469,6 +5469,7 @@
        [WebMethod]
        public bool set_SaveICMOProductReportBill_LayuiYqn(Model.ClsSc_ICMOReportBillMain oMain, string workcode, int HSourceID, string sHSourceType,string HProcID, ref string sErrMsg)
        {
            Log.LogInfo(workcode.ToString()); //记录提交数据
            //获取系统参数
            Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
            if (oSystemParameter.ShowBill(ref sErrMsg) == false)
@@ -5580,9 +5581,10 @@
                //根据生产订单号查询生产订单表,拿到组织、车间
                DataSet ds0 = oCn.RunProcReturn("select HPRDORGID,HDeptID from Sc_ICMOBillMain with(nolock) where HBillNo='" + workcode + "'", "Sc_ICMOBillMain");
                //查询产量汇报临时表
                DataSet ds = oCn.RunProcReturn("select top 1 * from  Sc_ICMOBillWorkQtyStatus_Tmp with(nolock) where HICMOReportInterID='" + oMain.HInterID + "' and HICMOReportBillNo='" + oMain.HBillNo + "' and HProcID='" + HProcID + "'", "Sc_ICMOBillWorkQtyStatus_Tmp");
                if (ds.Tables[0].Rows.Count <= 0)
                {
                    sErrMsg = "当前单据无产量汇报记录!";
@@ -5594,32 +5596,36 @@
                oMain.HPRDORGID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HPRDORGID"]);
                //插入子表
                oCn.RunProc("exec h_p_Sc_ICMOReportBillSub_Insert_WorkQtyYqn " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + sHSourceType + "'");
                //Log.LogInfo("执行通过2");
                //插入主表
                oCn.RunProc("Insert Into Sc_ICMOReportBillMain " +
                "(HBillType,HBillSubType,HInterID,HBillNo,HDate" +
                ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
                ",HEmpID,HGroupID,HDeptID,HPRDORGID" +
                ") " +
                " values('3711','3711'," + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "',convert(varchar(10),getdate(),120)" +
                ", " + oMain.HYear.ToString() + "," + oMain.HPeriod.ToString() + ",'" + oMain.HRemark + "','" + oMain.HMaker + "',convert(varchar(10),getdate(),120)" +
                ", " + oMain.HEmpID.ToString() + "," + oMain.HGroupID.ToString() + "," + oMain.HDeptID.ToString() + "," + oMain.HPRDORGID.ToString() +
                ") ");
                oCn.RunProc("Insert Into Sc_ProcessReportMain" +
               "(HYear,HPeriod,HBillType,HBillSubType,HInterID" +
               ",HDate,HBillNo,HBillStatus,HCheckItemNowID,HCheckItemNextID" +
               ",HICMOInterID,HICMOBillNo ,HDeptID ,HDeptNumber,HGroupID" +
               ",HGroupNumber,HMaterID,HMaterNumber,HUnitID,HUnitNumber" +
               ",HPlanQty,HInStockQty,HSumTimes,HExplanation,HRemark" +
               ",HInnerBillNo,HMaker,HMakeDate,HSupID,HMarker" +
               ") " +
               " values('" + oMain.HYear.ToString() + "','"+ oMain.HPeriod.ToString() + "','3714','3714','"+ oMain.HInterID.ToString() + "'" +
               ", convert(varchar(10),getdate(),120),'"+oMain.HBillNo+"','2','0','0'" +
               ", '"+oMain.HMainSourceInterID+"','','" + oMain.HDeptID.ToString() + "','','"+ ds.Tables[0].Rows[0]["HGroupID"].ToString() +"'" +
               ", '','" + ds.Tables[0].Rows[0]["HMaterID"].ToString() + "','','0',''" +
               ", '" + ds.Tables[0].Rows[0]["HPlanQty"].ToString() + "','0','0','同步erp生产汇报单','报工台同步工序汇报单'" +
               ",'','" +oMain.HMaker+ "','" + oMain.HDate + "','0',''" +
               ") ");
                //更新生产状态临时表(当日完工数量)HDateFinishQty  h_p_JIT_Sc_ICMOBillStatus_Tmp_Qty
                oCn.RunProc("exec h_p_JIT_Sc_ICMOBillStatus_Tmp_QtyYqn '" + workcode + "','" + HSourceID + "','"+HProcID+"','" + oMain.HMainSourceInterID + "','" + oMain.HMainSourceEntryID + "'");
                //string sql1 = string.Format(@"update Sc_ICMOBillWorkQtyStatus_Tmp  set
                //                 HICMOReportInterID ='" + oMain.HInterID + "', HICMOReportBillNo='" + oMain.HBillNo + "' from Sc_ICMOBillWorkQtyStatus_Tmp a where a.HICMOBillNo='" + workcode + "' and a.HSourceID='" + HSourceID + "' and  HICMOInterID='" + oMain.HMainSourceInterID + "' and a.HICMOEntryID='" + oMain.HMainSourceEntryID + "' and a.HMaker='" + oMain.HMaker + "'  and HRelationInterID='0'");
                //oCn.RunProc(sql1);
                //string sql1 = string.Format(@"update Sc_ICMOBillStatus_Tmp ");
                //oCn.RunProc("exec h_p_JIT_Sc_ICMOBillStatus_Tmp_QtyYqn '" + workcode + "','" + HSourceID + "','"+HProcID+"','" + oMain.HMainSourceInterID + "','" + oMain.HMainSourceEntryID + "'");
                //更新关联数量
                oCn.RunProc("exec h_p_Sc_UpDateRelation_ICMOToICMOReport_Add " + oMain.HInterID.ToString());
                oCn.RunProc("exec h_p_Sc_UpDateRelation_ICMOToICMOReport_AddYqn " + oMain.HInterID.ToString());
                if (oSystemParameterMain.Sc_ICMOReportBill_AutoCheck == "Y") //系统参数  自动审核 
                {
                    //审核单据
                    oCn.RunProc("Update Sc_ICMOReportBillMain Set HChecker='" + oMain.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120),HBillStatus=2 where HInterID= " + oMain.HInterID.ToString());
                    oCn.RunProc("Update Sc_ProcessReportMain Set HChecker='" + oMain.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120),HBillStatus=2 where HInterID= " + oMain.HInterID.ToString());
                }
                //根据TMP表 返回 子表信息
@@ -5632,6 +5638,7 @@
                }
                else
                {
                    Log.LogInfo("执行通过s");
                    string sJson_ZYMESFLAG = "";    //生产汇报单同步MES标记
                    sJson_ZYMESFLAG = Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FHZYMESFLAG"]);
@@ -5691,6 +5698,7 @@
                        " \"FREPORTTYPE\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FREPORTTYPE"]) + "\"}," +
                        " \"FUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FUNITID"]) + "\"}," +
                        " \"FWORKSHIPID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FWORKSHOPID"]) + "\"}," +
                        " \"FShiftGroupId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["HGROUPID"]) + "\"}," +
                        //\"FShiftGroupId\":{\"FNumber\":\"\"},
                        sJson_BatchNo +
                        //\"FDeptId\":{\"FNumber\":\"\"},
@@ -5729,6 +5737,8 @@
                        " \"FSTOCKID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKID"]) + "\"}," +
                        " \"FCOSTRATE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCOSTRATE"]) + "," +
                        " \"FSNUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSNUNITID"]) + "\"}," +
                        " \"F_zzzz_procedure\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["HSOURCENAME"]) + "\"," +
                        " \"F_zzzz_equipment\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["HPROCNAME"]) + "\"," +
                        //\"FSNQty\":\"0\",
                        //\"FProduceDate\":\"1900-01-01\",
                        //\"FExpiryDate\":\"1900-01-01\",
@@ -5852,7 +5862,7 @@
            }
            catch (Exception e)
            {
                sErrMsg = "生成生产汇报单失败!" + e.Message;
                sErrMsg = "生成生产汇报单失败Erro!" + e.Message+e.StackTrace;
                oCn.RollBack();
                return false;
            }
@@ -32661,199 +32671,67 @@
        [WebMethod]
        public Model.ClsKf_ICStockBill_WMS get_CheckTypeByBarCode_All(string sBarCode, Int64 HBillID, string HBillType, string HBillNo, string HMaker, Int64 HWhID, Int64 HSPID, Double HQty, bool HRedBlueFlag, bool SourceFlag, string HSourceBillNo, string HSourceBillType, Int64 HOWNERID, string HExpressNumber, ref string sErrMsg)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            Model.ClsKf_ICStockBill_WMS oBar = new Model.ClsKf_ICStockBill_WMS();
            DAL.ClsKF_PonderationBillMain_Temp_Ctl tem = new DAL.ClsKF_PonderationBillMain_Temp_Ctl();
            Model.ClsKF_PonderationBillMain_Temp model = new Model.ClsKF_PonderationBillMain_Temp();
            string sHSourceBillType = "";
            string sHSourceBillNo = "";
            Int64 sHSupID = 0;
            string sHSupName = "";
            Int64 sHDeptID = 0;
            string sHDeptName = "";
            string sHBarType = "";
            sBarCode = sBarCode.Trim();
            string sBarCodePrefix = sBarCode.Substring(0, Math.Min(3, sBarCode.Length));//截取条码前三位字符串
            try
            {
                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                Model.ClsKf_ICStockBill_WMS oBar = new Model.ClsKf_ICStockBill_WMS();
                DAL.ClsKF_PonderationBillMain_Temp_Ctl tem = new DAL.ClsKF_PonderationBillMain_Temp_Ctl();
                Model.ClsKF_PonderationBillMain_Temp model = new Model.ClsKF_PonderationBillMain_Temp();
                string sHSourceBillType = "";
                string sHSourceBillNo = "";
                Int64 sHSupID = 0;
                string sHSupName = "";
                Int64 sHDeptID = 0;
                string sHDeptName = "";
                string sHBarType = "";
                sBarCode = sBarCode.Trim();
                string sBarCodePrefix = sBarCode.Substring(0, Math.Min(3, sBarCode.Length));//截取条码前三位字符串
            //获取系统参数
            Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
            if (oSystemParameter.ShowBill(ref sErrMsg) == false)
            {
                sErrMsg = "获取系统参数失败! " + sErrMsg;
                return null;
            }
            //销售出库、销售退库模块扫码流程   飞龙专用
            if ((HBillType == "1205" || HBillType == "1247") && oSystemParameter.omodel.WMS_CampanyName == "飞龙") //系统参数  客户定制化名称     空白为通用
            {
                //将物料条码信息写入出入库条码临时表
                if (set_SavePonderationBillMain_Temp_FeiLong(sBarCode, HBillID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, HRedBlueFlag, SourceFlag, HSourceBillNo, HSourceBillType, HOWNERID, HExpressNumber, ref sHSourceBillNo, ref sHSourceBillType, ref sHSupID, ref sHSupName, ref sHDeptID, ref sHDeptName, ref sHBarType, ref sErrMsg))
                //获取系统参数
                Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
                if (oSystemParameter.ShowBill(ref sErrMsg) == false)
                {
                    oBar.HBarType = sHBarType;
                    oBar.HSourceBillType = sHSourceBillType;
                    oBar.HSourceBillNo = sHSourceBillNo;
                    oBar.HSupID = sHSupID;
                    oBar.HSupName = sHSupName;
                    oBar.HDeptID = sHDeptID;
                    oBar.HDeptName = sHDeptName;
                }
                else
                {
                    sErrMsg = "!" + sErrMsg;
                    sErrMsg = "获取系统参数失败! " + sErrMsg;
                    return null;
                }
                return oBar;
            }
            //生产入库  多源单模式
            else if (HBillType == "1202" && oSystemParameter.omodel.Kf_ProductInBill_MulSourceBill == "Y")
            {
                oBar = get_CheckTypeByBarCode_MulSourceBill(sBarCode, HBillID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, HRedBlueFlag, SourceFlag, HSourceBillNo, HSourceBillType, HOWNERID, HExpressNumber, oSystemParameter.omodel, ref sErrMsg);
                if (oBar == null)
                //销售出库、销售退库模块扫码流程   飞龙专用
                if ((HBillType == "1205" || HBillType == "1247") && oSystemParameter.omodel.WMS_CampanyName == "飞龙") //系统参数  客户定制化名称     空白为通用
                {
                    return null;
                }
                else
                {
                    //将物料条码信息写入出入库条码临时表
                    if (set_SavePonderationBillMain_Temp_FeiLong(sBarCode, HBillID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, HRedBlueFlag, SourceFlag, HSourceBillNo, HSourceBillType, HOWNERID, HExpressNumber, ref sHSourceBillNo, ref sHSourceBillType, ref sHSupID, ref sHSupName, ref sHDeptID, ref sHDeptName, ref sHBarType, ref sErrMsg))
                    {
                        oBar.HBarType = sHBarType;
                        oBar.HSourceBillType = sHSourceBillType;
                        oBar.HSourceBillNo = sHSourceBillNo;
                        oBar.HSupID = sHSupID;
                        oBar.HSupName = sHSupName;
                        oBar.HDeptID = sHDeptID;
                        oBar.HDeptName = sHDeptName;
                    }
                    else
                    {
                        sErrMsg = "!" + sErrMsg;
                        return null;
                    }
                    return oBar;
                }
            }
            else
            {
                //判断是否启用一键扫码模式,Y为启用,未启用时只扫描物料条码
                if (oSystemParameter.omodel.WMS_OneKeyMode.ToUpper() == "N")
                //生产入库  多源单模式
                else if (HBillType == "1202" && oSystemParameter.omodel.Kf_ProductInBill_MulSourceBill == "Y")
                {
                    if (oSystemParameter.omodel.WMS_CampanyName == "博日科技" || oSystemParameter.omodel.WMS_CampanyName == "杭州智见" || oSystemParameter.omodel.WMS_CampanyName == "杭州斯莫尔" || oSystemParameter.omodel.WMS_CampanyName == "奥邦") //系统参数  客户定制化名称     空白为通用
                    oBar = get_CheckTypeByBarCode_MulSourceBill(sBarCode, HBillID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, HRedBlueFlag, SourceFlag, HSourceBillNo, HSourceBillType, HOWNERID, HExpressNumber, oSystemParameter.omodel, ref sErrMsg);
                    if (oBar == null)
                    {
                        DAL.ClsGy_BarCodeBill_View dal = new DAL.ClsGy_BarCodeBill_View();
                        if (dal.GetInfoByNumber_View(sBarCode))
                        {
                            //如果是托盘条码分解并模拟扫码
                            if (dal.omodel_View.HBarCodeType == "托盘条码")
                            {
                                //分解托条码得到明细条码信息写入出入库条码临时表
                                DataSet dsTBarCode;
                                string sBarCode_MX;
                                dsTBarCode = oCn.RunProcReturn("select HBarCode HBarCodeMX from Sc_PackUnionBillSub_Sum " +
                                " Where HBarCode_Pack = '" + sBarCode + "'", "Sc_PackUnionBillSub_Sum");
                                if (dsTBarCode == null || dsTBarCode.Tables[0].Rows.Count == 0)
                                {
                                    sErrMsg = "没有找到托盘条码对应子条码记录!";
                                    return null;
                                }
                                else
                                {
                                    for (int i = 0; i < dsTBarCode.Tables[0].Rows.Count; i++)
                                    {
                                        sBarCode_MX = DBUtility.ClsPub.isStrNull(dsTBarCode.Tables[0].Rows[i]["HBarCodeMX"]);
                                        if (set_SavePonderationBillMain_Temp_BarCode(sBarCode_MX, HBillID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, HRedBlueFlag, SourceFlag, HSourceBillNo, HSourceBillType, HOWNERID, HExpressNumber, ref sHSourceBillNo, ref sHSourceBillType, ref sHSupID, ref sHSupName, ref sHDeptID, ref sHDeptName, ref sErrMsg))
                                        {
                                            oBar.HSourceBillType = sHSourceBillType;
                                            oBar.HSourceBillNo = sHSourceBillNo;
                                            oBar.HSupID = sHSupID;
                                            oBar.HSupName = sHSupName;
                                            oBar.HDeptID = sHDeptID;
                                            oBar.HDeptName = sHDeptName;
                                            SourceFlag = true;
                                        }
                                        else
                                        {
                                            sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HBillID + ";扫描失败!" + sBarCode_MX + sErrMsg;
                                            //sErrMsg = "扫描失败!" + sErrMsg;
                                            return null;
                                        }
                                    }
                                    return oBar;
                                }
                            }
                            else
                            {
                                //将物料条码信息写入出入库条码临时表
                                if (set_SavePonderationBillMain_Temp_BarCode(sBarCode, HBillID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, HRedBlueFlag, SourceFlag, HSourceBillNo, HSourceBillType, HOWNERID, HExpressNumber, ref sHSourceBillNo, ref sHSourceBillType, ref sHSupID, ref sHSupName, ref sHDeptID, ref sHDeptName, ref sErrMsg))
                                {
                                    oBar.HSourceBillType = sHSourceBillType;
                                    oBar.HSourceBillNo = sHSourceBillNo;
                                    oBar.HSupID = sHSupID;
                                    oBar.HSupName = sHSupName;
                                    oBar.HDeptID = sHDeptID;
                                    oBar.HDeptName = sHDeptName;
                                }
                                else
                                {
                                    sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HBillID + ";扫描失败!" + sErrMsg;
                                    return null;
                                }
                                return oBar;
                            }
                        }
                        else
                        {
                            sErrMsg = "没有找到该条码!";
                            return null;
                        }
                        return null;
                    }
                    else
                    {
                        if (sBarCodePrefix == "PAK")
                        {
                            //将模治具信息写入模治具出入库临时表
                            DataSet Mould = oCn.RunProcReturn("exec h_p_WMS_AddMouldBarCode '" + sBarCode + "'," + HBillID.ToString() + ",'" + HBillNo + "','" + HBillType + "'," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HRedBlueFlag + "','" + HMaker + "'," + HOWNERID.ToString(), "h_p_WMS_AddMouldBarCode");
                            if (Mould == null || Mould.Tables[0].Rows.Count == 0)
                            {
                                sErrMsg = "将模治具信息写入模治具出入库临时表失败!";
                                return null;
                            }
                            else
                            {
                                if (DBUtility.ClsPub.isLong(Mould.Tables[0].Rows[0][0]) == 0)
                                {
                                    oBar.HBarType = "模治具条码";
                                    return oBar;
                                }
                                else
                                {
                                    sErrMsg = DBUtility.ClsPub.isStrNull(Mould.Tables[0].Rows[0]["HRemark"]);
                                    return null;
                                }
                            }
                        }
                        else
                        {
                            //将物料条码信息写入出入库条码临时表
                            if (set_SavePonderationBillMain_Temp_BarCode(sBarCode, HBillID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, HRedBlueFlag, SourceFlag, HSourceBillNo, HSourceBillType, HOWNERID, HExpressNumber, ref sHSourceBillNo, ref sHSourceBillType, ref sHSupID, ref sHSupName, ref sHDeptID, ref sHDeptName, ref sErrMsg))
                            {
                                oBar.HSourceBillType = sHSourceBillType;
                                oBar.HSourceBillNo = sHSourceBillNo;
                                oBar.HSupID = sHSupID;
                                oBar.HSupName = sHSupName;
                                oBar.HDeptID = sHDeptID;
                                oBar.HDeptName = sHDeptName;
                            }
                            else
                            {
                                sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HBillID + ";扫描失败!" + sErrMsg;
                                return null;
                            }
                            return oBar;
                        }
                        return oBar;
                    }
                }
                //一键扫码模式,根据条码前缀走 不同方法(仓库、仓位、部门)(源单、物料条码)
                else
                {
                    string sRedBlue = "蓝字";
                    if (HRedBlueFlag)
                    {
                        sRedBlue = "红字";
                    }
                    else
                    {
                        sRedBlue = "蓝字";
                    }
                    DataSet Dss;
                    //根据递入的条码前三位,判断条码类型(仓库、仓位、部门、源单、物料条码)
                    Dss = oCn.RunProcReturn(" select HSourceName,BarCodeType from Xt_BarCodeType where HSourceNumber= '" + sBarCodePrefix + "'", "Xt_BarCodeType");
                    //无返回数据则为物料条码
                    if (Dss == null || Dss.Tables[0].Rows.Count == 0)
                    //判断是否启用一键扫码模式,Y为启用,未启用时只扫描物料条码
                    if (oSystemParameter.omodel.WMS_OneKeyMode.ToUpper() == "N")
                    {
                        if (oSystemParameter.omodel.WMS_CampanyName == "博日科技" || oSystemParameter.omodel.WMS_CampanyName == "杭州智见" || oSystemParameter.omodel.WMS_CampanyName == "杭州斯莫尔" || oSystemParameter.omodel.WMS_CampanyName == "奥邦") //系统参数  客户定制化名称     空白为通用
                        {
@@ -32970,373 +32848,514 @@
                            }
                        }
                    }
                    //一键扫码模式,根据条码前缀走 不同方法(仓库、仓位、部门)(源单、物料条码)
                    else
                    {
                        string sBarBillName = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HSourceName"]);
                        string sBarBillType = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["BarCodeType"]);
                        //判断条码类型为 基础资料条码 或 源单条码
                        if (sBarBillType == "基础资料条码")
                        string sRedBlue = "蓝字";
                        if (HRedBlueFlag)
                        {
                            //仓库条码
                            if (sBarBillName == "仓库")
                            {
                                DAL.ClsIF_Warehouse_View dal = new DAL.ClsIF_Warehouse_View();
                                //将递入的条码去掉前三位后转化成整形,TryParse不能转换成整数时返回false,并返回ID=0
                                int ID;
                                if (int.TryParse(sBarCode.Remove(0, 3), out ID))
                                {
                                    if (dal.GetInfoByID(ID, HOWNERID))
                                    {
                                        oBar.HBarType = "仓库条码";
                                        oBar.HWhID = dal.omodel.HItemID;
                                        oBar.HWhNumber = dal.omodel.HNumber;
                                        oBar.HWhName = dal.omodel.HName;
                                        oBar.HSPFlag = dal.omodel.HIsStockMgr;
                                        return oBar;
                                    }
                                    else
                                    {
                                        sErrMsg = "无效仓库条码!";
                                        return null;
                                    }
                                }
                                else
                                {
                                    sErrMsg = "错误的仓库条码!";
                                    return null;
                                }
                            }
                            //仓位条码
                            else if (sBarBillName == "仓位")
                            {
                                DAL.ClsIF_StockPlace_View dal = new DAL.ClsIF_StockPlace_View();
                                //将递入的条码去掉前三位后转化成整形
                                int sHSPID;
                                int sHWHID;
                                string[] sArray = sBarCode.Remove(0, 3).Split(';');
                                if (int.TryParse(sArray[1], out sHSPID) && int.TryParse(sArray[0], out sHWHID))
                                {
                                    if (dal.GetInfoByID(sHSPID, sHWHID, HOWNERID))
                                    {
                                        oBar.HBarType = "仓位条码";
                                        oBar.HSPID = dal.omodel.HItemID;
                                        oBar.HSPNumber = dal.omodel.HNumber;
                                        oBar.HSPName = dal.omodel.HName;
                                        oBar.HWhID = dal.omodel.HWHID;
                                        oBar.HWhNumber = dal.omodel.HWhNumber;
                                        oBar.HWhName = dal.omodel.HWhName;
                                        return oBar;
                                    }
                                    else
                                    {
                                        sErrMsg = "无效仓位条码!";
                                        return null;
                                    }
                                }
                                else
                                {
                                    sErrMsg = "错误的仓位条码!";
                                    return null;
                                }
                            }
                            //部门条码
                            else if (sBarBillName == "部门")
                            {
                                DAL.ClsIF_Department_View dal = new DAL.ClsIF_Department_View();
                                //将递入的条码去掉前三位后转化成整形
                                int ID;
                                if (int.TryParse(sBarCode.Remove(0, 3), out ID))
                                {
                                    if (dal.GetInfoByID(ID))
                                    {
                                        oBar.HBarType = "部门条码";
                                        oBar.HDeptID = dal.omodel.HItemID;
                                        oBar.HDeptNumber = dal.omodel.HNumber;
                                        oBar.HDeptName = dal.omodel.HName;
                                        return oBar;
                                    }
                                    else
                                    {
                                        sErrMsg = "无效部门条码!";
                                        return null;
                                    }
                                }
                                else
                                {
                                    sErrMsg = "错误的部门条码!";
                                    return null;
                                }
                            }
                            else
                            {
                                sErrMsg = "无效基础资料条码!";
                                return null;
                            }
                            sRedBlue = "红字";
                        }
                        //源单条码
                        else if (sBarBillType == "源单条码")
                        else
                        {
                            //当该单据类型的系统参数:多源单模式   时,不允许扫描原单
                            sRedBlue = "蓝字";
                        }
                        DataSet Dss;
                        //根据递入的条码前三位,判断条码类型(仓库、仓位、部门、源单、物料条码)
                        Dss = oCn.RunProcReturn(" select HSourceName,BarCodeType from Xt_BarCodeType where HSourceNumber= '" + sBarCodePrefix + "'", "Xt_BarCodeType");
                            //=======================
                            DataSet Ds = oCn.RunProcReturn(" select HSourceName from Xt_BarCodeType where HSourceNumber= '" + sBarCodePrefix + "' and HBillType= '" + HBillType + "'", "Xt_BarCodeType");
                            if (Ds == null || Ds.Tables[0].Rows.Count == 0)
                        //无返回数据则为物料条码
                        if (Dss == null || Dss.Tables[0].Rows.Count == 0)
                        {
                            if (oSystemParameter.omodel.WMS_CampanyName == "博日科技" || oSystemParameter.omodel.WMS_CampanyName == "杭州智见" || oSystemParameter.omodel.WMS_CampanyName == "杭州斯莫尔" || oSystemParameter.omodel.WMS_CampanyName == "奥邦") //系统参数  客户定制化名称     空白为通用
                            {
                                sErrMsg = "所扫源单条码不属于此模块源单范围!";
                                return null;
                            }
                            else
                            {
                                sBarBillName = Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceName"]);
                                //扫描源单条码时判断是否已经扫描过源单信息
                                if (SourceFlag)
                                DAL.ClsGy_BarCodeBill_View dal = new DAL.ClsGy_BarCodeBill_View();
                                if (dal.GetInfoByNumber_View(sBarCode))
                                {
                                    sErrMsg = "明细信息列表已有扫码记录,不允许多次扫描源单条码!";
                                    return null;
                                    //如果是托盘条码分解并模拟扫码
                                    if (dal.omodel_View.HBarCodeType == "托盘条码")
                                    {
                                        //分解托条码得到明细条码信息写入出入库条码临时表
                                        DataSet dsTBarCode;
                                        string sBarCode_MX;
                                        dsTBarCode = oCn.RunProcReturn("select HBarCode HBarCodeMX from Sc_PackUnionBillSub_Sum " +
                                        " Where HBarCode_Pack = '" + sBarCode + "'", "Sc_PackUnionBillSub_Sum");
                                        if (dsTBarCode == null || dsTBarCode.Tables[0].Rows.Count == 0)
                                        {
                                            sErrMsg = "没有找到托盘条码对应子条码记录!";
                                            return null;
                                        }
                                        else
                                        {
                                            for (int i = 0; i < dsTBarCode.Tables[0].Rows.Count; i++)
                                            {
                                                sBarCode_MX = DBUtility.ClsPub.isStrNull(dsTBarCode.Tables[0].Rows[i]["HBarCodeMX"]);
                                                if (set_SavePonderationBillMain_Temp_BarCode(sBarCode_MX, HBillID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, HRedBlueFlag, SourceFlag, HSourceBillNo, HSourceBillType, HOWNERID, HExpressNumber, ref sHSourceBillNo, ref sHSourceBillType, ref sHSupID, ref sHSupName, ref sHDeptID, ref sHDeptName, ref sErrMsg))
                                                {
                                                    oBar.HSourceBillType = sHSourceBillType;
                                                    oBar.HSourceBillNo = sHSourceBillNo;
                                                    oBar.HSupID = sHSupID;
                                                    oBar.HSupName = sHSupName;
                                                    oBar.HDeptID = sHDeptID;
                                                    oBar.HDeptName = sHDeptName;
                                                    SourceFlag = true;
                                                }
                                                else
                                                {
                                                    sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HBillID + ";扫描失败!" + sBarCode_MX + sErrMsg;
                                                    //sErrMsg = "扫描失败!" + sErrMsg;
                                                    return null;
                                                }
                                            }
                                            return oBar;
                                        }
                                    }
                                    else
                                    {
                                        //将物料条码信息写入出入库条码临时表
                                        if (set_SavePonderationBillMain_Temp_BarCode(sBarCode, HBillID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, HRedBlueFlag, SourceFlag, HSourceBillNo, HSourceBillType, HOWNERID, HExpressNumber, ref sHSourceBillNo, ref sHSourceBillType, ref sHSupID, ref sHSupName, ref sHDeptID, ref sHDeptName, ref sErrMsg))
                                        {
                                            oBar.HSourceBillType = sHSourceBillType;
                                            oBar.HSourceBillNo = sHSourceBillNo;
                                            oBar.HSupID = sHSupID;
                                            oBar.HSupName = sHSupName;
                                            oBar.HDeptID = sHDeptID;
                                            oBar.HDeptName = sHDeptName;
                                        }
                                        else
                                        {
                                            sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HBillID + ";扫描失败!" + sErrMsg;
                                            return null;
                                        }
                                        return oBar;
                                    }
                                }
                                else
                                {
                                    //产品入库单 源单:生产任务单
                                    if (sBarBillName == "生产任务单" && HBillType == "1202")
                                    sErrMsg = "没有找到该条码!";
                                    return null;
                                }
                            }
                            else
                            {
                                if (sBarCodePrefix == "PAK")
                                {
                                    //将模治具信息写入模治具出入库临时表
                                    DataSet Mould = oCn.RunProcReturn("exec h_p_WMS_AddMouldBarCode '" + sBarCode + "'," + HBillID.ToString() + ",'" + HBillNo + "','" + HBillType + "'," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HRedBlueFlag + "','" + HMaker + "'," + HOWNERID.ToString(), "h_p_WMS_AddMouldBarCode");
                                    if (Mould == null || Mould.Tables[0].Rows.Count == 0)
                                    {
                                        DAL.Cls_S_IF_ICMOBill_Lite dal = new DAL.Cls_S_IF_ICMOBill_Lite();
                                        DataSet DS;
                                        //根据单据号获取过滤条件
                                        string sWhere = " Where 单据号 like '" + sBarCode + "'";
                                        DS = dal.DisSourceBillList(sWhere);
                                        if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                        {
                                            sErrMsg = "没有返回任何记录!";
                                            return null;
                                        }
                                        oBar.HBarType = "源单条码";
                                        oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                        oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                        oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                        oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                        oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                        oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                    }
                                    //产品入库单 源单:生产汇报单
                                    else if (sBarBillName == "生产汇报单" && HBillType == "1202")
                                    {
                                        DAL.Cls_S_IF_ICMOReportBill_Lite dal = new DAL.Cls_S_IF_ICMOReportBill_Lite();
                                        DataSet DS;
                                        //根据单据号获取过滤条件
                                        string sWhere = " Where 单据号 like '" + sBarCode + "'";
                                        DS = dal.DisSourceBillList(sWhere);
                                        if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                        {
                                            sErrMsg = "没有返回任何记录!";
                                            return null;
                                        }
                                        oBar.HBarType = "源单条码";
                                        oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                        oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                        oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                        oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                        oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                        oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                    }
                                    //外购入库单 源单:采购订单
                                    else if (sBarBillName == "采购订单" && HBillType == "1201")
                                    {
                                        DAL.Cls_S_IF_POOrderBill_Lite dal = new DAL.Cls_S_IF_POOrderBill_Lite();
                                        DataSet DS;
                                        //根据单据号获取过滤条件
                                        string sWhere = " Where 单据号 like '" + sBarCode + "'";
                                        DS = dal.DisSourceBillList(sWhere);
                                        if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                        {
                                            sErrMsg = "没有返回任何记录!";
                                            return null;
                                        }
                                        oBar.HBarType = "源单条码";
                                        oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                        oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                        oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                        oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                        oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                        oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                    }
                                    //外购入库单 源单:收料通知单
                                    else if (sBarBillName == "收料通知单" && HBillType == "1201")
                                    {
                                        DAL.Cls_S_IF_POInStockBill_Lite dal = new DAL.Cls_S_IF_POInStockBill_Lite();
                                        DataSet DS;
                                        //根据单据号获取过滤条件
                                        string sWhere = " Where 单据号 like '" + sBarCode + "' and isnull(HBillSubType,0)=12510 ";
                                        DS = dal.DisSourceBillList(sWhere);
                                        if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                        {
                                            sErrMsg = "没有返回任何记录!";
                                            return null;
                                        }
                                        oBar.HBarType = "源单条码";
                                        oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                        oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                        oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                        oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                        oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                        oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                    }
                                    //委外入库单 源单:委外订单
                                    else if (sBarBillName == "委外订单" && HBillType == "1210")
                                    {
                                        DAL.Cls_S_IF_WWOrderBill_Lite dal = new DAL.Cls_S_IF_WWOrderBill_Lite();
                                        DataSet DS;
                                        //根据单据号获取过滤条件
                                        string sWhere = " Where 单据号 like '" + sBarCode + "'";
                                        DS = dal.DisSourceBillList(sWhere);
                                        if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                        {
                                            sErrMsg = "没有返回任何记录!";
                                            return null;
                                        }
                                        oBar.HBarType = "源单条码";
                                        oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                        oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                        oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                        oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                        oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                        oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                    }
                                    //委外入库单 源单:收料通知单-委外
                                    else if (sBarBillName == "收料通知单-委外" && HBillType == "1210")
                                    {
                                        DAL.Cls_S_IF_POStockInBill_Lite dal = new DAL.Cls_S_IF_POStockInBill_Lite();
                                        DataSet DS;
                                        //根据单据号获取过滤条件
                                        string sWhere = " Where 单据号 like '" + sBarCode + "' and isnull(HBillSubType,0)=12511 ";
                                        DS = dal.DisSourceBillList(sWhere);
                                        if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                        {
                                            sErrMsg = "没有返回任何记录!";
                                            return null;
                                        }
                                        oBar.HBarType = "源单条码";
                                        oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                        oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                        oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                        oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                        oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                        oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                    }
                                    //领料出库 源单:生产任务单-投料
                                    else if (sBarBillName == "生产任务单-投料" && HBillType == "1204")
                                    {
                                        DAL.Cls_S_IF_PPBomBillList_Lite dal = new DAL.Cls_S_IF_PPBomBillList_Lite();
                                        DataSet DS;
                                        //根据单据号获取过滤条件
                                        string sWhere = " Where 单据号 like '" + sBarCode + "'";
                                        DS = dal.DisSourceBillList(sWhere);
                                        if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                        {
                                            sErrMsg = "没有返回任何记录!";
                                            return null;
                                        }
                                        oBar.HBarType = "源单条码";
                                        oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                        oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                        oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                        oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                        oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                        oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                    }
                                    //销售出库 源单:销售订单
                                    else if (sBarBillName == "销售订单" && HBillType == "1205")
                                    {
                                        DAL.Cls_S_IF_SEOrderBill_Lite dal = new DAL.Cls_S_IF_SEOrderBill_Lite();
                                        DataSet DS;
                                        //根据单据号获取过滤条件
                                        string sWhere = " Where 单据号 like '" + sBarCode + "'";
                                        DS = dal.DisSourceBillList(sWhere);
                                        if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                        {
                                            sErrMsg = "没有返回任何记录!";
                                            return null;
                                        }
                                        oBar.HBarType = "源单条码";
                                        oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                        oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                        oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                        oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                        oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                        oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                        oBar.HCustom = Convert.ToString(DS.Tables[0].Rows[0]["HCustom"]);
                                    }
                                    //销售出库 源单:发货通知单
                                    else if (sBarBillName == "发货通知单" && HBillType == "1205")
                                    {
                                        DAL.Cls_S_IF_SeOutStockBill_Lite dal = new DAL.Cls_S_IF_SeOutStockBill_Lite();
                                        DataSet DS;
                                        //根据单据号获取过滤条件
                                        string sWhere = " Where 单据号 like '" + sBarCode + "'";
                                        DS = dal.DisSourceBillList(sWhere);
                                        if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                        {
                                            sErrMsg = "没有返回任何记录!";
                                            return null;
                                        }
                                        oBar.HBarType = "源单条码";
                                        oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                        oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                        oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                        oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                        oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                        oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                        oBar.HCustom = Convert.ToString(DS.Tables[0].Rows[0]["HCustom"]);
                                    }
                                    //委外出库单 源单:委外订单-投料
                                    else if (sBarBillName == "委外订单-投料" && HBillType == "1211")
                                    {
                                        DAL.Cls_S_IF_WWPPBomBill_Lite dal = new DAL.Cls_S_IF_WWPPBomBill_Lite();
                                        DataSet DS;
                                        //根据单据号获取过滤条件
                                        string sWhere = " Where 单据号 like '" + sBarCode + "'";
                                        DS = dal.DisSourceBillList(sWhere);
                                        if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                        {
                                            sErrMsg = "没有返回任何记录!";
                                            return null;
                                        }
                                        oBar.HBarType = "源单条码";
                                        oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                        oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                        oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                        oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                        oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                        oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                        sErrMsg = "将模治具信息写入模治具出入库临时表失败!";
                                        return null;
                                    }
                                    else
                                    {
                                        sErrMsg = "源单类型名称设置不正确!";
                                        return null;
                                        if (DBUtility.ClsPub.isLong(Mould.Tables[0].Rows[0][0]) == 0)
                                        {
                                            oBar.HBarType = "模治具条码";
                                            return oBar;
                                        }
                                        else
                                        {
                                            sErrMsg = DBUtility.ClsPub.isStrNull(Mould.Tables[0].Rows[0]["HRemark"]);
                                            return null;
                                        }
                                    }
                                    // 将源单信息写入 临时缓存表
                                    if (tem.AddNew_Source(HBillID, HBillNo, HBillType, oBar.HSourceBillNo, oBar.HSourceBillType, sRedBlue, ref sErrMsg))
                                }
                                else
                                {
                                    //将物料条码信息写入出入库条码临时表
                                    if (set_SavePonderationBillMain_Temp_BarCode(sBarCode, HBillID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, HRedBlueFlag, SourceFlag, HSourceBillNo, HSourceBillType, HOWNERID, HExpressNumber, ref sHSourceBillNo, ref sHSourceBillType, ref sHSupID, ref sHSupName, ref sHDeptID, ref sHDeptName, ref sErrMsg))
                                    {
                                        return oBar;
                                        oBar.HSourceBillType = sHSourceBillType;
                                        oBar.HSourceBillNo = sHSourceBillNo;
                                        oBar.HSupID = sHSupID;
                                        oBar.HSupName = sHSupName;
                                        oBar.HDeptID = sHDeptID;
                                        oBar.HDeptName = sHDeptName;
                                    }
                                    else
                                    {
                                        sErrMsg = "保存源单信息失败!" + sErrMsg;
                                        sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HBillID + ";扫描失败!" + sErrMsg;
                                        return null;
                                    }
                                    return oBar;
                                }
                            }
                        }
                        else
                        {
                            sErrMsg = "无效条码类型!";
                            return null;
                            string sBarBillName = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HSourceName"]);
                            string sBarBillType = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["BarCodeType"]);
                            //判断条码类型为 基础资料条码 或 源单条码
                            if (sBarBillType == "基础资料条码")
                            {
                                //仓库条码
                                if (sBarBillName == "仓库")
                                {
                                    DAL.ClsIF_Warehouse_View dal = new DAL.ClsIF_Warehouse_View();
                                    //将递入的条码去掉前三位后转化成整形,TryParse不能转换成整数时返回false,并返回ID=0
                                    int ID;
                                    if (int.TryParse(sBarCode.Remove(0, 3), out ID))
                                    {
                                        if (dal.GetInfoByID(ID, HOWNERID))
                                        {
                                            oBar.HBarType = "仓库条码";
                                            oBar.HWhID = dal.omodel.HItemID;
                                            oBar.HWhNumber = dal.omodel.HNumber;
                                            oBar.HWhName = dal.omodel.HName;
                                            oBar.HSPFlag = dal.omodel.HIsStockMgr;
                                            return oBar;
                                        }
                                        else
                                        {
                                            sErrMsg = "无效仓库条码!";
                                            return null;
                                        }
                                    }
                                    else
                                    {
                                        sErrMsg = "错误的仓库条码!";
                                        return null;
                                    }
                                }
                                //仓位条码
                                else if (sBarBillName == "仓位")
                                {
                                    DAL.ClsIF_StockPlace_View dal = new DAL.ClsIF_StockPlace_View();
                                    //将递入的条码去掉前三位后转化成整形
                                    int sHSPID;
                                    int sHWHID;
                                    string[] sArray = sBarCode.Remove(0, 3).Split(';');
                                    if (int.TryParse(sArray[1], out sHSPID) && int.TryParse(sArray[0], out sHWHID))
                                    {
                                        if (dal.GetInfoByID(sHSPID, sHWHID, HOWNERID))
                                        {
                                            oBar.HBarType = "仓位条码";
                                            oBar.HSPID = dal.omodel.HItemID;
                                            oBar.HSPNumber = dal.omodel.HNumber;
                                            oBar.HSPName = dal.omodel.HName;
                                            oBar.HWhID = dal.omodel.HWHID;
                                            oBar.HWhNumber = dal.omodel.HWhNumber;
                                            oBar.HWhName = dal.omodel.HWhName;
                                            return oBar;
                                        }
                                        else
                                        {
                                            sErrMsg = "无效仓位条码!";
                                            return null;
                                        }
                                    }
                                    else
                                    {
                                        sErrMsg = "错误的仓位条码!";
                                        return null;
                                    }
                                }
                                //部门条码
                                else if (sBarBillName == "部门")
                                {
                                    DAL.ClsIF_Department_View dal = new DAL.ClsIF_Department_View();
                                    //将递入的条码去掉前三位后转化成整形
                                    int ID;
                                    if (int.TryParse(sBarCode.Remove(0, 3), out ID))
                                    {
                                        if (dal.GetInfoByID(ID))
                                        {
                                            oBar.HBarType = "部门条码";
                                            oBar.HDeptID = dal.omodel.HItemID;
                                            oBar.HDeptNumber = dal.omodel.HNumber;
                                            oBar.HDeptName = dal.omodel.HName;
                                            return oBar;
                                        }
                                        else
                                        {
                                            sErrMsg = "无效部门条码!";
                                            return null;
                                        }
                                    }
                                    else
                                    {
                                        sErrMsg = "错误的部门条码!";
                                        return null;
                                    }
                                }
                                else
                                {
                                    sErrMsg = "无效基础资料条码!";
                                    return null;
                                }
                            }
                            //源单条码
                            else if (sBarBillType == "源单条码")
                            {
                                //当该单据类型的系统参数:多源单模式   时,不允许扫描原单
                                //=======================
                                DataSet Ds = oCn.RunProcReturn(" select HSourceName from Xt_BarCodeType where HSourceNumber= '" + sBarCodePrefix + "' and HBillType= '" + HBillType + "'", "Xt_BarCodeType");
                                if (Ds == null || Ds.Tables[0].Rows.Count == 0)
                                {
                                    sErrMsg = "所扫源单条码不属于此模块源单范围!";
                                    return null;
                                }
                                else
                                {
                                    sBarBillName = Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceName"]);
                                    //扫描源单条码时判断是否已经扫描过源单信息
                                    if (SourceFlag)
                                    {
                                        sErrMsg = "明细信息列表已有扫码记录,不允许多次扫描源单条码!";
                                        return null;
                                    }
                                    else
                                    {
                                        //产品入库单 源单:生产任务单
                                        if (sBarBillName == "生产任务单" && HBillType == "1202")
                                        {
                                            DAL.Cls_S_IF_ICMOBill_Lite dal = new DAL.Cls_S_IF_ICMOBill_Lite();
                                            DataSet DS;
                                            //根据单据号获取过滤条件
                                            string sWhere = " Where 单据号 like '" + sBarCode + "'";
                                            DS = dal.DisSourceBillList(sWhere);
                                            if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                            {
                                                sErrMsg = "没有返回任何记录!";
                                                return null;
                                            }
                                            oBar.HBarType = "源单条码";
                                            oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                            oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                            oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                            oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                            oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                            oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                        }
                                        //产品入库单 源单:生产汇报单
                                        else if (sBarBillName == "生产汇报单" && HBillType == "1202")
                                        {
                                            DAL.Cls_S_IF_ICMOReportBill_Lite dal = new DAL.Cls_S_IF_ICMOReportBill_Lite();
                                            DataSet DS;
                                            //根据单据号获取过滤条件
                                            string sWhere = " Where 单据号 like '" + sBarCode + "'";
                                            DS = dal.DisSourceBillList(sWhere);
                                            if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                            {
                                                sErrMsg = "没有返回任何记录!";
                                                return null;
                                            }
                                            oBar.HBarType = "源单条码";
                                            oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                            oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                            oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                            oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                            oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                            oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                        }
                                        //外购入库单 源单:采购订单
                                        else if (sBarBillName == "采购订单" && HBillType == "1201")
                                        {
                                            DAL.Cls_S_IF_POOrderBill_Lite dal = new DAL.Cls_S_IF_POOrderBill_Lite();
                                            DataSet DS;
                                            //根据单据号获取过滤条件
                                            string sWhere = " Where 单据号 like '" + sBarCode + "'";
                                            DS = dal.DisSourceBillList(sWhere);
                                            if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                            {
                                                sErrMsg = "没有返回任何记录!";
                                                return null;
                                            }
                                            oBar.HBarType = "源单条码";
                                            oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                            oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                            oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                            oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                            oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                            oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                        }
                                        //外购入库单 源单:收料通知单
                                        else if (sBarBillName == "收料通知单" && HBillType == "1201")
                                        {
                                            DAL.Cls_S_IF_POInStockBill_Lite dal = new DAL.Cls_S_IF_POInStockBill_Lite();
                                            DataSet DS;
                                            //根据单据号获取过滤条件
                                            string sWhere = " Where 单据号 like '" + sBarCode + "' and isnull(HBillSubType,0)=12510 ";
                                            DS = dal.DisSourceBillList(sWhere);
                                            if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                            {
                                                sErrMsg = "没有返回任何记录!";
                                                return null;
                                            }
                                            oBar.HBarType = "源单条码";
                                            oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                            oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                            oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                            oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                            oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                            oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                        }
                                        //委外入库单 源单:委外订单
                                        else if (sBarBillName == "委外订单" && HBillType == "1210")
                                        {
                                            DAL.Cls_S_IF_WWOrderBill_Lite dal = new DAL.Cls_S_IF_WWOrderBill_Lite();
                                            DataSet DS;
                                            //根据单据号获取过滤条件
                                            string sWhere = " Where 单据号 like '" + sBarCode + "'";
                                            DS = dal.DisSourceBillList(sWhere);
                                            if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                            {
                                                sErrMsg = "没有返回任何记录!";
                                                return null;
                                            }
                                            oBar.HBarType = "源单条码";
                                            oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                            oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                            oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                            oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                            oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                            oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                        }
                                        //委外入库单 源单:收料通知单-委外
                                        else if (sBarBillName == "收料通知单-委外" && HBillType == "1210")
                                        {
                                            DAL.Cls_S_IF_POStockInBill_Lite dal = new DAL.Cls_S_IF_POStockInBill_Lite();
                                            DataSet DS;
                                            //根据单据号获取过滤条件
                                            string sWhere = " Where 单据号 like '" + sBarCode + "' and isnull(HBillSubType,0)=12511 ";
                                            DS = dal.DisSourceBillList(sWhere);
                                            if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                            {
                                                sErrMsg = "没有返回任何记录!";
                                                return null;
                                            }
                                            oBar.HBarType = "源单条码";
                                            oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                            oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                            oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                            oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                            oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                            oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                        }
                                        //领料出库 源单:生产任务单-投料
                                        else if (sBarBillName == "生产任务单-投料" && HBillType == "1204")
                                        {
                                            DAL.Cls_S_IF_PPBomBillList_Lite dal = new DAL.Cls_S_IF_PPBomBillList_Lite();
                                            DataSet DS;
                                            //根据单据号获取过滤条件
                                            string sWhere = " Where 单据号 like '" + sBarCode + "'";
                                            DS = dal.DisSourceBillList(sWhere);
                                            if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                            {
                                                sErrMsg = "没有返回任何记录!";
                                                return null;
                                            }
                                            oBar.HBarType = "源单条码";
                                            oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                            oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                            oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                            oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                            oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                            oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                        }
                                        //销售出库 源单:销售订单
                                        else if (sBarBillName == "销售订单" && HBillType == "1205")
                                        {
                                            DAL.Cls_S_IF_SEOrderBill_Lite dal = new DAL.Cls_S_IF_SEOrderBill_Lite();
                                            DataSet DS;
                                            //根据单据号获取过滤条件
                                            string sWhere = " Where 单据号 like '" + sBarCode + "'";
                                            DS = dal.DisSourceBillList(sWhere);
                                            if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                            {
                                                sErrMsg = "没有返回任何记录!";
                                                return null;
                                            }
                                            oBar.HBarType = "源单条码";
                                            oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                            oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                            oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                            oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                            oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                            oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                            oBar.HCustom = Convert.ToString(DS.Tables[0].Rows[0]["HCustom"]);
                                        }
                                        //销售出库 源单:发货通知单
                                        else if (sBarBillName == "发货通知单" && HBillType == "1205")
                                        {
                                            DAL.Cls_S_IF_SeOutStockBill_Lite dal = new DAL.Cls_S_IF_SeOutStockBill_Lite();
                                            DataSet DS;
                                            //根据单据号获取过滤条件
                                            string sWhere = " Where 单据号 like '" + sBarCode + "'";
                                            DS = dal.DisSourceBillList(sWhere);
                                            if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                            {
                                                sErrMsg = "没有返回任何记录!";
                                                return null;
                                            }
                                            oBar.HBarType = "源单条码";
                                            oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                            oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                            oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                            oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                            oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                            oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                            oBar.HCustom = Convert.ToString(DS.Tables[0].Rows[0]["HCustom"]);
                                        }
                                        //委外出库单 源单:委外订单-投料
                                        else if (sBarBillName == "委外订单-投料" && HBillType == "1211")
                                        {
                                            DAL.Cls_S_IF_WWPPBomBill_Lite dal = new DAL.Cls_S_IF_WWPPBomBill_Lite();
                                            DataSet DS;
                                            //根据单据号获取过滤条件
                                            string sWhere = " Where 单据号 like '" + sBarCode + "'";
                                            DS = dal.DisSourceBillList(sWhere);
                                            if (DS == null || DS.Tables[0].Rows.Count <= 0)
                                            {
                                                sErrMsg = "没有返回任何记录!";
                                                return null;
                                            }
                                            oBar.HBarType = "源单条码";
                                            oBar.HSourceBillNo = Convert.ToString(DS.Tables[0].Rows[0]["HBillNo"]);
                                            oBar.HSourceBillType = Convert.ToString(DS.Tables[0].Rows[0]["HBillType"]);
                                            oBar.HSupID = Convert.ToInt64(DS.Tables[0].Rows[0]["HSupID"]);
                                            oBar.HSupName = Convert.ToString(DS.Tables[0].Rows[0]["HSupName"]);
                                            oBar.HDeptID = Convert.ToInt64(DS.Tables[0].Rows[0]["HDeptID"]);
                                            oBar.HDeptName = Convert.ToString(DS.Tables[0].Rows[0]["HDeptName"]);
                                        }
                                        else
                                        {
                                            sErrMsg = "源单类型名称设置不正确!";
                                            return null;
                                        }
                                        // 将源单信息写入 临时缓存表
                                        if (tem.AddNew_Source(HBillID, HBillNo, HBillType, oBar.HSourceBillNo, oBar.HSourceBillType, sRedBlue, ref sErrMsg))
                                        {
                                            return oBar;
                                        }
                                        else
                                        {
                                            sErrMsg = "保存源单信息失败!" + sErrMsg;
                                            return null;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                sErrMsg = "无效条码类型!";
                                return null;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                sErrMsg = e.Message+";"+e.StackTrace;
                return null;
            }
        }
        #endregion