/// <summary>
        /// 获取服务组件
        /// </summary>
        /// <returns>返回组件接口</returns>
        public static T GetServerModule <T>()
        {
            string name = typeof(T).ToString();

            m_hashTable = new Hashtable();

            //if (m_hashTable.ContainsKey(name))
            //{
            //    return (T)m_hashTable[name];
            //}

            if (typeof(T) == typeof(IProviderServer))
            {
                IProviderServer serverModule = new ProviderServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IAccessoryDutyInfoManageServer))
            {
                IAccessoryDutyInfoManageServer serverModule = new AccessoryDutyInfoManageServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IDepartmentServer))
            {
                IDepartmentServer serverModule = new DepartmentServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IMaterialTypeServer))
            {
                IMaterialTypeServer serverModule = new MaterialTypeServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IStoreServer))
            {
                IStoreServer serverModule = new StoreServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(ICheckOutInDepotServer))
            {
                ICheckOutInDepotServer serverModule = new CheckOutInDepotServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IUnitServer))
            {
                IUnitServer serverModule = new UnitServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IClientServer))
            {
                IClientServer serverModule = new ClientServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IProductListServer))
            {
                IProductListServer serverModule = new ProductListServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IBasicGoodsServer))
            {
                IBasicGoodsServer serverModule = SCM_Level01_ServerFactory.GetServerModule <IBasicGoodsServer>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IAssemblyInfoServer))
            {
                IAssemblyInfoServer serverModule = PMS_ServerFactory.GetServerModule <IAssemblyInfoServer>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IBarCodeServer))
            {
                IBarCodeServer serverModule = BasicServerFactory.GetServerModule <IBarCodeServer>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IBomServer))
            {
                IBomServer serverModule = PMS_ServerFactory.GetServerModule <IBomServer>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IBomMappingServer))
            {
                IBomMappingServer serverModule = PMS_ServerFactory.GetServerModule <IBomMappingServer>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IAssemblingBom))
            {
                IAssemblingBom serverModule = PMS_ServerFactory.GetServerModule <IAssemblingBom>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IElectronFileServer))
            {
                IElectronFileServer serverModule = PMS_ServerFactory.GetServerModule <IElectronFileServer>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IChoseConfectServer))
            {
                IChoseConfectServer serverModule = PMS_ServerFactory.GetServerModule <IChoseConfectServer>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IWorkbenchService))
            {
                IWorkbenchService serverModule = PMS_ServerFactory.GetServerModule <IWorkbenchService>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IGoodsGradeServer))
            {
                IGoodsGradeServer serverModule = new GoodsGradeServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IBargainInfoServer))
            {
                IBargainInfoServer serverModule = new BargainInfoServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IBargainGoodsServer))
            {
                IBargainGoodsServer serverModule = new BargainGoodsServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IOrderFormInfoServer))
            {
                IOrderFormInfoServer serverModule = new OrderFormInfoServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IOrderFormGoodsServer))
            {
                IOrderFormGoodsServer serverModule = new OrderFormGoodsServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IOrdinaryInDepotBillServer))
            {
                IOrdinaryInDepotBillServer serverModule = new OrdinaryInDepotBillServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IOrdinaryInDepotGoodsBill))
            {
                IOrdinaryInDepotGoodsBill serverModule = new OrdinaryInDepotGoodsBill();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IProductInfoServer))
            {
                IProductInfoServer serverModule = PMS_ServerFactory.GetServerModule <IProductInfoServer>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IBillTypeServer))
            {
                IBillTypeServer serverModule = BasicServerFactory.GetServerModule <IBillTypeServer>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IAssignBillNoServer))
            {
                IAssignBillNoServer serverModule = BasicServerFactory.GetServerModule <IAssignBillNoServer>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IMaterialRequisitionServer))
            {
                IMaterialRequisitionServer serverModule = new MaterialRequisitionServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IPersonnelInfoServer))
            {
                IPersonnelInfoServer serverModule = SCM_Level01_ServerFactory.GetServerModule <IPersonnelInfoServer>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IMaterialRequisitionGoodsServer))
            {
                IMaterialRequisitionGoodsServer serverModule = new MaterialRequisitionGoodsServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IDeclareWastrelType))
            {
                IDeclareWastrelType serverModule = new DeclareWastrelType();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IScrapBillServer))
            {
                IScrapBillServer serverModule = new ScrapBillServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IScrapGoodsServer))
            {
                IScrapGoodsServer serverModule = new ScrapGoodsServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IMaterialRequisitionPurposeServer))
            {
                IMaterialRequisitionPurposeServer serverModule = new MaterialRequisitionPurposeServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IFieldWidthServer))
            {
                IFieldWidthServer serverModule = new FieldWidthServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IHomemadePartInDepotServer))
            {
                IHomemadePartInDepotServer serverModule = new HomemadePartInDepotServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IMaterialReturnedInTheDepot))
            {
                IMaterialReturnedInTheDepot serverModule = new MaterialReturnedInTheDepot();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IMaterialListReturnedInTheDepot))
            {
                IMaterialListReturnedInTheDepot serverModule = new MaterialListReturnedInTheDepot();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IMaterialRejectBill))
            {
                IMaterialRejectBill serverModule = new MaterialRejectBill();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IMaterialListRejectBill))
            {
                IMaterialListRejectBill serverModule = new MaterialListRejectBill();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IDetailSummaryInfo))
            {
                IDetailSummaryInfo serverModule = new DetailSummaryInfo();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IDepotTypeForPersonnel))
            {
                IDepotTypeForPersonnel serverModule = SCM_Level01_ServerFactory.GetServerModule <IDepotTypeForPersonnel>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IInvoiceServer))
            {
                IInvoiceServer serverModule = new InvoiceServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(ISellIn))
            {
                ISellIn serverModule = new SellIn();
                m_hashTable.Add(name, serverModule);
            }
            //else if (typeof(T) == typeof(IProductOrder))
            //{
            //    IProductOrder serverModule = new ProductOrder();
            //    m_hashTable.Add(name, serverModule);
            //}
            else if (typeof(T) == typeof(ICannibalize))
            {
                ICannibalize serverModule = new Cannibalize();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(ICheckReturnRepair))
            {
                ICheckReturnRepair serverModule = new CheckReturnRepair();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IIsolationManageBill))
            {
                IIsolationManageBill serverModule = new IsolationManageBill();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IMessMessageFeedback))
            {
                IMessMessageFeedback serverModule = new MessMessageFeedback();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(ITorqueConverterInfoServer))
            {
                ITorqueConverterInfoServer serverModule = new TorqueConverterInfoServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IProductPlan))
            {
                IProductPlan serverModule = new ProductPlan();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IStoreageCheck))
            {
                IStoreageCheck serverModule = new StoreageCheck();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(ISafeStockServer))
            {
                ISafeStockServer serverModule = new SafeStockServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IMusterAffirmBill))
            {
                IMusterAffirmBill serverModule = new MusterAffirmBill();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IMusterUse))
            {
                IMusterUse serverModule = new MusterUse();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(ITempElectronFileServer))
            {
                ITempElectronFileServer serverModule = PMS_ServerFactory.GetServerModule <ITempElectronFileServer>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IMultiBatchPartServer))
            {
                IMultiBatchPartServer serverModule = PMS_ServerFactory.GetServerModule <IMultiBatchPartServer>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(ITechnologyChange))
            {
                ITechnologyChange serverModule = new TechnologyChange();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IGoodsLeastPackAndStock))
            {
                IGoodsLeastPackAndStock serverModule = new GoodsLeastPackAndStock();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IOrderFormAffrim))
            {
                IOrderFormAffrim serverModule = new OrderFormAffrim();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IMarketingPlan))
            {
                IMarketingPlan serverModule = new MarketingPlan();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IPurcharsingPlan))
            {
                IPurcharsingPlan serverModule = new PurcharsingPlan();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IGeneratesCheckOutInDepotServer))
            {
                IGeneratesCheckOutInDepotServer serverModule = new GeneratesCheckOutInDepotServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IGoodsAntirust))
            {
                IGoodsAntirust serverModule = new GoodsAntirust();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IQuarantine))
            {
                IQuarantine serverModule = new Quarantine();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IAfterServiceMakePartsBill))
            {
                IAfterServiceMakePartsBill serverModule = new AfterServiceMakePartsBill();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IReparativePartInfoServer))
            {
                IReparativePartInfoServer serverModule = PMS_ServerFactory.GetServerModule <IReparativePartInfoServer>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IConvertCVTNumber))
            {
                IConvertCVTNumber serverModule = PMS_ServerFactory.GetServerModule <IConvertCVTNumber>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IProductBarcodeServer))
            {
                IProductBarcodeServer serverModule = PMS_ServerFactory.GetServerModule <IProductBarcodeServer>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(ICheckOutInDepotForOutsourcingServer))
            {
                ICheckOutInDepotForOutsourcingServer serverModule = new CheckOutInDepotForOutsourcingServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IProductChange))
            {
                IProductChange serverModule = new ProductChange();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IHomemadeRejectBill))
            {
                IHomemadeRejectBill serverModule = new HomemadeRejectBill();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IHomemadeRejectList))
            {
                IHomemadeRejectList serverModule = new HomemadeRejectList();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IFrockProvingReport))
            {
                IFrockProvingReport serverModule = new FrockProvingReport();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IMaterialDetainBill))
            {
                IMaterialDetainBill serverModule = new MaterialDetainBill();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IPrintProductBarcodeInfo))
            {
                IPrintProductBarcodeInfo serverModule = PMS_ServerFactory.GetServerModule <IPrintProductBarcodeInfo>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IThreePacketsOfTheRepairBill))
            {
                IThreePacketsOfTheRepairBill serverModule = new ThreePacketsOfTheRepairBill();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IFrockIndepotBill))
            {
                IFrockIndepotBill serverModule = new FrockIndepotBill();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(ICommunicateReportBill))
            {
                ICommunicateReportBill serverModule = new CommunicateReportBill();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IProductCodeServer))
            {
                IProductCodeServer serverModule = SCM_Level02_ServerFactory.GetServerModule <IProductCodeServer>();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IHomemadePartInfoServer))
            {
                IHomemadePartInfoServer serverModule = new HomemadePartInfoServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IStorageInfo))
            {
                IStorageInfo serverModule = new StorageInfo();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IProductDeliveryInspectionServer))
            {
                IProductDeliveryInspectionServer serverModule = new ProductDeliveryInspectionServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(ICVTCustomerInformationServer))
            {
                ICVTCustomerInformationServer serverModule = new CVTCustomerInformationServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(ICVTTruckLoadingInformation))
            {
                ICVTTruckLoadingInformation serverModule = new CVTTruckLoadingInformation();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IQualityProblemRectificationDisposalBill))
            {
                IQualityProblemRectificationDisposalBill serverModule = new QualityProblemRectificationDisposalBill();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IGoodsShelfLife))
            {
                IGoodsShelfLife serverModule = new GoodsShelfLife();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IReport))
            {
                IReport serverModule = new Report();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IMarqueeServer))
            {
                IMarqueeServer serverModule = new MarqueeServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IDeviceMaintenanceBill))
            {
                IDeviceMaintenanceBill serverModule = new DeviceMaintenanceBill();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(ICBOMServer))
            {
                ICBOMServer serverModule = new CBOMServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(ILogisticSafeStock))
            {
                ILogisticSafeStock serverModule = new LogisticSafeStock();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IUnProductTestingSingle))
            {
                IUnProductTestingSingle serverModule = new UnProductTestingSingle();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IDisposableGoodsServer))
            {
                IDisposableGoodsServer serverModule = new DisposableGoodsServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(ITCURepairInfoServer))
            {
                ITCURepairInfoServer serverModule = new TCURepairInfoServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(ISalesOrderServer))
            {
                ISalesOrderServer serverModule = new SalesOrderServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(ITechnologyAlteration))
            {
                ITechnologyAlteration serverModule = new TechnologyAlteration();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IMinorPurchaseBillServer))
            {
                IMinorPurchaseBillServer serverModule = new MinorPurchaseBillServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IProductLendService))
            {
                IProductLendService serverModule = new ProductLendService();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IProductLendReturnService))
            {
                IProductLendReturnService serverModule = new ProductLendReturnService();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IProductReturnService))
            {
                IProductReturnService serverModule = new ProductReturnService();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IStockLack))
            {
                IStockLack serverModule = new StockLack();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IOfflineFailSafeServer))
            {
                IOfflineFailSafeServer serverModule = new OfflineFailSafeServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(ISystemLogServer))
            {
                ISystemLogServer serverModule = new SystemLogServer();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IFinancialDetailManagement))
            {
                IFinancialDetailManagement serverModule = new FinancialDetailManagement();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IToolsManage))
            {
                IToolsManage serverModule = new ToolsManage();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IGaugeManage))
            {
                IGaugeManage serverModule = new GaugeManage();
                m_hashTable.Add(name, serverModule);
            }
            else if (typeof(T) == typeof(IQualitySystemDatabase))
            {
                IQualitySystemDatabase serverModule = new QualitySystemDatabase();
                m_hashTable.Add(name, serverModule);
            }

            if (m_hashTable.ContainsKey(name))
            {
                return((T)m_hashTable[name]);
            }

            return(default(T));
        }
