/// <summary>
        /// 根据单据信息操作账务信息与库存信息
        /// </summary>
        /// <param name="dataContext">数据上下文</param>
        /// <param name="bill">单据信息</param>
        public void OpertaionDetailAndStock(DepotManagementDataContext dataContext, S_MaterialReturnedInTheDepot bill)
        {
            MaterialListReturnedInTheDepot listService  = new MaterialListReturnedInTheDepot();
            IFinancialDetailManagement     serverDetail =
                ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>();

            var result = from r in dataContext.S_MaterialListReturnedInTheDepot
                         where r.Bill_ID == bill.Bill_ID
                         select r;

            if (result == null || result.Count() == 0)
            {
                throw new Exception("获取单据信息失败");
            }

            foreach (var item in result)
            {
                S_FetchGoodsDetailBill detailInfo = listService.AssignDetailInfo(dataContext, bill, item);
                S_Stock stockInfo = listService.AssignStockInfo(dataContext, bill, item);

                if (detailInfo == null || stockInfo == null)
                {
                    throw new Exception("获取账务信息或者库存信息失败");
                }

                serverDetail.ProcessFetchGoodsDetail(dataContext, detailInfo, stockInfo);
            }

            IStoreServer serviceStore = ServerModuleFactory.GetServerModule <IStoreServer>();

            serviceStore.Operation_MES_InProduction(dataContext, bill.Bill_ID);
        }
