/// <summary> /// 保存台账 /// </summary> /// <typeparam name="TBatch">批次类型</typeparam> /// <param name="batchs">批次对象</param> /// <param name="currentDetail">当前调价明细单对象</param> public void SaveAccout <TBatch>(TBatch batchs, DG_AdjDetail currentDetail) { string errMsg = string.Empty; int actYear = 0; int actMonth = 0; int actId = 0; if (batchs.GetType() == typeof(DW_Batch)) { DW_Batch batch = batchs as DW_Batch; currentDetail.AdjAmount = batch.BatchAmount; batch.RetailPrice = currentDetail.NewRetailPrice; this.BindDb(batch); int dwresult = batch.save(); if (dwresult > 0) { this.BindDb(currentDetail); int detailresult = currentDetail.save(); if (detailresult > 0) { if (!GetDWAccountTime(batch.DeptID, out errMsg, out actYear, out actMonth, out actId)) { throw new Exception(errMsg); } DW_Account newaccount = new DW_Account(); newaccount.AccountType = 0; newaccount.BalanceFlag = 0; newaccount.BalanceID = actId; newaccount.BalanceMonth = actMonth; newaccount.BalanceYear = actYear; newaccount.BatchNO = batch.BatchNO; newaccount.BillNO = currentDetail.BillNO; newaccount.BusiType = DGConstant.OP_DW_ADJPRICE; newaccount.CTypeID = NewDao <IDWDao>().GetTypeId(batch.BatchNO, batch.DrugID); newaccount.LendRetailFee = currentDetail.NewRetailPrice > currentDetail.OldRetailPrice ? (currentDetail.NewRetailPrice - currentDetail.OldRetailPrice) * currentDetail.AdjAmount : 0; newaccount.DebitRetailFee = currentDetail.NewRetailPrice < currentDetail.OldRetailPrice ? (currentDetail.OldRetailPrice - currentDetail.NewRetailPrice) * currentDetail.AdjAmount : 0; newaccount.OverRetailFee = currentDetail.NewRetailPrice * currentDetail.AdjAmount; newaccount.DebitAmount = 0; newaccount.LendAmount = 0; newaccount.OverAmount = currentDetail.AdjAmount; newaccount.OverStockFee = batch.StockPrice * currentDetail.AdjAmount; newaccount.DebitStockFee = 0; newaccount.LendStockFee = 0; newaccount.DeptID = batch.DeptID; newaccount.DetailID = detailresult; newaccount.DrugID = batch.DrugID; newaccount.UnitName = currentDetail.PackUnitName; newaccount.UnitID = currentDetail.UnitID; newaccount.StockPrice = batch.StockPrice; newaccount.RegTime = DateTime.Now; newaccount.RetailPrice = currentDetail.NewRetailPrice; this.BindDb(newaccount); newaccount.save(); } } } else { DS_Batch batch = batchs as DS_Batch; currentDetail.AdjAmount = batch.BatchAmount; batch.RetailPrice = currentDetail.NewRetailPrice; this.BindDb(batch); int dsresult = batch.save(); if (dsresult > 0) { this.BindDb(currentDetail); int detailresult = currentDetail.save(); if (detailresult > 0) { if (!GetDSAccountTime(batch.DeptID, out errMsg, out actYear, out actMonth, out actId)) { throw new Exception(errMsg); } DS_Account newaccount = new DS_Account(); newaccount.AccountType = 0; newaccount.BalanceFlag = 0; newaccount.BalanceID = actId; newaccount.BalanceMonth = actMonth; newaccount.BalanceYear = actYear; newaccount.BatchNO = batch.BatchNO; newaccount.BillNO = currentDetail.BillNO; newaccount.BusiType = DGConstant.OP_DS_ADJPRICE; newaccount.CTypeID = NewDao <IDSDao>().GetTypeId(batch.BatchNO, batch.DrugID); newaccount.LendRetailFee = (currentDetail.NewRetailPrice > currentDetail.OldRetailPrice) ? ((currentDetail.NewRetailPrice - currentDetail.OldRetailPrice) * (currentDetail.AdjAmount / batch.UnitAmount)) : 0; newaccount.DebitRetailFee = (currentDetail.NewRetailPrice < currentDetail.OldRetailPrice) ? ((currentDetail.OldRetailPrice - currentDetail.NewRetailPrice) * (currentDetail.AdjAmount / batch.UnitAmount)) : 0; newaccount.OverRetailFee = (currentDetail.NewRetailPrice * (currentDetail.AdjAmount / batch.UnitAmount)); newaccount.DebitAmount = 0; newaccount.LendAmount = 0; newaccount.OverAmount = currentDetail.AdjAmount; newaccount.OverStockFee = (batch.StockPrice * (currentDetail.AdjAmount / batch.UnitAmount)); newaccount.DebitStockFee = 0; newaccount.LendStockFee = 0; newaccount.DeptID = batch.DeptID; newaccount.DetailID = detailresult; newaccount.DrugID = batch.DrugID; newaccount.UnitName = currentDetail.UnitName; newaccount.UnitID = currentDetail.UnitID; newaccount.StockPrice = batch.StockPrice; newaccount.RegTime = DateTime.Now; newaccount.RetailPrice = currentDetail.NewRetailPrice; this.BindDb(newaccount); newaccount.save(); } } } }
/// <summary> /// 减少库存 /// </summary> /// <param name="storeParam">库存参数</param> /// <returns>处理结果</returns> public DGStoreResult ReduceStore(StoreParam storeParam) { DGStoreResult storeResult = new DGStoreResult(); if (storeParam != null) { DS_Storage storage = NewDao <IDSDao>().GetStorageInfo(storeParam.DeptID, storeParam.DrugID); if (storage != null) { DS_Batch batch = NewDao <IDSDao>().GetBatchAmount(storeParam.DeptID, storeParam.DrugID, storeParam.BatchNO); if (batch != null) { //本批次存量 和库存总量都必须大于出库数量 if (batch.BatchAmount >= storeParam.Amount && storage.Amount >= storeParam.Amount) { storage.Amount = storage.Amount - storeParam.Amount; storage.save(); batch.BatchAmount -= storeParam.Amount; batch.save(); DGBatchAllot batchAllot = new DGBatchAllot(); batchAllot.BatchNO = storeParam.BatchNO; batchAllot.RetailPrice = batch.RetailPrice; batchAllot.StockPrice = batch.StockPrice; batchAllot.StoreAmount = batch.BatchAmount; batchAllot.StorageID = storage.StorageID; storeResult.BatchAllot = new DGBatchAllot[1]; storeResult.BatchAllot[0] = batchAllot; storeResult.StoreAmount = storage.Amount; storeResult.UnitAmount = storeParam.UnitAmount; storeResult.StorageID = storage.StorageID; return(storeResult); } else { storeResult.Result = 1; storeResult.StoreAmount = storage.Amount; storeResult.UnitAmount = 1; storeResult.StorageID = storage.StorageID; return(storeResult); } } else { storeResult.Result = 1; storeResult.StoreAmount = storage.Amount; storeResult.UnitAmount = 1; storeResult.StorageID = storage.StorageID; return(storeResult); } } else { storeResult.Result = 1; storeResult.StoreAmount = storage.Amount; storeResult.UnitAmount = 1; storeResult.StorageID = storage.StorageID; return(storeResult); } } return(storeResult); }
/// <summary> /// 按批次增加库存 /// </summary> /// <param name="storeParam">药品库存入参</param> /// <returns>库存处理结果</returns> public DGStoreResult AddStore(StoreParam storeParam) { DGStoreResult storeResult = new DGStoreResult(); if (storeParam != null) { DS_Storage storage = NewDao <IDSDao>().GetStorageInfo(storeParam.DeptID, storeParam.DrugID); if (storage != null) { storeParam.StorageId = storage.StorageID; //获取批次数据 DS_Batch batch = NewDao <IDSDao>().GetBatchAmount(storeParam.DeptID, storeParam.DrugID, storeParam.BatchNO); if (batch != null) { //如果批次数量加退货数量大于0 if (batch.BatchAmount + storeParam.Amount >= 0 && storage.Amount + storeParam.Amount >= 0) { if ((batch.BatchAmount + storeParam.Amount) == 0) { //当库存量为零时,把批次记录标记为已删除,新增加该批次库存,然后再标记为有效 batch.DelFlag = 1; } else { batch.DelFlag = 0; } batch.BatchAmount += storeParam.Amount; batch.BindDb(this as AbstractBusines); batch.save(); storage.Amount += storeParam.Amount; storage.BindDb(this as AbstractBusines); storage.save(); //添加成功 DGBatchAllot batchAllot = new DGBatchAllot(); batchAllot.BatchNO = storeParam.BatchNO; batchAllot.RetailPrice = batch.RetailPrice; batchAllot.StockPrice = batch.StockPrice; batchAllot.StoreAmount = batch.BatchAmount; batchAllot.StorageID = storage.StorageID; storeResult.BatchAllot = new DGBatchAllot[1]; storeResult.BatchAllot[0] = batchAllot; storeResult.StoreAmount = storage.Amount; storeResult.UnitAmount = 1; storeResult.StorageID = storage.StorageID; return(storeResult); } else { storeResult.Result = 1; storeResult.StoreAmount = storage.Amount; storeResult.UnitAmount = 1; storeResult.StorageID = storage.StorageID; return(storeResult); } } else { if (storeParam.BussConstant == DGConstant.OP_DS_RETURNSOTRE) { //退库业务 storeResult.Result = 1; return(storeResult); } if (storeParam.BussConstant == DGConstant.OP_DS_FIRSTIN) { if (storeParam.Amount < 0) { storeResult.Result = 1; return(storeResult); } } //新建批次 DS_Batch dwBatch = NewObject <DS_Batch>(); dwBatch.StorageID = storage.StorageID; dwBatch.BatchAmount = storeParam.Amount; dwBatch.BatchNO = storeParam.BatchNO; dwBatch.ValidityTime = storeParam.ValidityTime; dwBatch.DelFlag = 0; dwBatch.DeptID = storeParam.DeptID; dwBatch.DrugID = storeParam.DrugID; dwBatch.DelFlag = 0; dwBatch.UnitAmount = storeParam.PackAmount;//单位系数 dwBatch.InstoreTime = System.DateTime.Now; dwBatch.PackUnit = storeParam.PackUnit; dwBatch.UnitID = storeParam.UnitID; dwBatch.UnitName = storeParam.UnitName; dwBatch.RetailPrice = storeParam.RetailPrice; dwBatch.StockPrice = storeParam.StockPrice; dwBatch.save(); bool addRtn = NewDao <IDSDao>().AddStoreAmount(storeParam.DeptID, storeParam.DrugID, storeParam.Amount);//改库存 if (addRtn) { //构建返回值 DGBatchAllot batchAllot = new DGBatchAllot(); batchAllot.BatchNO = storeParam.BatchNO; batchAllot.RetailPrice = dwBatch.RetailPrice; batchAllot.StockPrice = dwBatch.StockPrice; batchAllot.StoreAmount = dwBatch.BatchAmount; batchAllot.StorageID = storage.StorageID; storeResult.BatchAllot = new DGBatchAllot[1]; storeResult.BatchAllot[0] = batchAllot; storeResult.StoreAmount = storage.Amount + storeParam.Amount; storeResult.UnitAmount = storeParam.PackAmount; storeResult.StorageID = storage.StorageID; } else { //添加失败 storeResult.Result = 2; storeResult.StoreAmount = storage.Amount; storeResult.UnitAmount = storeParam.PackAmount; storeResult.StorageID = storage.StorageID; return(storeResult); } } } else { if (storeParam.BussConstant == DGConstant.OP_DS_RETURNSOTRE) { //如果返库业务 storeResult.Result = 1; return(storeResult); } if (storeParam.Amount < 0) { storeResult.Result = 1; return(storeResult); } //新建库存记录 DS_Storage dwStorage = NewObject <DS_Storage>(); dwStorage.DrugID = storeParam.DrugID; dwStorage.DeptID = storeParam.DeptID; dwStorage.DelFlag = 0; dwStorage.UnitAmount = storeParam.UnitAmount; dwStorage.UnitID = storeParam.UnitID; dwStorage.UnitName = storeParam.UnitName; dwStorage.Amount = storeParam.Amount; dwStorage.PackUnit = storeParam.PackUnit; dwStorage.UpperLimit = 0; dwStorage.LowerLimit = 0; dwStorage.LocationID = 0; dwStorage.Place = string.Empty; dwStorage.RegTime = System.DateTime.Now; dwStorage.LastStockPrice = 0; dwStorage.save(); storeParam.StorageId = dwStorage.StorageID; //新建批次记录 DS_Batch dwBatch = NewObject <DS_Batch>(); dwBatch.StorageID = dwStorage.StorageID; dwBatch.BatchAmount = storeParam.Amount; dwBatch.BatchNO = storeParam.BatchNO; dwBatch.ValidityTime = storeParam.ValidityTime; dwBatch.DelFlag = 0; dwBatch.DeptID = storeParam.DeptID; dwBatch.DrugID = storeParam.DrugID; dwBatch.DelFlag = 0; dwBatch.InstoreTime = dwStorage.RegTime; dwBatch.UnitAmount = storeParam.PackAmount; dwBatch.UnitID = storeParam.UnitID; dwBatch.PackUnit = storeParam.PackUnit; dwBatch.UnitName = storeParam.UnitName; dwBatch.RetailPrice = storeParam.RetailPrice; dwBatch.StockPrice = storeParam.StockPrice; dwBatch.save(); //构建返回值 DGBatchAllot batchAllot = new DGBatchAllot(); batchAllot.BatchNO = storeParam.BatchNO; batchAllot.RetailPrice = storeParam.RetailPrice; batchAllot.StockPrice = storeParam.StockPrice; batchAllot.StoreAmount = storeParam.Amount; batchAllot.StorageID = dwStorage.StorageID; storeResult.BatchAllot = new DGBatchAllot[1] { batchAllot }; storeResult.StoreAmount = storeParam.Amount; storeResult.UnitAmount = storeParam.PackAmount; storeResult.StorageID = dwStorage.StorageID; return(storeResult); } } return(storeResult); }
/// <summary> /// 按先进先出增加库存 /// </summary> /// <param name="storeParam">药品库存入参</param> /// <param name="retAllBatch">true返回所有批次,返回</param> /// <returns>库存处理结果</returns> public DGStoreResult AddStoreAuto(StoreParam storeParam, bool retAllBatch) { DGStoreResult storeResult = new DGStoreResult(); if (storeParam != null) { if (storeParam.Amount < 0) { storeParam.Amount = Math.Abs(storeParam.Amount); } DS_Storage storage = NewDao <IDSDao>().GetStorageInfo(storeParam.DeptID, storeParam.DrugID); if (storage != null) { if (!retAllBatch) { //退药模式,返回最近入库批次 //获取该药品最近入库批次,将药品加到该批次上 DS_Batch latelyBatch = NewDao <IDSDao>().GetLatelyBatchInfo(storeParam.DeptID, storeParam.DrugID); if (latelyBatch != null) { //增加药品库存 storage.Amount += storeParam.Amount; int addStorageRtn = storage.save(); //增加药品批次库存 bool addBatchRtn = NewDao <IDSDao>().UpdateBatchAmount(latelyBatch.DeptID, latelyBatch.DrugID, latelyBatch.BatchNO, storeParam.Amount, 0, 1); //如果批次数量加退货数量大于0 if (addStorageRtn >= 0 && addBatchRtn == true) { //添加成功 DGBatchAllot batchAllot = new DGBatchAllot(); batchAllot.BatchNO = latelyBatch.BatchNO; batchAllot.StoreAmount = latelyBatch.BatchAmount + storeParam.Amount; batchAllot.StorageID = storage.StorageID; batchAllot.RetailPrice = latelyBatch.RetailPrice; batchAllot.StockPrice = latelyBatch.StockPrice; batchAllot.DispAmount = storeParam.Amount; batchAllot.UnitAmount = latelyBatch.UnitAmount; batchAllot.DispRetailFee = batchAllot.CalFee(storeParam.RetailPrice, latelyBatch.UnitAmount, storeParam.Amount); batchAllot.DispStockFee = batchAllot.CalFee(storeParam.StockPrice, latelyBatch.UnitAmount, storeParam.Amount); storeResult.BatchAllotList = new List <DGBatchAllot>(); storeResult.BatchAllotList.Add(batchAllot); storeResult.StoreAmount = storage.Amount + storeParam.Amount; storeResult.UnitAmount = 1; storeResult.StorageID = storage.StorageID; return(storeResult); } else { storeResult.Result = 1; storeResult.StoreAmount = storage.Amount; storeResult.UnitAmount = 1; storeResult.StorageID = storage.StorageID; return(storeResult); } } } else { //盘点模式返回所有批次 decimal profitAmount = storeParam.FactAmount - storeParam.ActAmount; //更新药品库存 storage.Amount += profitAmount; int addStorageRtn = storage.save(); //更新有效库存 if (profitAmount != 0) { UpdateValidStore(storeParam.DrugID, storeParam.DeptID, profitAmount); } //取得所有批次 DataTable dtBatch = NewDao <IDSDao>().GetStorageBatch(storage.StorageID); decimal tempAmount = storeParam.FactAmount; storeResult.BatchAllotList = new List <DGBatchAllot>(); storeResult.StoreAmount = storage.Amount; storeResult.StorageID = storage.StorageID; for (int i = dtBatch.Rows.Count - 1; i >= 0; i--) { DGBatchAllot batchAllot = new DGBatchAllot(); batchAllot.BatchNO = dtBatch.Rows[i]["BatchNO"].ToString(); batchAllot.RetailPrice = Convert.ToDecimal(dtBatch.Rows[i]["RetailPrice"]); batchAllot.StockPrice = Convert.ToDecimal(dtBatch.Rows[i]["StockPrice"]); batchAllot.ValidityDate = Convert.ToDateTime(dtBatch.Rows[i]["ValidityTime"]); batchAllot.StorageID = storage.StorageID; batchAllot.DispAmount = storeParam.Amount; batchAllot.UnitAmount = Convert.ToInt32(dtBatch.Rows[i]["UnitAmount"]); decimal batchAmount = Convert.ToDecimal(dtBatch.Rows[i]["BatchAmount"]); decimal retailPrice = Convert.ToDecimal(dtBatch.Rows[i]["RetailPrice"]); decimal stockPrice = Convert.ToDecimal(dtBatch.Rows[i]["StockPrice"]);//盘点按照批次库存价格调整 decimal unitAmount = Convert.ToDecimal(dtBatch.Rows[i]["UnitAmount"]); decimal factAmount = 0; decimal factStockFee = 0; decimal factRetailFee = 0; decimal actAmount = 0; decimal actStockFee = 0; decimal actRetailFee = 0; if (tempAmount >= batchAmount) { //按照批次数计算金额 if (profitAmount > 0 && i == dtBatch.Rows.Count - 1) { //盘盈加入到最近入库批次 factAmount = batchAmount + profitAmount; factStockFee = batchAllot.CalFee(stockPrice, unitAmount, factAmount); factRetailFee = batchAllot.CalFee(retailPrice, unitAmount, factAmount); actAmount = batchAmount; actStockFee = batchAllot.CalFee(stockPrice, unitAmount, actAmount); actRetailFee = batchAllot.CalFee(retailPrice, unitAmount, actAmount); batchAllot.StoreAmount = factAmount; //更改批次库存 //增加药品批次库存 bool addBatchRtn = NewDao <IDSDao>().UpdateBatchAmount(storeParam.DeptID, storeParam.DrugID, dtBatch.Rows[i]["BatchNO"].ToString(), profitAmount, 0, 1); if (!addBatchRtn) { storeResult.Result = 1; storeResult.StoreAmount = storage.Amount; storeResult.UnitAmount = 1; storeResult.StorageID = storage.StorageID; return(storeResult); } } else { factAmount = batchAmount; factStockFee = batchAllot.CalFee(stockPrice, unitAmount, factAmount); factRetailFee = batchAllot.CalFee(retailPrice, unitAmount, factAmount); actAmount = batchAmount; actStockFee = factStockFee; actRetailFee = factRetailFee; batchAllot.StoreAmount = factAmount; } tempAmount -= batchAmount; } else { if (tempAmount > 0) { //按照剩余数算 factAmount = tempAmount; factStockFee = batchAllot.CalFee(stockPrice, unitAmount, factAmount); factRetailFee = batchAllot.CalFee(retailPrice, unitAmount, factAmount); actAmount = batchAmount; actStockFee = batchAllot.CalFee(stockPrice, unitAmount, actAmount); actRetailFee = batchAllot.CalFee(retailPrice, unitAmount, actAmount); batchAllot.StoreAmount = tempAmount; } else { factAmount = 0; factStockFee = batchAllot.CalFee(stockPrice, unitAmount, factAmount); factRetailFee = batchAllot.CalFee(retailPrice, unitAmount, factAmount); actAmount = batchAmount; actStockFee = batchAllot.CalFee(stockPrice, unitAmount, actAmount); actRetailFee = batchAllot.CalFee(retailPrice, unitAmount, actAmount); batchAllot.StoreAmount = 0; } //增加药品批次库存 bool addBatchRtn = NewDao <IDSDao>().UpdateBatchAmount(storeParam.DeptID, storeParam.DrugID, dtBatch.Rows[i]["BatchNO"].ToString(), -(batchAmount - tempAmount), 0, 1); if (!addBatchRtn) { storeResult.Result = 1; storeResult.StoreAmount = storage.Amount; storeResult.UnitAmount = 1; storeResult.StorageID = storage.StorageID; return(storeResult); } tempAmount = 0; } batchAllot.FactAmount = factAmount; batchAllot.FactStockFee = factStockFee; batchAllot.FactRetailFee = factRetailFee; batchAllot.ActAmount = actAmount; batchAllot.ActStockFee = actStockFee; batchAllot.ActRetailFee = actRetailFee; storeResult.BatchAllotList.Add(batchAllot); } } } } return(storeResult); }
/// <summary> /// 审核单据 /// </summary> /// <param name="headID">药房入库单表头ID</param> /// <param name="auditEmpID">审核人ID</param> /// <param name="auditEmpName">审核人姓名</param> /// <param name="workId">机构ID</param> /// <returns>单据结果对象</returns> public override DGBillResult AuditBill(int headID, int auditEmpID, string auditEmpName, int workId) { DS_InstoreHead head = (DS_InstoreHead)NewObject <DS_InstoreHead>().getmodel(headID); DGBillResult result = new DGBillResult(); if (!NewObject <DrugDeptMgr>().IsDeptChecked(head.DeptID, workId)) { result.Result = 1; result.ErrMsg = "当前科室处于盘点状态或者没有设置科室的盘点状态 不能处理业务操作"; return(result); } if (head != null) { if (head.AuditFlag == 1) { result.Result = 1; result.ErrMsg = "当前数据已经被审核,请确认"; return(result); } List <DS_InStoreDetail> lstDetails = NewObject <DS_InStoreDetail>().getlist <DS_InStoreDetail>("InHeadID=" + headID); head.AuditEmpID = auditEmpID; head.AuditEmpName = auditEmpName; head.AuditTime = System.DateTime.Now; head.AuditFlag = 1; head.save(); foreach (DS_InStoreDetail detail in lstDetails) { DS_Batch batch = NewDao <IDSDao>().GetBatchAmount(Convert.ToInt32(head.DeptID), detail.DrugID, detail.BatchNO); if (batch != null) { if (detail.Amount < 0) { if ((batch.RetailPrice.Equals(detail.RetailPrice) == false) || (batch.StockPrice.Equals(detail.StockPrice) == false)) { result.Result = 1; result.ErrMsg = "编码【" + detail.DrugID.ToString() + "的(进货价/零售价)】与【" + batch.BatchNO + "】批次价格不一致(进货价:" + batch.StockPrice.ToString() + ",零售价:" + batch.RetailPrice.ToString() + "),请核查库存!"; return(result); } } else { if ((batch.RetailPrice.Equals(detail.RetailPrice) == false) || (batch.StockPrice.Equals(detail.StockPrice) == false)) { result.Result = 1; result.ErrMsg = "编码【" + detail.DrugID.ToString() + "的(进货价/零售价)】与【" + batch.BatchNO + "】批次价格不一致(进货价:" + batch.StockPrice.ToString() + ",零售价:" + batch.RetailPrice.ToString() + "),请核查库存!"; return(result); } } } StoreParam storeParam = new StoreParam(); storeParam.BatchNO = detail.BatchNO; storeParam.DeptID = head.DeptID; storeParam.DrugID = detail.DrugID; decimal packAmount = GetPackAmount(detail.DrugID); storeParam.RetailPrice = detail.RetailPrice; storeParam.StockPrice = detail.StockPrice; storeParam.UnitID = detail.UnitID; storeParam.UnitName = detail.UnitName; storeParam.ValidityTime = detail.ValidityDate; storeParam.UnitAmount = Convert.ToInt32(packAmount); storeParam.Amount = detail.Amount;//包装数*系数+基本单位数 storeParam.PackAmount = Convert.ToInt32(packAmount); storeParam.PackUnit = detail.PackUnit; storeParam.BussConstant = head.BusiType; DGStoreResult storeRtn = iStore.AddStore(storeParam); if (storeRtn.Result != 0) { result.Result = 1; if (storeRtn.Result == 1) { result.LstNotEnough = new List <DGNotEnough>(); DGNotEnough notEnough = new DGNotEnough(); notEnough.DeptID = head.DeptID; notEnough.DrugID = detail.DrugID; notEnough.LackAmount = storeRtn.StoreAmount + detail.Amount; notEnough.DrugInfo = "药品编号" + detail.DrugID + "药品批次号:" + detail.BatchNO; result.LstNotEnough.Add(notEnough); result.ErrMsg = "【" + notEnough.DrugInfo + "】库存不足"; } else { result.ErrMsg = "药品更新库存出错"; } return(result); } else { DGStoreResult vStoreRtn = NewObject <DSStore>().AddValidStore(storeParam); WriteAccount(head, detail, storeRtn, packAmount); } } result.Result = 0; return(result); } return(result); }