Exemple #2
0
        /// <summary>
        /// 保存单据
        /// </summary>
        /// <param name="billNo">单据号</param>
        /// <param name="bill">要保存的单据对象</param>
        /// <param name="goodsList">要保存的报废物品清单</param>
        /// <param name="error">出错时返回的错误信息</param>
        /// <returns>操作是否成功的标志</returns>
        public bool SaveGoods(string billNo, S_ScrapBill bill, List <View_S_ScrapGoods> goodsList,
                              out string error)
        {
            error = null;
            ScrapBillServer serverScrapBill = new ScrapBillServer();

            try
            {
                DepotManagementDataContext contxt = CommentParameter.DepotDataContext;

                if (IsExist(billNo))
                {
                    #region 夏石友,2012-07-13 10:20

                    S_ScrapBill surBill = serverScrapBill.GetBill(billNo);

                    // 判断当前保存人员是否是建单人
                    if (surBill.FillInPersonnelCode != bill.FillInPersonnelCode)
                    {
                        error = string.Format("您不是建单人 [{0}, {1}] 无法进行此操作", surBill.FillInPersonnelCode, surBill.FillInPersonnel);
                        return(false);
                    }

                    #endregion

                    //检查总成报废数量是否都设置了流水码
                    foreach (var item in goodsList)
                    {
                        if (!m_serverProductCode.IsFitCount(item.物品ID, Convert.ToInt32(item.报废数量), bill.Bill_ID))
                        {
                            error = "请对产品设置流水号,并保证产品数量与流水号数一致";
                            return(false);
                        }
                    }


                    if (!serverScrapBill.DeleteBill(contxt, billNo, false, out error))
                    {
                        return(false);
                    }

                    DeleteGoods(contxt, billNo);
                }

                if (!serverScrapBill.AddBill(contxt, bill, out error))
                {
                    return(false);
                }

                AddGoods(contxt, goodsList);

                contxt.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
Exemple #3
0
        /// <summary>
        /// 插入报废单
        /// </summary>
        /// <param name="ctx">LINQ数据上下文</param>
        /// <param name="outSourcing">Linq操作数据集</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>插入成功返回True,插入失败返回False</returns>
        public bool AddScrapBill(DepotManagementDataContext ctx,
                                 S_CheckOutInDepotForOutsourcingBill outSourcing, out string error)
        {
            error = null;
            string strBillID = "";

            try
            {
                ScrapBillServer serverScrapBill = new ScrapBillServer();

                S_ScrapBill lnqBill = new S_ScrapBill();

                strBillID = m_assignBill.AssignNewNo(serverScrapBill, CE_BillTypeEnum.报废单.ToString());

                lnqBill.AuthorizeTime     = ServerTime.Time;
                lnqBill.Bill_ID           = strBillID;
                lnqBill.Bill_Time         = ServerTime.Time;
                lnqBill.BillStatus        = "已完成";
                lnqBill.Checker           = outSourcing.Checker;
                lnqBill.DeclareDepartment = m_serverDepartment.GetDeptInfoFromPersonnelInfo(
                    outSourcing.DeclarePersonnel).Rows[0]["DepartmentCode"].ToString();
                lnqBill.DepartmentDirector  = "";
                lnqBill.DepotManager        = outSourcing.ManagerPersonnel;
                lnqBill.DepotTime           = ServerTime.Time;
                lnqBill.FillInPersonnel     = outSourcing.DeclarePersonnel;
                lnqBill.FillInPersonnelCode = UniversalFunction.GetPersonnelCode(outSourcing.DeclarePersonnel);
                lnqBill.NotifyChecker       = UniversalFunction.GetPersonnelCode(outSourcing.Checker);
                lnqBill.ProductType         = "";
                lnqBill.Remark   = "关联委外报检入库单【" + outSourcing.Bill_ID + "】,自动生成";
                lnqBill.Sanction = outSourcing.Checker;

                ctx.S_ScrapBill.InsertOnSubmit(lnqBill);

                S_ScrapGoods lnqGoods = new S_ScrapGoods();

                lnqGoods.BatchNo  = outSourcing.BatchNo;
                lnqGoods.Bill_ID  = strBillID;
                lnqGoods.GoodsID  = outSourcing.GoodsID;
                lnqGoods.Provider = outSourcing.Provider;
                lnqGoods.Quantity = outSourcing.DeclareWastrelCount;
                lnqGoods.Reason   = "检测报废,关联委外报检入库单【" + outSourcing.Bill_ID + "】,自动生成";
                lnqGoods.Remark   = "检测报废,关联委外报检入库单【" + outSourcing.Bill_ID + "】,自动生成";
                lnqGoods.ResponsibilityDepartment = "GYS";
                lnqGoods.ResponsibilityProvider   = outSourcing.Provider;
                lnqGoods.ResponsibilityType       = "返 修 废";
                lnqGoods.UnitPrice    = 0;
                lnqGoods.WastrelType  = 9;
                lnqGoods.WorkingHours = 0;

                ctx.S_ScrapGoods.InsertOnSubmit(lnqGoods);

                m_assignBill.UseBillNo(CE_BillTypeEnum.报废单.ToString(), strBillID);

                return(true);
            }
            catch (Exception ex)
            {
                m_assignBill.CancelBillNo(CE_BillTypeEnum.报废单.ToString(), strBillID);
                error = ex.Message;
                return(false);
            }
        }