Beispiel #2
0
        /// <summary>
        /// 操作账务信息与库存信息_出
        /// </summary>
        /// <param name="dataContext">数据上下文</param>
        /// <param name="lnqOutPut">单据信息</param>
        void OperationDetailAndStock_Out(DepotManagementDataContext dataContext, Business_WarehouseInPut_InPut lnqInPut)
        {
            string             error = "";
            IProductCodeServer productCodeService =
                ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IProductCodeServer>();
            CE_MarketingType marketingType = GlobalObject.EnumOperation.OutPutBusinessTypeConvertToMarketingType(
                GlobalObject.GeneralFunction.StringConvertToEnum <CE_OutPutBusinessType>(lnqInPut.BillType));
            IFinancialDetailManagement serverDetail =
                ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>();

            List <View_Business_WarehouseInPut_InPutDetail> listDetail = GetListViewDetailInfo(lnqInPut.BillNo);

            foreach (View_Business_WarehouseInPut_InPutDetail detail1 in listDetail)
            {
                if (!productCodeService.UpdateProductStock(dataContext, lnqInPut.BillNo, marketingType.ToString(), lnqInPut.StorageID,
                                                           (lnqInPut.StorageID == "05" && marketingType == CE_MarketingType.入库) ? true : false, detail1.物品ID, out error))
                {
                    throw new Exception(error);
                }

                S_FetchGoodsDetailBill detailInfo = AssignDetailInfo_Out(dataContext, lnqInPut, detail1);
                S_Stock stockInfo = AssignStockInfo(dataContext, lnqInPut, detail1);

                if (detailInfo == null || stockInfo == null)
                {
                    throw new Exception("获取账务信息或者库存信息失败");
                }

                serverDetail.ProcessFetchGoodsDetail(dataContext, detailInfo, stockInfo);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 根据单据信息操作账务信息与库存信息
        /// </summary>
        /// <param name="dataContext">数据上下文</param>
        /// <param name="bill">单据信息</param>
        public void OpertaionDetailAndStock(DepotManagementDataContext dataContext, S_ScrapBill bill)
        {
            IFinancialDetailManagement serverDetail =
                ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>();

            var result = from r in dataContext.S_ScrapGoods
                         where r.Bill_ID == bill.Bill_ID
                         select r;

            if (result == null || result.Count() == 0)
            {
                throw new Exception("获取单据信息失败");
            }

            foreach (var item in result)
            {
                S_FetchGoodsDetailBill detailInfo = AssignDetailInfo(dataContext, bill, item);

                if (detailInfo == null)
                {
                    throw new Exception("获取账务信息或者库存信息失败");
                }

                serverDetail.ProcessFetchGoodsDetail(dataContext, detailInfo, null);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 赋值入库明细信息
        /// </summary>
        /// <param name="originalInfo">原始信息</param>
        /// <returns>入库明细对象</returns>
        S_FetchGoodsDetailBill AssignmentInfo(S_FetchGoodsDetailBill originalInfo)
        {
            S_FetchGoodsDetailBill lnqResult = new S_FetchGoodsDetailBill();

            lnqResult.AssociatedBillNo   = originalInfo.AssociatedBillNo;
            lnqResult.AssociatedBillType = originalInfo.AssociatedBillType;
            lnqResult.BatchNo            = originalInfo.BatchNo;
            lnqResult.BillTime           = originalInfo.BillTime;
            lnqResult.DepartDirector     = originalInfo.DepartDirector;
            lnqResult.Department         = originalInfo.Department;
            lnqResult.Depot            = originalInfo.Depot;
            lnqResult.DepotManager     = originalInfo.DepotManager;
            lnqResult.FetchBIllID      = originalInfo.FetchBIllID;
            lnqResult.FetchCount       = originalInfo.FetchCount;
            lnqResult.FillInDate       = originalInfo.FillInDate;
            lnqResult.FillInPersonnel  = originalInfo.FillInPersonnel;
            lnqResult.FinanceSignatory = originalInfo.FinanceSignatory;
            lnqResult.GoodsID          = originalInfo.GoodsID;
            lnqResult.ID              = originalInfo.ID;
            lnqResult.OperationType   = originalInfo.OperationType;
            lnqResult.Price           = originalInfo.Price;
            lnqResult.Provider        = originalInfo.Provider;
            lnqResult.ProviderBatchNo = originalInfo.ProviderBatchNo;
            lnqResult.Remark          = originalInfo.Remark;
            lnqResult.StorageID       = originalInfo.StorageID;
            lnqResult.UnitPrice       = originalInfo.UnitPrice;
            lnqResult.Using           = originalInfo.Using;

            return(lnqResult);
        }
Beispiel #5
0
        /// <summary>
        /// 借还货出库业务的处理
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="fetchGoodsDetailInfo">出库业务对象</param>
        void FetchLendReturn_MaterialRequisition(DepotManagementDataContext ctx, S_FetchGoodsDetailBill fetchGoodsDetailInfo)
        {
            if (fetchGoodsDetailInfo == null)
            {
                return;
            }

            if (Convert.ToBoolean(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.开启借还货账务管理]))
            {
                BASE_SubsidiaryOperationType operationType = UniversalFunction.GetSubsidiaryOperationType(ctx, fetchGoodsDetailInfo.OperationType);

                if (operationType.LendReturnType != null)
                {
                    IProductLendReturnService serverLendReturn = ServerModuleFactory.GetServerModule <IProductLendReturnService>();

                    var varData = from a in ctx.View_S_MaterialRequisitionProductReturnList
                                  where a.单据号 == fetchGoodsDetailInfo.FetchBIllID &&
                                  a.还账物品ID == fetchGoodsDetailInfo.GoodsID &&
                                  a.还账物品批次号 == fetchGoodsDetailInfo.BatchNo &&
                                  a.还账物品供应商 == fetchGoodsDetailInfo.Provider
                                  select a;

                    if (varData.Count() > 0)
                    {
                        foreach (var item1 in varData)
                        {
                            S_ProductLendRecord tempRecord =
                                serverLendReturn.GetStockSingleInfo(ctx, BasicInfo.DeptCode, fetchGoodsDetailInfo.StorageID, item1.账物品ID,
                                                                    item1.账物品批次号, item1.账物品供应商);

                            if (tempRecord != null)
                            {
                                S_ProductLendReturnDetail tempDetail = new S_ProductLendReturnDetail();

                                tempDetail.Affirm         = fetchGoodsDetailInfo.DepotManager;
                                tempDetail.AffirmDate     = ServerTime.Time;
                                tempDetail.BatchNo        = item1.账物品批次号;
                                tempDetail.Provider       = item1.账物品供应商;
                                tempDetail.BillNo         = fetchGoodsDetailInfo.FetchBIllID;
                                tempDetail.BillTime       = ServerTime.Time;
                                tempDetail.Credit         = fetchGoodsDetailInfo.StorageID;
                                tempDetail.Debtor         = BasicInfo.DeptCode;
                                tempDetail.GoodsID        = item1.账物品ID;
                                tempDetail.OperationCount = item1.还账数量;
                                tempDetail.OperationType  = fetchGoodsDetailInfo.OperationType;
                                tempDetail.Proposer       = fetchGoodsDetailInfo.FillInPersonnel;
                                tempDetail.ProposerDate   =
                                    fetchGoodsDetailInfo.FillInDate == null ? ServerTime.Time : Convert.ToDateTime(fetchGoodsDetailInfo.FillInDate);
                                tempDetail.UnitPrice = 0;

                                serverLendReturn.OperationDetailRecord(ctx, tempDetail);
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 赋值账务信息_出
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="lnqOutPut">单据信息</param>
        /// <param name="detail1">明细信息</param>
        /// <returns>返回账务信息对象</returns>
        S_FetchGoodsDetailBill AssignDetailInfo_Out(DepotManagementDataContext ctx, Business_WarehouseOutPut_OutPut lnqOutPut,
                                                    View_Business_WarehouseOutPut_OutPutDetail detail1)
        {
            ServerModule.IStoreServer storeService = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IStoreServer>();
            IFlowServer           serverFlow       = FlowControlService.ServerModuleFactory.GetServerModule <IFlowServer>();
            CommonProcessInfo     processInfo      = new CommonProcessInfo();
            CE_OutPutBusinessType OutPutType       =
                GlobalObject.GeneralFunction.StringConvertToEnum <CE_OutPutBusinessType>(lnqOutPut.BillType);

            S_FetchGoodsDetailBill fetchDetail = new S_FetchGoodsDetailBill();

            fetchDetail.AssociatedBillNo   = detail1.关联业务;
            fetchDetail.AssociatedBillType = CE_BillTypeEnum.入库申请单.ToString();
            fetchDetail.BatchNo            = detail1.批次号;
            fetchDetail.BillTime           = ServerTime.Time;
            fetchDetail.DepartDirector     = "";
            fetchDetail.Department         = lnqOutPut.ApplyingDepartment;
            fetchDetail.Depot = UniversalFunction.GetGoodsInfo(detail1.物品ID).物品类别名称;

            fetchDetail.Price = 0;
            //Math.Round(detail1.单价 * detail1.数量, 2);
            fetchDetail.UnitPrice = 0;
            //detail1.单价;

            processInfo = serverFlow.GetFlowData(detail1.关联业务).First();

            fetchDetail.FillInDate      = Convert.ToDateTime(processInfo.时间);
            fetchDetail.FillInPersonnel = processInfo.人员;

            fetchDetail.FetchBIllID   = lnqOutPut.BillNo;
            fetchDetail.FetchCount    = detail1.数量;
            fetchDetail.GoodsID       = detail1.物品ID;
            fetchDetail.OperationType = (int)GlobalObject.EnumOperation.OutPutBusinessTypeConvertToSubsidiaryOperationType(OutPutType);
            fetchDetail.Provider      = detail1.供应商;
            fetchDetail.Remark        = detail1.备注;
            fetchDetail.StorageID     = lnqOutPut.StorageID;

            DataTable stockTable = storeService.GetGoodsStockInfo(fetchDetail.GoodsID, fetchDetail.BatchNo, fetchDetail.Provider, fetchDetail.StorageID);

            if (stockTable != null && stockTable.Rows.Count > 0)
            {
                fetchDetail.ProviderBatchNo = stockTable.Rows[0]["ProviderBatchNo"].ToString();
            }
            else
            {
                fetchDetail.ProviderBatchNo = "";
            }

            fetchDetail.Using = lnqOutPut.BillTypeDetail;

            return(fetchDetail);
        }
Beispiel #7
0
        /// <summary>
        /// 插入提交出库明细表
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="detailInfo">明细信息</param>
        void InsertOnSubmitFetchGoodsDetailBill(DepotManagementDataContext ctx, S_FetchGoodsDetailBill detailInfo)
        {
            if (detailInfo == null)
            {
                return;
            }

            if (GlobalObject.GeneralFunction.IsNullOrEmpty(detailInfo.FetchBIllID))
            {
                throw new Exception("【单据号】获取失败,请重新再试");
            }

            ctx.S_FetchGoodsDetailBill.InsertOnSubmit(detailInfo);
        }
        /// <summary>
        /// 赋值账务信息
        /// </summary>
        /// <param name="context">数据上下文</param>
        /// <param name="bill">单据信息</param>
        /// <param name="item">明细信息</param>
        /// <returns>返回账务信息对象</returns>
        public S_FetchGoodsDetailBill AssignDetailInfo(DepotManagementDataContext context, S_MaterialReturnedInTheDepot bill,
                                                       S_MaterialListReturnedInTheDepot item)
        {
            IBillTypeServer server   = ServerModuleFactory.GetServerModule <IBillTypeServer>();
            BASE_BillType   billType = server.GetBillTypeFromName("领料退库单");

            if (billType == null)
            {
                throw new Exception("获取不到单据类型信息");
            }

            View_Department department = UniversalFunction.GetDeptInfo(context, bill.Department);

            //单价设置
            decimal dcStockUnitPrice = m_serverStore.GetGoodsUnitPrice(context, item.GoodsID, item.BatchNo, bill.StorageID);

            //S_FetchGoodsDetailBill用于存放每次领料、领料退库的明细信息
            S_FetchGoodsDetailBill detailBill = new S_FetchGoodsDetailBill();

            detailBill.ID               = Guid.NewGuid();
            detailBill.FetchBIllID      = bill.Bill_ID;
            detailBill.BillTime         = ServerTime.Time;
            detailBill.FetchCount       = -item.ReturnedAmount;
            detailBill.GoodsID          = item.GoodsID;
            detailBill.BatchNo          = item.BatchNo;
            detailBill.ProviderBatchNo  = item.ProviderBatchNo;
            detailBill.Provider         = item.Provider;
            detailBill.Price            = -dcStockUnitPrice * (decimal)item.ReturnedAmount;
            detailBill.UnitPrice        = dcStockUnitPrice;
            detailBill.Department       = department.部门名称;
            detailBill.FillInPersonnel  = bill.FillInPersonnel;
            detailBill.FinanceSignatory = null;
            detailBill.DepartDirector   = bill.DepartmentDirector;
            detailBill.DepotManager     = bill.DepotManager;
            detailBill.OperationType    = (int)CE_SubsidiaryOperationType.领料退库;
            detailBill.StorageID        = bill.StorageID;
            detailBill.Remark           = "退库原因:" + bill.ReturnReason + ";备注:" + item.Remark;
            detailBill.FillInDate       = bill.Bill_Time;

            IMaterialRequisitionPurposeServer purposeServer =
                ServerModuleFactory.GetServerModule <IMaterialRequisitionPurposeServer>();

            detailBill.Using = string.Format("领料退库,初始用途:{0}", purposeServer.GetBillPurpose(context, bill.PurposeCode).Purpose);

            return(detailBill);
        }
        /// <summary>
        /// 根据单据信息操作账务信息与库存信息
        /// </summary>
        /// <param name="dataContext">数据上下文</param>
        /// <param name="bill">单据信息</param>
        /// <param name="dataTable">明细信息集合</param>
        void OpertaionDetailAndStock(DepotManagementDataContext dataContext, S_ProductLendBill bill, DataTable dataTable)
        {
            IFinancialDetailManagement serverDetail =
                ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>();

            foreach (DataRow dr in dataTable.Rows)
            {
                S_FetchGoodsDetailBill detailInfo = AssignDetailInfo(dataContext, bill, dr);

                if (detailInfo == null)
                {
                    throw new Exception("获取账务信息或者库存信息失败");
                }

                serverDetail.ProcessFetchGoodsDetail(dataContext, detailInfo, null);
            }
        }
Beispiel #10
0
        /// <summary>
        /// 赋值账务信息
        /// </summary>
        /// <param name="dataContxt">数据上下文</param>
        /// <param name="bill">单据信息</param>
        /// <param name="item">明细信息</param>
        /// <returns>返回账务信息</returns>
        S_FetchGoodsDetailBill AssignDetailInfo(DepotManagementDataContext dataContxt, S_ScrapBill bill, S_ScrapGoods item)
        {
            Service_Manufacture_WorkShop.IWorkShopStock serverWSStock =
                Service_Manufacture_WorkShop.ServerModuleFactory.GetServerModule <Service_Manufacture_WorkShop.IWorkShopStock>();
            Service_Manufacture_WorkShop.IWorkShopBasic serverWSBasic =
                Service_Manufacture_WorkShop.ServerModuleFactory.GetServerModule <Service_Manufacture_WorkShop.IWorkShopBasic>();
            WS_WorkShopCode tempWSCode = serverWSBasic.GetPersonnelWorkShop(dataContxt, bill.FillInPersonnelCode);

            S_FetchGoodsDetailBill detailBill = new S_FetchGoodsDetailBill();

            string error = "";

            if (!m_serverProductCode.UpdateProductStock(dataContxt, bill.Bill_ID, "报废", "05", false, item.GoodsID, out error))
            {
                throw new Exception(error);
            }

            detailBill.ID          = Guid.NewGuid();
            detailBill.FetchBIllID = bill.Bill_ID;
            detailBill.BillTime    = ServerTime.Time;
            detailBill.FetchCount  = -(decimal)item.Quantity;
            detailBill.GoodsID     = item.GoodsID;
            detailBill.BatchNo     = item.BatchNo == "无批次" ? "" : item.BatchNo;

            WS_WorkShopStock tempWSStock = new WS_WorkShopStock();

            if (tempWSCode != null)
            {
                tempWSStock = serverWSStock.GetStockSingleInfo(dataContxt, tempWSCode.WSCode, item.GoodsID, item.BatchNo);
            }

            detailBill.UnitPrice        = tempWSStock == null ? 0 : tempWSStock.UnitPrice;
            detailBill.Price            = detailBill.UnitPrice * (decimal)detailBill.FetchCount;
            detailBill.Provider         = item.Provider;
            detailBill.FillInPersonnel  = bill.FillInPersonnel;
            detailBill.FinanceSignatory = null;
            detailBill.DepartDirector   = bill.DepartmentDirector;
            detailBill.DepotManager     = bill.DepotManager;
            detailBill.OperationType    = (int)CE_SubsidiaryOperationType.报废;
            detailBill.Remark           = "【报废】";
            detailBill.FillInDate       = bill.Bill_Time;

            return(detailBill);
        }
Beispiel #11
0
        /// <summary>
        /// 赋值账务信息
        /// </summary>
        /// <param name="dataContext">数据上下文</param>
        /// <param name="billInfo">单据信息</param>
        /// <param name="listSingle">明细信息</param>
        /// <param name="operationType">操作类型</param>
        /// <returns>返回账务信息</returns>
        S_FetchGoodsDetailBill AssignDetailInfo(DepotManagementDataContext dataContext, S_CannibalizeBill billInfo, S_CannibalizeList listSingle,
                                                CE_SubsidiaryOperationType operationType)
        {
            S_FetchGoodsDetailBill lnqOutDepot = new S_FetchGoodsDetailBill();

            bool flag = false;

            if (operationType == CE_SubsidiaryOperationType.库房调出)
            {
                flag = true;
            }
            else if (operationType == CE_SubsidiaryOperationType.库房调入)
            {
                flag = false;
            }
            else
            {
                throw new Exception("业务类型错误");
            }

            lnqOutDepot.ID              = Guid.NewGuid();
            lnqOutDepot.FetchBIllID     = billInfo.DJH;
            lnqOutDepot.BillTime        = ServerTime.Time;
            lnqOutDepot.GoodsID         = (int)listSingle.GoodsID;
            lnqOutDepot.Provider        = listSingle.Provider;
            lnqOutDepot.BatchNo         = listSingle.BatchNo;
            lnqOutDepot.FetchCount      = flag ? listSingle.Count : -listSingle.Count;
            lnqOutDepot.UnitPrice       = (decimal)listSingle.UnitPrice;
            lnqOutDepot.Price           = flag ? (decimal)listSingle.Price : -(decimal)listSingle.Price;
            lnqOutDepot.Using           = flag ? "仓库调拨单:调出" : "仓库调拨:调入";
            lnqOutDepot.Department      = UniversalFunction.GetStorageName(dataContext, flag ? billInfo.InStoreRoom : billInfo.OutStoreRoom);
            lnqOutDepot.FillInPersonnel = UniversalFunction.GetPersonnelInfo(dataContext, billInfo.LRRY).姓名;
            lnqOutDepot.DepartDirector  = UniversalFunction.GetPersonnelInfo(dataContext, billInfo.SHRY).姓名;
            lnqOutDepot.DepotManager    = BasicInfo.LoginName;
            lnqOutDepot.OperationType   = flag ? (int)CE_SubsidiaryOperationType.库房调出 : (int)CE_SubsidiaryOperationType.库房调入;
            lnqOutDepot.Remark          = billInfo.Remark;
            lnqOutDepot.StorageID       = flag ? billInfo.OutStoreRoom : billInfo.InStoreRoom;
            lnqOutDepot.FillInDate      = billInfo.LRRQ;

            return(lnqOutDepot);
        }
Beispiel #12
0
        /// <summary>
        /// 工具出库业务的处理
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="fetchGoodsDetailInfo">出库业务对象</param>
        void FetchToolsInfo(DepotManagementDataContext ctx, S_FetchGoodsDetailBill fetchGoodsDetailInfo)
        {
            if (fetchGoodsDetailInfo == null)
            {
                return;
            }

            IToolsManage serverTools = ServerModule.ServerModuleFactory.GetServerModule <IToolsManage>();

            if (serverTools.IsTools(ctx, fetchGoodsDetailInfo.GoodsID))
            {
                if (fetchGoodsDetailInfo.StorageID != null && fetchGoodsDetailInfo.StorageID.Trim().Length > 0)
                {
                    S_MachineAccount_Tools toolsInfo_Storage = new S_MachineAccount_Tools();

                    toolsInfo_Storage.GoodsID     = fetchGoodsDetailInfo.GoodsID;
                    toolsInfo_Storage.Provider    = fetchGoodsDetailInfo.Provider;
                    toolsInfo_Storage.StockCount  = -(decimal)fetchGoodsDetailInfo.FetchCount;
                    toolsInfo_Storage.StorageCode = fetchGoodsDetailInfo.StorageID;

                    serverTools.OpertionInfo(ctx, toolsInfo_Storage);
                    serverTools.DayToDayAccount(ctx, toolsInfo_Storage, fetchGoodsDetailInfo.FetchBIllID);
                }

                CE_SubsidiaryOperationType operationType =
                    (CE_SubsidiaryOperationType)Enum.ToObject(typeof(CE_SubsidiaryOperationType), fetchGoodsDetailInfo.OperationType);

                if (operationType != CE_SubsidiaryOperationType.营销出库 && operationType != CE_SubsidiaryOperationType.营销退库)
                {
                    S_MachineAccount_Tools toolsInfo_Department = new S_MachineAccount_Tools();

                    toolsInfo_Department.GoodsID     = fetchGoodsDetailInfo.GoodsID;
                    toolsInfo_Department.Provider    = fetchGoodsDetailInfo.Provider;
                    toolsInfo_Department.StockCount  = (decimal)fetchGoodsDetailInfo.FetchCount;
                    toolsInfo_Department.StorageCode = UniversalFunction.GetPersonnelInfo(ctx, fetchGoodsDetailInfo.FillInPersonnel).部门编码;

                    serverTools.OpertionInfo(ctx, toolsInfo_Department);
                    serverTools.DayToDayAccount(ctx, toolsInfo_Department, fetchGoodsDetailInfo.FetchBIllID);
                }
            }
        }
Beispiel #13
0
        /// <summary>
        /// 根据单据信息操作账务信息与库存信息
        /// </summary>
        /// <param name="dataContext">数据上下文</param>
        /// <param name="bill">单据信息</param>
        /// <param name="operationType">操作类型</param>
        void OpertaionDetailAndStock(DepotManagementDataContext dataContext, S_CannibalizeBill bill,
                                     CE_SubsidiaryOperationType operationType)
        {
            IFinancialDetailManagement serverDetail =
                ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>();

            var result = from r in dataContext.S_CannibalizeList
                         where r.DJ_ID == bill.ID
                         select r;

            foreach (var item in result)
            {
                S_FetchGoodsDetailBill detailInfo = AssignDetailInfo(dataContext, bill, item, operationType);
                S_Stock stockInfo = AssignStockInfo(dataContext, bill, item, operationType);

                if (detailInfo == null || stockInfo == null)
                {
                    throw new Exception("获取账务信息或者库存信息失败");
                }

                serverDetail.ProcessFetchGoodsDetail(dataContext, detailInfo, stockInfo);
            }
        }
Beispiel #14
0
        /// <summary>
        /// 车间出库业务的处理
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="fetchGoodsDetailInfo">出库业务对象</param>
        void FetchWorkShop(DepotManagementDataContext ctx, S_FetchGoodsDetailBill fetchGoodsDetailInfo)
        {
            if (fetchGoodsDetailInfo == null)
            {
                return;
            }

            Service_Manufacture_WorkShop.IWorkShopBasic serverWSBasic =
                Service_Manufacture_WorkShop.ServerModuleFactory.GetServerModule <Service_Manufacture_WorkShop.IWorkShopBasic>();
            WS_WorkShopCode tempWSCode = serverWSBasic.GetPersonnelWorkShop(ctx, fetchGoodsDetailInfo.FillInPersonnel);

            if (Convert.ToBoolean(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.开启车间管理模块]) &&
                tempWSCode != null)
            {
                WS_Subsidiary tempSubsidiary = new WS_Subsidiary();

                tempSubsidiary.BillTime       = ServerTime.Time;
                tempSubsidiary.Applicant      = UniversalFunction.GetStorageName(ctx, fetchGoodsDetailInfo.StorageID);
                tempSubsidiary.Affirm         = fetchGoodsDetailInfo.DepotManager;
                tempSubsidiary.AffirmDate     = ServerTime.Time;
                tempSubsidiary.BatchNo        = fetchGoodsDetailInfo.BatchNo;
                tempSubsidiary.BillNo         = fetchGoodsDetailInfo.FetchBIllID;
                tempSubsidiary.GoodsID        = fetchGoodsDetailInfo.GoodsID;
                tempSubsidiary.Provider       = fetchGoodsDetailInfo.Provider;
                tempSubsidiary.OperationCount = (decimal)fetchGoodsDetailInfo.FetchCount < 0 ? -(decimal)fetchGoodsDetailInfo.FetchCount : (decimal)fetchGoodsDetailInfo.FetchCount;
                tempSubsidiary.OperationType  = fetchGoodsDetailInfo.OperationType;
                tempSubsidiary.Proposer       = fetchGoodsDetailInfo.FillInPersonnel;
                tempSubsidiary.ProposerDate   = fetchGoodsDetailInfo.FillInDate == null ? ServerTime.Time : Convert.ToDateTime(fetchGoodsDetailInfo.FillInDate);
                tempSubsidiary.UnitPrice      = fetchGoodsDetailInfo.UnitPrice;
                tempSubsidiary.WSCode         = tempWSCode.WSCode;
                tempSubsidiary.Remark         = fetchGoodsDetailInfo.Remark;

                Service_Manufacture_WorkShop.IWorkShopStock serverWSStock =
                    Service_Manufacture_WorkShop.ServerModuleFactory.GetServerModule <Service_Manufacture_WorkShop.IWorkShopStock>();
                serverWSStock.OperationSubsidiary(ctx, tempSubsidiary);
            }
        }
        /// <summary>
        /// 赋值账务信息
        /// </summary>
        /// <param name="dataContext">数据上下文</param>
        /// <param name="tempBill">单据信息</param>
        /// <param name="dr">明细信息</param>
        /// <returns>返回账务信息对象</returns>
        S_FetchGoodsDetailBill AssignDetailInfo(DepotManagementDataContext dataContext, S_ProductLendBill tempBill, DataRow dr)
        {
            S_FetchGoodsDetailBill detailBill = new S_FetchGoodsDetailBill();

            detailBill.ID               = Guid.NewGuid();
            detailBill.FetchBIllID      = tempBill.BillNo;
            detailBill.BillTime         = ServerTime.Time;
            detailBill.FetchCount       = Convert.ToDecimal(dr["数量"]);
            detailBill.GoodsID          = Convert.ToInt32(dr["物品ID"]);
            detailBill.BatchNo          = dr["批次号"].ToString();
            detailBill.UnitPrice        = 0;
            detailBill.Price            = detailBill.UnitPrice * (decimal)detailBill.FetchCount;
            detailBill.Provider         = dr["供应商"].ToString();
            detailBill.FillInPersonnel  = tempBill.Proposer;
            detailBill.FinanceSignatory = null;
            detailBill.DepartDirector   = tempBill.Audit;
            detailBill.DepotManager     = tempBill.Affirm;
            detailBill.OperationType    = (int)CE_SubsidiaryOperationType.借货;
            detailBill.Remark           = dr["备注"].ToString();
            detailBill.FillInDate       = tempBill.ProposerDate;
            detailBill.StorageID        = tempBill.StorageID;

            return(detailBill);
        }
Beispiel #16
0
        /// <summary>
        /// 借还货出库业务的处理
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="fetchGoodsDetailInfo">出库业务对象</param>
        void FetchLendReturn(DepotManagementDataContext ctx, S_FetchGoodsDetailBill fetchGoodsDetailInfo)
        {
            if (fetchGoodsDetailInfo == null)
            {
                return;
            }

            if (Convert.ToBoolean(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.开启借还货账务管理]))
            {
                BASE_SubsidiaryOperationType operationType = UniversalFunction.GetSubsidiaryOperationType(ctx, fetchGoodsDetailInfo.OperationType);

                if (operationType.LendReturnType != null)
                {
                    S_ProductLendReturnDetail tempDetail = new S_ProductLendReturnDetail();

                    tempDetail.Affirm         = fetchGoodsDetailInfo.DepotManager;
                    tempDetail.AffirmDate     = fetchGoodsDetailInfo.BillTime;
                    tempDetail.BatchNo        = fetchGoodsDetailInfo.BatchNo;
                    tempDetail.Provider       = fetchGoodsDetailInfo.Provider;
                    tempDetail.BillNo         = fetchGoodsDetailInfo.FetchBIllID;
                    tempDetail.BillTime       = fetchGoodsDetailInfo.BillTime;
                    tempDetail.Credit         = fetchGoodsDetailInfo.StorageID;
                    tempDetail.Debtor         = UniversalFunction.GetPersonnelInfo(ctx, fetchGoodsDetailInfo.FillInPersonnel).部门编码;
                    tempDetail.GoodsID        = fetchGoodsDetailInfo.GoodsID;
                    tempDetail.OperationCount = fetchGoodsDetailInfo.FetchCount < 0 ? -(decimal)fetchGoodsDetailInfo.FetchCount : (decimal)fetchGoodsDetailInfo.FetchCount;
                    tempDetail.OperationType  = fetchGoodsDetailInfo.OperationType;
                    tempDetail.Proposer       = fetchGoodsDetailInfo.FillInPersonnel;
                    tempDetail.ProposerDate   = fetchGoodsDetailInfo.FillInDate == null ? ServerTime.Time : Convert.ToDateTime(fetchGoodsDetailInfo.FillInDate);
                    tempDetail.Remark         = fetchGoodsDetailInfo.Remark;
                    tempDetail.UnitPrice      = fetchGoodsDetailInfo.UnitPrice;

                    IProductLendReturnService serverLendReturn = ServerModuleFactory.GetServerModule <IProductLendReturnService>();
                    serverLendReturn.OperationDetailRecord(ctx, tempDetail);
                }
            }
        }
Beispiel #17
0
        /// <summary>
        /// 赋值账务信息
        /// </summary>
        /// <param name="context">数据上下文</param>
        /// <param name="bill">单据信息</param>
        /// <param name="item">明细信息</param>
        /// <returns>返回账务信息对象</returns>
        public S_FetchGoodsDetailBill AssignDetailInfo(DepotManagementDataContext context, S_MaterialRequisition bill,
                                                       S_MaterialRequisitionGoods item)
        {
            IBillTypeServer server   = ServerModuleFactory.GetServerModule <IBillTypeServer>();
            BASE_BillType   billType = server.GetBillTypeFromName("领料单");

            if (billType == null)
            {
                throw new Exception("获取不到单据类型信息");
            }

            View_Department           department       = UniversalFunction.GetDeptInfo(context, bill.Department);
            IStoreServer              storeServer      = ServerModuleFactory.GetServerModule <IStoreServer>();
            IProductLendReturnService serverLendReturn = ServerModuleFactory.GetServerModule <IProductLendReturnService>();
            F_GoodsPlanCost           basicGoods       = m_basicGoodsServer.GetGoodsInfo(context, item.GoodsID);

            if (basicGoods == null)
            {
                throw new Exception(string.Format("物品ID [{0}] 的物品在基础物品表中没有查到,请与系统管理员联系!", item.GoodsID));
            }

            StoreQueryCondition condition = new StoreQueryCondition();

            condition.GoodsID   = item.GoodsID;
            condition.Provider  = item.ProviderCode;
            condition.BatchNo   = item.BatchNo;
            condition.StorageID = bill.StorageID;

            S_Stock stock = storeServer.GetStockInfoOverLoad(context, condition);

            if (stock == null && GlobalObject.GeneralFunction.IsNullOrEmpty(basicGoods.GoodsType))
            {
                throw new Exception(string.Format("图号:{0}, 名称:{1}, 规格:{2}, 供应商:{3}, 批次号:{4} 的物品在库存中没有查到相关物品,请仓管员核实!",
                                                  basicGoods.GoodsCode, basicGoods.GoodsName, basicGoods.Spec, item.ProviderCode, item.BatchNo));
            }

            //S_FetchGoodsDetailBill用于存放每次领料、领料退库的明细信息
            decimal dcRealCount = item.RealCount;
            decimal dcSumCount  = 0;

            var varData = from a in context.View_S_MaterialRequisitionProductReturnList
                          where a.单据号 == item.Bill_ID &&
                          a.还账物品ID == item.GoodsID &&
                          a.还账物品批次号 == item.BatchNo &&
                          a.还账物品供应商 == item.ProviderCode
                          select a;

            if (varData.Count() > 0)
            {
                dcSumCount = varData.Sum(a => a.还账数量);

                if (dcRealCount < dcSumCount)
                {
                    throw new Exception("实际领用数量不能大于还货数量,请重新核对");
                }
            }

            S_FetchGoodsDetailBill detailBill = new S_FetchGoodsDetailBill();

            detailBill.ID                 = Guid.NewGuid();
            detailBill.FetchBIllID        = bill.Bill_ID;
            detailBill.BillTime           = (DateTime)bill.OutDepotDate;
            detailBill.AssociatedBillType = bill.AssociatedBillType;
            detailBill.AssociatedBillNo   = bill.AssociatedBillNo;
            detailBill.Department         = department.部门名称;
            detailBill.FetchCount         = item.RealCount;
            detailBill.GoodsID            = item.GoodsID;
            detailBill.StorageID          = bill.StorageID;
            detailBill.Price              = dcSumCount;
            detailBill.UnitPrice          = stock == null ? 0 : stock.UnitPrice;
            detailBill.OperationType      = (int)CE_SubsidiaryOperationType.领料;
            detailBill.Provider           = item.ProviderCode;

            if (stock != null)
            {
                detailBill.ProviderBatchNo = stock.ProviderBatchNo;
            }
            else
            {
                detailBill.ProviderBatchNo = "";
            }

            detailBill.BatchNo = item.BatchNo;

            detailBill.FillInPersonnel  = bill.FillInPersonnel;
            detailBill.FinanceSignatory = null;
            detailBill.DepartDirector   = bill.DepartmentDirector;
            detailBill.DepotManager     = bill.DepotManager;
            detailBill.Remark           = (bill.Remark == null ? "" : bill.Remark.Trim()) + (item.Remark == null ? "" : item.Remark.Trim());
            detailBill.FillInDate       = bill.Bill_Time;

            IMaterialRequisitionPurposeServer purposeServer =
                ServerModuleFactory.GetServerModule <IMaterialRequisitionPurposeServer>();

            detailBill.Using = purposeServer.GetBillPurpose(context, bill.PurposeCode).Purpose;

            return(detailBill);
        }
Beispiel #18
0
        /// <summary>
        /// 处理出库明细业务信息
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="fetchGoodsDetailInfo">出库明细信息</param>
        /// <param name="stockInfo">库存信息</param>
        public void ProcessFetchGoodsDetail(DepotManagementDataContext ctx, S_FetchGoodsDetailBill fetchGoodsDetailInfo, S_Stock stockInfo)
        {
            try
            {
                CE_SubsidiaryOperationType operationType =
                    (CE_SubsidiaryOperationType)Enum.ToObject(typeof(CE_SubsidiaryOperationType), fetchGoodsDetailInfo.OperationType);
                IStoreServer storeService = ServerModule.ServerModuleFactory.GetServerModule <IStoreServer>();

                switch (operationType)
                {
                case CE_SubsidiaryOperationType.领料:
                    decimal dcSumCount = fetchGoodsDetailInfo.Price;

                    fetchGoodsDetailInfo.Price =
                        fetchGoodsDetailInfo.FetchCount == null ? 0 : fetchGoodsDetailInfo.UnitPrice * (decimal)fetchGoodsDetailInfo.FetchCount;
                    InsertOnSubmitFetchGoodsDetailBill(ctx, fetchGoodsDetailInfo);

                    S_FetchGoodsDetailBill newFetchDetailInfo = AssignmentInfo(fetchGoodsDetailInfo);
                    newFetchDetailInfo.FetchCount = newFetchDetailInfo.FetchCount < dcSumCount ? 0 : newFetchDetailInfo.FetchCount - dcSumCount;

                    FetchToolsInfo(ctx, newFetchDetailInfo);
                    FetchGaugeInfo(ctx, newFetchDetailInfo);
                    FetchLendReturn_MaterialRequisition(ctx, newFetchDetailInfo);

                    if (!fetchGoodsDetailInfo.AssociatedBillNo.Contains("SBW"))
                    {
                        FetchWorkShop(ctx, newFetchDetailInfo);
                    }

                    ctx.SubmitChanges();    // xsy, 2017.11.14 解决更新异常增加
                    storeService.OutStore(ctx, stockInfo, operationType);
                    ctx.SubmitChanges();    // xsy, 2017.11.14 解决更新异常增加
                    break;

                case CE_SubsidiaryOperationType.领料退库:
                    InsertOnSubmitFetchGoodsDetailBill(ctx, fetchGoodsDetailInfo);
                    FetchToolsInfo(ctx, fetchGoodsDetailInfo);
                    InDepotGuagesInfo(ctx, fetchGoodsDetailInfo);

                    if (UniversalFunction.GetStorageInfo(fetchGoodsDetailInfo.StorageID).WorkShopCurrentAccount)
                    {
                        FetchWorkShop(ctx, fetchGoodsDetailInfo);
                    }

                    storeService.InStore(ctx, stockInfo, operationType);
                    break;

                case CE_SubsidiaryOperationType.报废:
                    FetchToolsInfo(ctx, fetchGoodsDetailInfo);
                    FetchWorkShop(ctx, fetchGoodsDetailInfo);
                    break;

                case CE_SubsidiaryOperationType.样品耗用:
                case CE_SubsidiaryOperationType.借货:
                case CE_SubsidiaryOperationType.还货:
                    FetchLendReturn(ctx, fetchGoodsDetailInfo);
                    FetchToolsInfo(ctx, fetchGoodsDetailInfo);
                    FetchWorkShop(ctx, fetchGoodsDetailInfo);
                    break;

                case CE_SubsidiaryOperationType.库房调入:
                case CE_SubsidiaryOperationType.营销退库:
                    InsertOnSubmitFetchGoodsDetailBill(ctx, fetchGoodsDetailInfo);
                    FetchToolsInfo(ctx, fetchGoodsDetailInfo);
                    InDepotGuagesInfo(ctx, fetchGoodsDetailInfo);
                    storeService.InStore(ctx, stockInfo, operationType);
                    break;

                case CE_SubsidiaryOperationType.库房调出:
                case CE_SubsidiaryOperationType.营销出库:
                    InsertOnSubmitFetchGoodsDetailBill(ctx, fetchGoodsDetailInfo);
                    FetchToolsInfo(ctx, fetchGoodsDetailInfo);
                    FetchGaugeInfo(ctx, fetchGoodsDetailInfo);
                    storeService.OutStore(ctx, stockInfo, operationType);
                    break;

                default:
                    break;
                }
            }
            catch (System.Data.Linq.ChangeConflictException)
            {
                foreach (System.Data.Linq.ObjectChangeConflict occ in ctx.ChangeConflicts)
                {
                    //以下是解决冲突的三种方法,选一种即可
                    // 使用当前数据库中的值,覆盖Linq缓存中实体对象的值
                    //occ.Resolve(System.Data.Linq.RefreshMode.OverwriteCurrentValues);

                    // 使用Linq缓存中实体对象的值,覆盖当前数据库中的值
                    occ.Resolve(System.Data.Linq.RefreshMode.KeepCurrentValues);

                    // 只更新实体对象中改变的字段的值,其他的保留不变
                    //occ.Resolve(System.Data.Linq.RefreshMode.KeepChanges);
                }

                // 这个地方要注意,Catch方法中,我们前面只是指明了怎样来解决冲突,这个地方还需要再次提交更新,这样的话,值    //才会提交到数据库。
                ctx.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }