public decimal GetUnitPrice(CE_InPutBusinessType businessType, string relateBillNo, int goodsID, string batchNo, string storageID) { try { decimal resultUnitPrice = 0; switch (businessType) { case CE_InPutBusinessType.生产采购: case CE_InPutBusinessType.普通采购: case CE_InPutBusinessType.委外采购: case CE_InPutBusinessType.样品采购: break; case CE_InPutBusinessType.自制件入库: resultUnitPrice = 0; break; case CE_InPutBusinessType.领料退库: IStoreServer storeService = ServerModuleFactory.GetServerModule <IStoreServer>(); resultUnitPrice = storeService.GetGoodsUnitPrice(goodsID, batchNo, storageID); break; case CE_InPutBusinessType.营销入库: case CE_InPutBusinessType.营销退库: break; default: break; } return(resultUnitPrice); } catch (Exception ex) { throw new Exception(ex.Message); } }
void CreateMaterialRequisition(DepotManagementDataContext ctx, Business_WarehouseOutPut_WholeMachineRequisition billInfo, List <Business_WarehouseOutPut_WholeMachineRequisitionDetail> listDetail, List <Business_WarehouseOutPut_WholeMachineRequisition_StorageID> listStorage, out List <string> listBillNo) { listBillNo = null; ServerModule.IMaterialRequisitionGoodsServer serviceGoods = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IMaterialRequisitionGoodsServer>(); ServerModule.IMaterialRequisitionServer serviceBill = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IMaterialRequisitionServer>(); ServerModule.IStoreServer serviceStore = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IStoreServer>(); IFlowServer serviceFlow = FlowControlService.ServerModuleFactory.GetServerModule <IFlowServer>(); ServerModule.IMaterialRequisitionPurposeServer servicePurpose = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IMaterialRequisitionPurposeServer>(); BillNumberControl billControl = new BillNumberControl(CE_BillTypeEnum.领料单, serviceBill); List <CommonProcessInfo> listProcessInfo = serviceFlow.GetFlowData(billInfo.BillNo); try { List <GoodsInfo> listGoodsInfo = new List <GoodsInfo>(); foreach (Business_WarehouseOutPut_WholeMachineRequisitionDetail detail in listDetail) { decimal requstCount = detail.GoodsCount; foreach (Business_WarehouseOutPut_WholeMachineRequisition_StorageID storage in listStorage) { if (requstCount == 0) { break; } List <View_S_Stock> lstStock = serviceStore.GetGoodsStoreOnlyForAssembly(detail.GoodsID, storage.StorageID).ToList(); foreach (View_S_Stock stock in lstStock) { if (requstCount == 0) { break; } if (stock.库存数量 <= requstCount) { GoodsInfo goodsInfo = new GoodsInfo(); goodsInfo.GoodsID = detail.GoodsID; goodsInfo.BatchNo = stock.批次号; goodsInfo.Provider = stock.供货单位; goodsInfo.GoodsCount = stock.库存数量; goodsInfo.ListInfo = new List <string>(); goodsInfo.ListInfo.Add(listGoodsInfo.Count.ToString()); goodsInfo.ListInfo.Add(storage.StorageID); goodsInfo.ListInfo.Add(stock.库存数量.ToString()); listGoodsInfo.Add(goodsInfo); requstCount = requstCount - stock.库存数量; } else { GoodsInfo goodsInfo = new GoodsInfo(); goodsInfo.GoodsID = detail.GoodsID; goodsInfo.BatchNo = stock.批次号; goodsInfo.Provider = stock.供货单位; goodsInfo.GoodsCount = requstCount; goodsInfo.ListInfo = new List <string>(); goodsInfo.ListInfo.Add(listGoodsInfo.Count.ToString()); goodsInfo.ListInfo.Add(storage.StorageID); goodsInfo.ListInfo.Add(detail.GoodsCount.ToString()); listGoodsInfo.Add(goodsInfo); requstCount = 0; } } } } if (listGoodsInfo != null && listGoodsInfo.Count > 0) { listBillNo = new List <string>(); CommonProcessInfo firstProcess = new CommonProcessInfo(); CommonProcessInfo SecondProcess = new CommonProcessInfo(); CommonProcessInfo ThridProcess = new CommonProcessInfo(); var varTemp = from a in listProcessInfo where a.操作节点 == "新建" orderby a.时间 descending select a; if (varTemp.Count() != 0) { firstProcess = varTemp.First(); } else { throw new Exception("此单据无【新建】流程"); } varTemp = from a in listProcessInfo where a.操作节点 == "审核" orderby a.时间 descending select a; if (varTemp.Count() != 0) { SecondProcess = varTemp.First(); } else { throw new Exception("此单据无【审核】流程"); } varTemp = from a in listProcessInfo where a.操作节点 == "确认" orderby a.时间 descending select a; if (varTemp.Count() != 0) { ThridProcess = varTemp.First(); } foreach (Business_WarehouseOutPut_WholeMachineRequisition_StorageID storage in listStorage) { List <GoodsInfo> listGoodsInfoTemp = (from a in listGoodsInfo where a.ListInfo[1].ToString() == storage.StorageID orderby Convert.ToInt32(a.ListInfo[0]) select a).ToList(); if (listGoodsInfoTemp.Count > 0) { string error = ""; S_MaterialRequisition bill = new S_MaterialRequisition(); bill.AssociatedBillNo = billInfo.BillNo; bill.AssociatedBillType = CE_BillTypeEnum.整台份请领单.ToString(); bill.Bill_ID = billControl.GetNewBillNo(ctx); bill.Bill_Time = ServerTime.Time; bill.BillStatus = "等待出库"; View_HR_Personnel personnelInfo = UniversalFunction.GetPersonnelInfo(firstProcess.工号); bill.Department = personnelInfo.部门编码; bill.DepartmentDirector = SecondProcess.人员; bill.DepotManager = ThridProcess == new CommonProcessInfo() ? BasicInfo.LoginName : ThridProcess.人员; bill.FetchCount = (int)billInfo.MachineCount; bill.FetchType = FetchGoodsType.整台领料.ToString(); bill.FillInPersonnel = firstProcess.人员; bill.FillInPersonnelCode = personnelInfo.工号; bill.ProductType = billInfo.ProductType; bill.PurposeCode = servicePurpose.GetBillPurpose(ctx, billInfo.BillTypeDetail).Code; bill.Remark = billInfo.Remark; bill.StorageID = storage.StorageID; if (!serviceBill.AutoCreateBill(ctx, bill, out error)) { throw new Exception(error); } listBillNo.Add(bill.Bill_ID); for (int i = 0; i < listGoodsInfoTemp.Count; i++) { S_MaterialRequisitionGoods goodsInfo = new S_MaterialRequisitionGoods(); goodsInfo.BasicCount = Convert.ToDecimal(listGoodsInfoTemp[i].ListInfo[2]); goodsInfo.BatchNo = listGoodsInfoTemp[i].BatchNo; goodsInfo.Bill_ID = bill.Bill_ID; goodsInfo.GoodsID = listGoodsInfoTemp[i].GoodsID; goodsInfo.ProviderCode = listGoodsInfoTemp[i].Provider; goodsInfo.RealCount = listGoodsInfoTemp[i].GoodsCount; goodsInfo.Remark = GetWorkBench_WashFlag(billInfo.ProductType, goodsInfo.GoodsID); goodsInfo.RequestCount = listGoodsInfoTemp[i].GoodsCount; IProductOrder serviceProductOrder = ServerModuleFactory.GetServerModule <IProductOrder>(); goodsInfo.ShowPosition = 0; //serviceProductOrder.GetPosition(ctx, billInfo.ProductType, goodsInfo.GoodsID); if (!serviceGoods.AutoCreateGoods(ctx, goodsInfo, out error)) { throw new Exception(error); } } } ctx.SubmitChanges(); } } } catch (Exception ex) { throw new Exception(ex.Message); } }