示例#1
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);
            }
        }
示例#2
0
        /// <summary>
        /// 处理入库明细业务信息
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="indepotDetailInfo">入库明细信息</param>
        /// <param name="stockInfo">库存信息</param>
        public void ProcessInDepotDetail(DepotManagementDataContext ctx, S_InDepotDetailBill indepotDetailInfo, S_Stock stockInfo)
        {
            try
            {
                CE_SubsidiaryOperationType operationType =
                    (CE_SubsidiaryOperationType)Enum.ToObject(typeof(CE_SubsidiaryOperationType), indepotDetailInfo.OperationType);
                IStoreServer storeService = ServerModule.ServerModuleFactory.GetServerModule <IStoreServer>();

                switch (operationType)
                {
                case CE_SubsidiaryOperationType.报检入库:
                case CE_SubsidiaryOperationType.委外报检入库:
                    InsertOnSubmitInDepotDetailBill(ctx, indepotDetailInfo);
                    InDepotToolsInfo(ctx, indepotDetailInfo);
                    InDepotGuagesInfo(ctx, indepotDetailInfo);
                    storeService.InStore(ctx, stockInfo, operationType);
                    break;

                case CE_SubsidiaryOperationType.采购退货:
                    InsertOnSubmitInDepotDetailBill(ctx, indepotDetailInfo);
                    InDepotToolsInfo(ctx, indepotDetailInfo);
                    FetchGaugeInfo(ctx, indepotDetailInfo);
                    storeService.OutStore(ctx, stockInfo, operationType);
                    break;

                case CE_SubsidiaryOperationType.普通入库:
                    InsertOnSubmitInDepotDetailBill(ctx, indepotDetailInfo);
                    InDepotToolsInfo(ctx, indepotDetailInfo);
                    InDepotGuagesInfo(ctx, indepotDetailInfo);
                    storeService.InStore(ctx, stockInfo, operationType);
                    storeService.UpdateAging(ctx, stockInfo, false);
                    break;

                case CE_SubsidiaryOperationType.营销入库:
                case CE_SubsidiaryOperationType.自制件入库:
                case CE_SubsidiaryOperationType.自制件工装入库:
                    InsertOnSubmitInDepotDetailBill(ctx, indepotDetailInfo);
                    InDepotToolsInfo(ctx, indepotDetailInfo);
                    InDepotGuagesInfo(ctx, indepotDetailInfo);
                    InDepotWorkShop(ctx, indepotDetailInfo);
                    storeService.InStore(ctx, stockInfo, operationType);
                    break;

                case CE_SubsidiaryOperationType.营销退货:
                case CE_SubsidiaryOperationType.自制件退货:
                    InsertOnSubmitInDepotDetailBill(ctx, indepotDetailInfo);
                    InDepotToolsInfo(ctx, indepotDetailInfo);
                    FetchGaugeInfo(ctx, indepotDetailInfo);
                    InDepotWorkShop(ctx, indepotDetailInfo);
                    storeService.OutStore(ctx, stockInfo, operationType);
                    break;

                case CE_SubsidiaryOperationType.财务对冲:
                case CE_SubsidiaryOperationType.财务红冲:
                    InsertOnSubmitInDepotDetailBill(ctx, indepotDetailInfo);
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }