/// <summary> /// 重新计算入库单价格和金额,防止审核之前入库单调价 /// </summary> /// <param name="inMaster">入库单表头</param> /// <param name="billOrder">入库单明细</param> /// <param name="belongSystem">药房或药库系统</param> protected void AuditPrice(YP_InMaster inMaster, List <YP_InOrder> billOrder, string belongSystem) { inMaster.RetailFee = 0; inMaster.TradeFee = 0; foreach (YP_InOrder order in billOrder) { YP_MakerDic makerDic = BindEntity <YP_MakerDic> .CreateInstanceDAL(oleDb).GetModel(order.MakerDicID); if (makerDic.RetailPrice != order.RetailPrice || makerDic.TradePrice != order.TradePrice) { order.RetailPrice = makerDic.RetailPrice; order.TradePrice = makerDic.TradePrice; if (belongSystem == ConfigManager.YF_SYSTEM) { if (inMaster.OpType != ConfigManager.OP_YF_APPLYIN) { order.RetailFee = AccountWriter.YF_ComputeTotalFee(order.RetailPrice, order.InNum, order.UnitNum); order.TradeFee = AccountWriter.YF_ComputeTotalFee(order.TradePrice, order.InNum, order.UnitNum); } else { order.RetailFee = AccountWriter.YF_ComputeTotalFee(order.RetailPrice, order.InNum * order.UnitNum, order.UnitNum); order.TradeFee = AccountWriter.YF_ComputeTotalFee(order.TradePrice, order.InNum * order.UnitNum, order.UnitNum); } } else { order.RetailFee = AccountWriter.YK_ComputeTotalFee(order.RetailPrice, order.InNum); order.TradeFee = AccountWriter.YK_ComputeTotalFee(order.TradePrice, order.InNum); } } inMaster.RetailFee += order.RetailFee; inMaster.TradeFee += order.TradeFee; } }
private void FrmInorder_Load(object sender, EventArgs e) { CreateProcessorBySystem(); //如果是添加单据状态 if (_currentState == ADD || _currentState == BACK) { _currentMaster = (YP_InMaster)(_billProcessor.BuildNewMaster(_currentDeptId, _currentUserId)); _currentOrder = (YP_InOrder)(_billProcessor.BuildNewoder(_currentDeptId, _currentMaster)); LoadData(); //设置金额初始值 this.txtStockFee.Text = "0.00"; this.txtStockPrice.Text = "0.000"; this.txtDefStockPrice.Text = "0.000"; } else if (_currentState == UPDATE) { _currentOrder = (YP_InOrder)(_billProcessor.BuildNewoder(_currentDeptId, _currentMaster)); LoadData(); dgrdInOrder_CurrentCellChanged(null, null); } if (_currentMaster.OpType == ConfigManager.OP_YK_BACKSTORE) { this.FormTitle = "退库单据"; } //显示当前表头信息 ShowCurrentMaster(); this.txtSupport.Focus(); }
/// <summary> /// 加载药房申请入库单明细 /// </summary> /// <param name="billMaster">单据头表</param> /// <returns></returns> public override DataTable LoadOrder(BillMaster billMaster) { try { if (billMaster != null) { YP_InMaster inStore = (YP_InMaster)billMaster; string strWhere = ""; YP_Dal ypDal = new YP_Dal(); ypDal._oleDb = oleDb; if (inStore != null) { strWhere = "A.MasterInStorageID=" + inStore.MasterInStorageID.ToString(); strWhere += oleDb.And() + "A.DeptID" + oleDb.EuqalTo() + inStore.DeptID; } else { strWhere = "0<>0"; } return(ypDal.YF_Inorder_GetList(strWhere)); } else { return(null); } } catch (Exception error) { throw error; } }
/// <summary> /// 删除单据 /// </summary> /// <param name="billMaster">单据头表</param> public override void DelBill(BillMaster billMaster) { try { YP_OutMaster outStore = (YP_OutMaster)billMaster; oleDb.BeginTransaction(); YP_Dal ypDal = new YP_Dal(); ypDal._oleDb = oleDb; IBaseDAL <YP_OutMaster> ykmasterDao = BindEntity <YP_OutMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_OUTMASTER); //删除表头信息 ykmasterDao.Update(BLL.Tables.yk_outmaster.MASTEROUTSTORAGEID + oleDb.EuqalTo() + outStore.MasterOutStorageID, BLL.Tables.yf_outmaster.DEL_FLAG + oleDb.EuqalTo() + "1"); if (outStore.OpType == ConfigManager.OP_YK_OUTTOYF) { IBaseDAL <YP_InMaster> yfmasterDao = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INMASTER); //删除表头信息 YP_InMaster deleteMaster = yfmasterDao.GetModel("BillNum=" + outStore.RelationNum.ToString() + " AND OpType='" + ConfigManager.OP_YF_APPLYIN + "'" + " AND DeptID=" + outStore.OutDeptId.ToString()); if (deleteMaster != null) { deleteMaster.Del_Flag = 1; yfmasterDao.Update(deleteMaster); } } oleDb.CommitTransaction(); } catch (Exception error) { oleDb.RollbackTransaction(); throw error; } }
/// <summary> /// 删除药房期初入库单 /// </summary> /// <param name="billMaster">药房期初入库单表头</param> public override void DelBill(BillMaster billMaster) { try { YP_InMaster inStore = (YP_InMaster)billMaster; oleDb.BeginTransaction(); IBaseDAL <YP_InMaster> yfInMaster = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INMASTER); yfInMaster.Update(BLL.Tables.yf_inmaster.MASTERINSTORAGEID + oleDb.EuqalTo() + inStore.MasterInStorageID, BLL.Tables.yf_inmaster.DEL_FLAG + oleDb.EuqalTo() + "1"); YP_Dal ypDal = new YP_Dal(); ypDal._oleDb = oleDb; int deleteID = ypDal.YK_Outmaster_GetIDByBillNum(inStore.BillNum, inStore.DeptID); //做关联删除 if (deleteID != -1) { IBaseDAL <YP_OutMaster> ykOutMaster = BindEntity <YP_OutMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_OUTMASTER); ykOutMaster.Update(BLL.Tables.yk_outmaster.MASTEROUTSTORAGEID + oleDb.EuqalTo() + deleteID, BLL.Tables.yk_outmaster.DEL_FLAG + oleDb.EuqalTo() + "1"); } oleDb.CommitTransaction(); } catch (Exception error) { oleDb.RollbackTransaction(); throw error; } }
private void dgrdInMaker_CurrentCellChanged(object sender, EventArgs e) { try { this.Cursor = GWMHIS.BussinessLogicLayer.Classes.PublicStaticFun.WaitCursor(); if (dgrdInMaker.CurrentCell != null) { int currentIndex = dgrdInMaker.CurrentCell.RowIndex; _currentMaster = GetMasterFromDt(_masterDt.DefaultView.ToTable(), currentIndex); _orderDt = _billQurey.LoadOrder(_currentMaster); dgrdInOrder.DataSource = _orderDt; } else { dgrdInOrder.DataSource = null; _currentMaster = null; } } catch (Exception error) { MessageBox.Show(error.Message); } finally { this.Cursor = DefaultCursor; } }
/// <summary> /// 根据入库表头生成出库表头并添加到数据库中 /// </summary> /// <param name="masterDao">出库表头数据访问对象</param> /// <param name="inMaster">入库表头</param> /// <param name="ypDal">数据访问层对象</param> /// <param name="storedeptId">入库部门ID</param> private YP_OutMaster AddYKOutMaster(IBaseDAL <YP_OutMaster> masterDao, YP_InMaster inMaster, YP_Dal ypDal, int storedeptId) { YP_OutMaster outMaster = new YP_OutMaster(); if (HIS.SYSTEM.Core.BindEntity <object> .CreateInstanceDAL(oleDb, "YP_DEPTDIC").GetFieldValue("DEPTTYPE1", "DEPTID=" + storedeptId).ToString() == "药房") { boPjdb = true; } else { boPjdb = false; } if (boPjdb == true) { ChangeInmasterToOutmaster1(inMaster, storedeptId, outMaster); //update 20100624 outMaster.BillNum = ypDal.YP_Bill_GetBillNum(ConfigManager.OP_YF_DEPTDRAW, storedeptId).BillNum; } else { ChangeInmasterToOutmaster(inMaster, storedeptId, outMaster); //update 20100624 outMaster.BillNum = ypDal.YP_Bill_GetBillNum(ConfigManager.OP_YK_OUTTOYF, storedeptId).BillNum; } masterDao.Add(outMaster); return(outMaster); }
/// <summary> /// 写入台帐 /// </summary> /// <param name="billMaster">单据头表信息</param> /// <param name="orderList">单据明细信息</param> /// <param name="storeTable">库存处理后的最新药品库存信息</param> public override void WriteAccount(BillMaster billMaster, List <BillOrder> orderList, System.Collections.Hashtable storeTable) { try { int actYear = 0, actMonth = 0; YP_InMaster master = (YP_InMaster)billMaster; IBaseDAL <YP_Account> accountDao = BindEntity <YP_Account> .CreateInstanceDAL(oleDb, HIS.BLL.Tables.YK_ACCOUNT); AccountFactory.GetQuery(ConfigManager.YK_SYSTEM).GetAccountTime(master.AuditTime, ref actYear, ref actMonth, master.DeptID); foreach (YP_InOrder order in orderList) { string queryKey = order.MakerDicID.ToString() + order.BatchNum.ToString(); decimal storeNum = ((YP_StoreNum)(storeTable[queryKey])).storeNum; int smallUnit = ((YP_StoreNum)(storeTable[queryKey])).smallUnit; YP_Account account = BuildAccount(billMaster, order, storeNum, actYear, actMonth, smallUnit); ComputeFee(account); accountDao.Add(account); } } catch (Exception error) { throw error; } }
/// <summary> /// 根据单据信息构造台帐信息 /// </summary> /// <param name="billMaster">单据头</param> /// <param name="billOrder">单据明细信息</param> /// <param name="storeNum">库存处理后药品库存信息</param> /// <param name="accountYear">会计年份</param> /// <param name="accountMonth">会计月份</param> /// <param name="smallUnit">基本单位</param> /// <returns>台帐信息</returns> protected override HIS.Model.YP_Account BuildAccount(HIS.Model.BillMaster billMaster, HIS.Model.BillOrder billOrder, decimal storeNum, int accountYear, int accountMonth, int smallUnit) { YP_InMaster master = (YP_InMaster)billMaster; YP_InOrder order = (YP_InOrder)billOrder; YP_Account account = new YP_Account(); account.AccountYear = accountYear; account.AccountMonth = accountMonth; account.AccountType = 2; account.Balance_Flag = 0; account.BillNum = master.BillNum; account.OpType = master.OpType; account.DeptID = master.DeptID; account.LeastUnit = smallUnit; account.UnitNum = order.UnitNum; account.MakerDicID = order.MakerDicID; account.RegTime = master.AuditTime; account.RetailPrice = order.RetailPrice; account.StockPrice = order.TradePrice; account.OrderID = order.InStorageID; account.DebitFee = order.RetailFee; account.DebitNum = order.InNum; account.OverNum = storeNum; return(account); }
//add 平级药房调拨 张运辉 [20100531] /// <summary> /// 将药房出库单表头转换为药房申请入库单表头 /// </summary> /// <param name="inMaster">入库单头表</param> /// <param name="storedeptId">出库库房ID</param> /// <param name="outMaster">出库单表头</param> /// <returns>出库单表头</returns> private YP_InMaster ChangeOutmasterToIntmaster(YP_OutMaster outMaster) { YP_InMaster inMaster = new YP_InMaster(); //outMaster.BillDate = inMaster.BillDate; //outMaster.Del_Flag = 0; //outMaster.OpType = ConfigManager.OP_YK_OUTTOYF; //outMaster.OutFee = inMaster.RetailFee; //outMaster.RegTime = inMaster.RegTime; //outMaster.RelationNum = inMaster.BillNum; //outMaster.ReMark = inMaster.ReMark; //outMaster.RetailFee = inMaster.RetailFee; //outMaster.TradeFee = inMaster.TradeFee; //outMaster.DeptID = storedeptId; //outMaster.OutDeptId = inMaster.DeptID; //outMaster.RegPeopleID = inMaster.RegPeopleID; //return outMaster; inMaster.BillDate = outMaster.BillDate; inMaster.OpType = _opType; inMaster.RetailFee = outMaster.OutFee; inMaster.RegTime = outMaster.RegTime; inMaster.BillNum = outMaster.BillNum; inMaster.ReMark = outMaster.ReMark; inMaster.RetailFee = outMaster.RetailFee; inMaster.TradeFee = outMaster.TradeFee; inMaster.DeptID = outMaster.OutDeptId; inMaster.RegPeopleID = outMaster.RegPeopleID; return(inMaster); }
/// <summary> /// 审核药房申请入库单 /// </summary> /// <param name="billMaster">药房申请入库单表头</param> /// <param name="auditerID">审核人员ID</param> /// <param name="auditDeptID">审核科室ID</param> public override void AuditBill(BillMaster billMaster, long auditerID, long auditDeptID) { YP_InMaster inStore = (YP_InMaster)billMaster; try { ////update 20100624 if (HIS.SYSTEM.Core.BindEntity <object> .CreateInstanceDAL(oleDb, "YP_DEPTDIC").GetFieldValue("DEPTTYPE1", "DEPTID=" + inStore.DeptID).ToString() == "药房") { boPjdb = true; } else { boPjdb = false; } if (billMaster == null) { throw new Exception("对应领药单丢失"); } IBaseDAL <YP_InMaster> yfInMaster = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INMASTER); IBaseDAL <YP_InOrder> yfInOrder = BindEntity <YP_InOrder> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INORDER); List <YP_InOrder> listOrder = yfInOrder.GetListArray("MasterInStorageID=" + inStore.MasterInStorageID + ""); List <BillOrder> billListOrder = new List <BillOrder>(); base.AuditPrice(inStore, listOrder, ConfigManager.YF_SYSTEM); inStore.AuditTime = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime; inStore.Audit_Flag = 1; inStore.AuditPeopleID = Convert.ToInt32(auditerID); yfInMaster.Update(inStore); foreach (YP_InOrder orderInstore in listOrder) { orderInstore.Audit_Flag = 1; yfInOrder.Update(orderInstore); billListOrder.Add(orderInstore); } Hashtable storeTable; if (((YP_InMaster)billMaster).OpType == ConfigManager.OP_YF_PJDB) { ((YP_InMaster)billMaster).OpType = ConfigManager.OP_YF_APPLYIN; storeTable = StoreFactory.GetProcessor(ConfigManager.OP_YF_APPLYIN).ChangeStoreNum(billMaster, billListOrder); } else { storeTable = StoreFactory.GetProcessor(inStore.OpType).ChangeStoreNum(billMaster, billListOrder); } AccountFactory.GetWriter(inStore.OpType).WriteAccount(billMaster, billListOrder, storeTable); } catch (Exception error) { inStore.Audit_Flag = 0; throw error; } }
/// <summary> /// 保存采购入库单 /// </summary> /// <param name="billMaster">采购入库单表头</param> /// <param name="listOrder">采购入库单明细</param> /// <param name="deptId">药剂科室ID</param> public override void SaveBill(BillMaster billMaster, List <BillOrder> listOrder, long deptId) { try { YP_InMaster masterInstore = (YP_InMaster)billMaster; YP_InOrder inStore = new YP_InOrder(); oleDb.BeginTransaction(); //声明操作对象 IBaseDAL <YP_InMaster> inMasterDao = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_INMASTER); IBaseDAL <YP_InOrder> inOrderDao = BindEntity <YP_InOrder> .CreateInstanceDAL(oleDb, BLL.Tables.YK_INORDER); IBaseDAL <YP_Storage> storeDao = BindEntity <YP_Storage> .CreateInstanceDAL(oleDb, BLL.Tables.YK_STORAGE); YP_Dal ypDal = new YP_Dal(); ypDal._oleDb = oleDb; //获取入库单据号 if (masterInstore.OpType == ConfigManager.OP_YK_INOPTYPE) { masterInstore.BillNum = ypDal.YP_Bill_GetBillNum(ConfigManager.OP_YK_INOPTYPE, deptId).BillNum; } else if (masterInstore.OpType == ConfigManager.OP_YK_BACKSTORE) { masterInstore.BillNum = ypDal.YP_Bill_GetBillNum(ConfigManager.OP_YK_BACKSTORE, deptId).BillNum; } else { masterInstore.BillNum = ypDal.YP_Bill_GetBillNum(ConfigManager.OP_YK_FIRSTIN, deptId).BillNum; } inMasterDao.Add(masterInstore); foreach (BillOrder order in listOrder) { //遍历DataTable取出明细记录并设置记录的值 inStore = (YP_InOrder)order; //计算入库金额 masterInstore.RetailFee += inStore.RetailFee; masterInstore.StockFee += inStore.StockFee; masterInstore.TradeFee += inStore.TradeFee; inStore.MasterInStorageID = masterInstore.MasterInStorageID; inStore.BillNum = masterInstore.BillNum; //依次添加明细记录 inOrderDao.Add(inStore); } inMasterDao.Update(masterInstore); oleDb.CommitTransaction(); } catch (Exception error) { oleDb.RollbackTransaction(); throw error; } }
/// <summary> /// 将药房申请入库单表头转换为药库出库单表头 /// </summary> /// <param name="inMaster">入库单头表</param> /// <param name="storedeptId">出库库房ID</param> /// <param name="outMaster">出库单表头</param> /// <returns>出库单表头</returns> private static YP_OutMaster ChangeInmasterToOutmaster1(YP_InMaster inMaster, int storedeptId, YP_OutMaster outMaster) { outMaster.BillDate = inMaster.BillDate; outMaster.Del_Flag = 0; outMaster.OpType = ConfigManager.OP_YF_DEPTDRAW; outMaster.OutFee = inMaster.RetailFee; outMaster.RegTime = inMaster.RegTime; outMaster.RelationNum = inMaster.BillNum; outMaster.ReMark = inMaster.ReMark; outMaster.RetailFee = inMaster.RetailFee; outMaster.TradeFee = inMaster.TradeFee; outMaster.DeptID = storedeptId; outMaster.OutDeptId = inMaster.DeptID; outMaster.RegPeopleID = inMaster.RegPeopleID; return(outMaster); }
public override Hashtable ChangeStoreNum(BillMaster billMaster, List <BillOrder> orderList) { try { Hashtable storeNumHash = new Hashtable(); YP_InMaster inStore = (YP_InMaster)billMaster; foreach (BillOrder order in orderList) { YP_StoreNum storeNum = new YP_StoreNum(); YP_InOrder orderInstore = (YP_InOrder)order; storeNum.makerDicId = orderInstore.MakerDicID; storeNum.smallUnit = orderInstore.LeastUnit; IBaseDAL <YP_Storage> storeDao = BindEntity <YP_Storage> .CreateInstanceDAL(oleDb, BLL.Tables.YK_STORAGE); //增加库存 decimal rtn = base.AddStoreNum(orderInstore.MakerDicID, orderInstore.DeptID, orderInstore.InNum); if (rtn == -1) { YP_Storage drugStore = new YP_Storage(); drugStore.CurrentNum = orderInstore.InNum; drugStore.Del_Flag = 0; drugStore.DeptID = inStore.DeptID; drugStore.LeastUnit = storeNum.smallUnit; drugStore.LowerLimit = 0; drugStore.LStockPrice = orderInstore.StockPrice; drugStore.MakerDicID = orderInstore.MakerDicID; drugStore.RegTime = inStore.RegTime; drugStore.UnitNum = orderInstore.UnitNum; drugStore.UpperLimit = 0; storeDao.Add(drugStore); storeNum.storeNum = orderInstore.InNum; } else { storeNum.storeNum = rtn; } storeNum.queryKey = orderInstore.MakerDicID.ToString() + orderInstore.BatchNum.ToString(); storeNumHash.Add(storeNum.queryKey, storeNum); } BatchProcessor.AddBatchNum(orderList, inStore.RegTime); return(storeNumHash); } catch (Exception error) { throw error; } }
//add 平级药房调拨 张运辉 [20100531] /// <summary> /// 将药房申请入库单表头转换为药库出库单表头 /// </summary> /// <param name="inMaster">入库单头表</param> /// <param name="storedeptId">出库库房ID</param> /// <param name="outMaster">出库单表头</param> /// <returns>出库单表头</returns> private YP_OutMaster ChangeInmasterToOutmaster(YP_InMaster inMaster) { YP_OutMaster outMaster = new YP_OutMaster(); outMaster.BillDate = inMaster.BillDate; outMaster.Del_Flag = 0; outMaster.OpType = inMaster.OpType; outMaster.OutFee = inMaster.RetailFee; outMaster.RegTime = inMaster.RegTime; outMaster.RelationNum = inMaster.BillNum; outMaster.ReMark = inMaster.ReMark; outMaster.RetailFee = inMaster.RetailFee; outMaster.TradeFee = inMaster.TradeFee; outMaster.DeptID = (int)_currentDeptId; outMaster.OutDeptId = inMaster.DeptID; outMaster.RegPeopleID = inMaster.RegPeopleID; return(outMaster); }
/// <summary> /// 删除采购入库单 /// </summary> /// <param name="billMaster">单据表头</param> public override void DelBill(BillMaster billMaster) { try { YP_InMaster inStore = (YP_InMaster)billMaster; oleDb.BeginTransaction(); IBaseDAL <YP_InMaster> ykInMaster = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_INMASTER); ykInMaster.Update(BLL.Tables.yk_inmaster.MASTERINSTORAGEID + oleDb.EuqalTo() + inStore.MasterInStorageID, BLL.Tables.yk_inmaster.DEL_FLAG + oleDb.EuqalTo() + "1"); oleDb.CommitTransaction(); } catch (Exception error) { oleDb.RollbackTransaction(); throw error; } }
/// <summary> /// 药库入库单审核 /// </summary> /// <param name="billMaster">药库入库单头表</param> /// <param name="auditerID">审核人员ID</param> /// <param name="auditDeptID">审核部门ID</param> public override void AuditBill(BillMaster billMaster, long auditerID, long auditDeptID) { try { YP_InMaster inStore = (YP_InMaster)billMaster; string strWhere = BLL.Tables.yk_inmaster.MASTERINSTORAGEID + oleDb.EuqalTo() + inStore.MasterInStorageID + oleDb.And() + BLL.Tables.yk_inmaster.AUDIT_FLAG + oleDb.EuqalTo() + "1"; if (BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_INMASTER).Exists(strWhere)) { throw new Exception("该张单据已经审核过。。。"); } oleDb.BeginTransaction(); DateTime _currentTime = XcDate.ServerDateTime; inStore.AuditTime = _currentTime; inStore.Audit_Flag = 1; inStore.AuditPeopleID = Convert.ToInt32(auditerID); IBaseDAL <YP_InOrder> ykInOrder = BindEntity <YP_InOrder> .CreateInstanceDAL(oleDb, BLL.Tables.YK_INORDER); IBaseDAL <YP_InMaster> ykInMaster = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_INMASTER); List <YP_InOrder> listStore = ykInOrder.GetListArray("MasterInStorageID=" + inStore.MasterInStorageID + ""); base.AuditPrice(inStore, listStore, ConfigManager.YK_SYSTEM); ykInMaster.Update(inStore); List <BillOrder> listOrder = new List <BillOrder>(); AccountWriter actWriter = AccountFactory.GetWriter(inStore.OpType); foreach (YP_InOrder orderInstore in listStore) { orderInstore.Audit_Flag = 1; ykInOrder.Update(orderInstore); listOrder.Add(orderInstore); } Hashtable storeTable = StoreFactory.GetProcessor(inStore.OpType).ChangeStoreNum(billMaster, listOrder); AccountFactory.GetWriter(inStore.OpType).WriteAccount(billMaster, listOrder, storeTable); oleDb.CommitTransaction(); } catch (Exception error) { if (oleDb.IsInTransaction) { oleDb.RollbackTransaction(); } throw error; } }
/// <summary> /// 将数据表中指定位置的记录转成入库表头记录对象 /// </summary> /// <param name="dtTable"> /// 数据表 /// </param> /// <param name="index"> /// 对应记录的索引 /// </param> /// <returns> /// 转换之后生成的入库表头记录对象 /// </returns> private YP_InMaster GetMasterFromDt(DataTable dtTable, int index) { try { if (dtTable.Rows.Count < index || dtTable.Rows.Count == 0) { return(null); } YP_InMaster currentInmaster = new YP_InMaster(); currentInmaster.SupportDic = new YP_SupportDic(); HIS.SYSTEM.PubicBaseClasses.ApiFunction.DataTableToObject(dtTable, index, currentInmaster); currentInmaster.SupportDic.Name = dtTable.Rows[index]["SupportName"].ToString(); return(currentInmaster); } catch (Exception error) { throw error; } }
/// <summary> /// 修改采购入库单 /// </summary> /// <param name="billMaster">采购入库单表头</param> /// <param name="listOrder">采购入库单明细列表</param> /// <param name="deptId">药剂科室ID</param> public override void UpdateBill(BillMaster billMaster, List <BillOrder> listOrder, long deptId) { try { YP_InMaster masterInstore = (YP_InMaster)billMaster; YP_InOrder orderInstore = new YP_InOrder(); oleDb.BeginTransaction(); //声明操作对象 IBaseDAL <YP_InMaster> inMasterDao = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_INMASTER); IBaseDAL <YP_InOrder> inOrderDao = BindEntity <YP_InOrder> .CreateInstanceDAL(oleDb, BLL.Tables.YK_INORDER); //如果明细不为空重新更新整个入库单表头及明细 if (listOrder != null) { masterInstore.RetailFee = 0; masterInstore.StockFee = 0; masterInstore.TradeFee = 0; inOrderDao.Delete("MasterInStorageID=" + masterInstore.MasterInStorageID.ToString()); foreach (BillOrder order in listOrder) { //遍历DataTable取出明细记录并设置记录的值 orderInstore = (YP_InOrder)order; //计算入库金额 masterInstore.RetailFee += orderInstore.RetailFee; masterInstore.TradeFee += orderInstore.TradeFee; masterInstore.StockFee += orderInstore.StockFee; orderInstore.MasterInStorageID = masterInstore.MasterInStorageID; orderInstore.BillNum = masterInstore.BillNum; //依次添加明细记录 inOrderDao.Add(orderInstore); } } //明细为空仅更新表头 inMasterDao.Update(masterInstore); oleDb.CommitTransaction(); } catch (Exception error) { oleDb.RollbackTransaction(); throw error; } }
private void tsrbtnNew_Click(object sender, EventArgs e) { try { //生成一个新的单据表头 _currentMaster = (YP_InMaster)(_billProcessor.BuildNewMaster(_currentDeptId, _currentUserId)); _currentMaster.SupportDicID = _outDept.DeptID; _currentOrder = (YP_InOrder)(_billProcessor.BuildNewoder(_currentDeptId, _currentMaster)); //加载数据 LoadData(); ClearOrderTextbox(); ShowCurrentMaster(); _currentState = ADD; this.cobBillTime.Focus(); } catch (Exception error) { MessageBox.Show(error.Message); } }
private void FrmYFInorder_Load(object sender, EventArgs e) { try { this.Cursor = GWMHIS.BussinessLogicLayer.Classes.PublicStaticFun.WaitCursor(); if (!_isBuildByLimit) { if (_currentState == ADD) { //生成一个新的单据表头 _currentMaster = (YP_InMaster)(_billProcessor.BuildNewMaster(_currentDeptId, _currentUserId)); _currentMaster.SupportDicID = _outDept.DeptID; } _currentOrder = (YP_InOrder)(_billProcessor.BuildNewoder(_currentDeptId, _currentMaster)); LoadData(); } else { _billProcessor.BuildApplyInByStoreLimit(out _currentMaster, out _inOrderDt, (int)_currentDeptId, (int)_currentUserId, _outDept.DeptID, _limitDt); _currentOrder = (YP_InOrder)(_billProcessor.BuildNewoder(_currentDeptId, _currentMaster)); dgrdInOrder.AutoGenerateColumns = false; dgrdInOrder.DataSource = _inOrderDt; _drugInfoDt = _storeQuery.LoadDrugInfo(_outDept.DeptID, (int)_currentDeptId); txtDgCode.SetSelectionCardDataSource(_drugInfoDt); _isBuildByLimit = false; } //显示当前表头信息 this.txtApplyDept.Text = _outDept.DeptName; ShowCurrentMaster(); this.cobBillTime.Focus(); } catch (Exception error) { MessageBox.Show(error.Message); } finally { this.Cursor = DefaultCursor; } }
private void tsrbtnNew_Click(object sender, EventArgs e) { try { //生成一个新的单据表头 if (_belongSystem == ConfigManager.YF_SYSTEM) { _currentMaster = (YP_InMaster)(_billProcessor.BuildNewMaster(_currentDeptId, _currentUserId)); _currentOrder = (YP_InOrder)(_billProcessor.BuildNewoder(_currentDeptId, _currentMaster)); _inOrderDt = BillFactory.GetQuery(ConfigManager.OP_YF_INSTORE).LoadOrder(_currentMaster); } else { _currentMaster = (YP_InMaster)(_billProcessor.BuildNewMaster(_currentDeptId, _currentUserId)); _currentOrder = (YP_InOrder)(_billProcessor.BuildNewoder(_currentDeptId, _currentMaster)); _inOrderDt = BillFactory.GetQuery(ConfigManager.OP_YK_INOPTYPE).LoadOrder(_currentMaster); } //加载数据 dgrdInOrder.DataSource = _inOrderDt; ClearOrderTextbox(); ShowCurrentMaster(); //设置金额初始值 txtStockFee.Text = "0.00"; txtStockPrice.Text = "0.000"; txtDefStockPrice.Text = "0.000"; if (_currentMaster.OpType == ConfigManager.OP_YK_BACKSTORE) { _currentState = BACK; } else { _currentState = ADD; } this.txtSupport.Focus(); } catch (Exception error) { MessageBox.Show(error.Message); } }
/// <summary> /// 保存药房期初入库单 /// </summary> /// <param name="billMaster">期初入库单表头</param> /// <param name="listOrder">期初入库单明细列表</param> /// <param name="deptId">药剂科室ID</param> public override void SaveBill(BillMaster billMaster, List <BillOrder> listOrder, long deptId) { try { YP_InOrder orderInstore; YP_InMaster masterInstore = (YP_InMaster)billMaster; oleDb.BeginTransaction(); //声明操作对象 IBaseDAL <YP_InMaster> inMasterDao = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INMASTER); IBaseDAL <YP_InOrder> inOrderDao = BindEntity <YP_InOrder> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INORDER); YP_Dal ypDal = new YP_Dal(); ypDal._oleDb = oleDb; //获取入库单据号 masterInstore.BillNum = (ypDal.YP_Bill_GetBillNum(ConfigManager.OP_YF_INSTORE, deptId)).BillNum; masterInstore.OpType = ConfigManager.OP_YF_INSTORE; inMasterDao.Add(masterInstore); foreach (BillOrder order in listOrder) { orderInstore = (YP_InOrder)order; //计算入库金额 masterInstore.RetailFee += orderInstore.RetailFee; masterInstore.TradeFee += orderInstore.TradeFee; masterInstore.StockFee += orderInstore.StockFee; orderInstore.MasterInStorageID = masterInstore.MasterInStorageID; orderInstore.BillNum = masterInstore.BillNum; //依次添加明细记录 inOrderDao.Add(orderInstore); } inMasterDao.Update(masterInstore); oleDb.CommitTransaction(); } catch (Exception error) { oleDb.RollbackTransaction(); throw error; } }
/// <summary> /// 创建采购入库单 /// </summary> /// <param name="deptId">部门ID</param> /// <param name="userId">用户ID</param> /// <returns></returns> override public BillMaster BuildNewMaster(long deptId, long userId) { YP_InMaster inStore = new YP_InMaster(); try { inStore.RegPeopleID = Convert.ToInt32(userId); inStore.DeptID = Convert.ToInt32(deptId); inStore.Audit_Flag = 0; inStore.Del_Flag = 0; inStore.Pay_Flag = 0; inStore.OpManID = Convert.ToInt32(userId); inStore.RegTime = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime; inStore.BillDate = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime; inStore.InvoiceDate = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime; inStore.SupportDic = new YP_SupportDic(); return(inStore); } catch (Exception error) { throw error; } }
private void dgrdInMaker_CurrentCellChanged(object sender, EventArgs e) { try { this.Cursor = GWMHIS.BussinessLogicLayer.Classes.PublicStaticFun.WaitCursor(); if (dgrdInMaker.CurrentCell != null) { int currentIndex = dgrdInMaker.CurrentCell.RowIndex; _currentMaster = GetMasterFromDt(_masterDt.DefaultView.ToTable(), currentIndex); //add 平级药房调拨 张运辉 [20100531] if (_currentMaster.OpType == ConfigManager.OP_YF_PJDB) { _orderDt = BillFactory.GetQuery(ConfigManager.OP_YF_APPLYIN).LoadOrder(_currentMaster); tribmange(false); } else { _orderDt = BillFactory.GetQuery(_currentMaster.OpType).LoadOrder(_currentMaster); tribmange(true); } dgrdInOrder.DataSource = _orderDt; } else { dgrdInOrder.DataSource = null; _currentMaster = null; } } catch (Exception error) { MessageBox.Show(error.Message); } finally { this.Cursor = DefaultCursor; } }
public override Hashtable ChangeStoreNum(BillMaster billMaster, List <BillOrder> orderList) { try { Hashtable storeNumHash = new Hashtable(); YP_InMaster inStore = (YP_InMaster)billMaster; foreach (BillOrder order in orderList) { YP_StoreNum storeNum = new YP_StoreNum(); YP_InOrder orderInstore = (YP_InOrder)order; storeNum.makerDicId = orderInstore.MakerDicID; storeNum.smallUnit = orderInstore.LeastUnit; IBaseDAL <YP_Storage> storeDao = BindEntity <YP_Storage> .CreateInstanceDAL(oleDb, BLL.Tables.YK_STORAGE); //增加库存 decimal rtn = base.ReduceStoreNum(orderInstore.MakerDicID, orderInstore.DeptID, orderInstore.InNum); if (rtn != -1) { storeNum.storeNum = rtn; storeNum.queryKey = storeNum.makerDicId.ToString() + orderInstore.BatchNum; } else { string drugName = DrugBaseDataBll.GetDurgName(storeNum.makerDicId); throw new Exception("[" + drugName + "]" + "退库数量过多,审核失败"); } storeNumHash.Add(storeNum.queryKey, storeNum); } BatchProcessor.BackBatchNum(orderList); return(storeNumHash); } catch (Exception error) { throw error; } }
/// <summary> /// 按药房库存上下限构建入库申请单 /// </summary> /// <param name="newMaster">申请单表头</param> /// <param name="orderDt">申请单明细列表</param> /// <param name="_currentDeptId">申请科室</param> /// <param name="_currentUserId">申请人员ID</param> /// <param name="applyDept">出库科室</param> /// <param name="lowerStoreDrug">低于库存下限药品</param> public void BuildApplyInByStoreLimit(out YP_InMaster newMaster, out DataTable orderDt, int _currentDeptId, int _currentUserId, int applyDept, DataTable lowerStoreDrug) { try { if (lowerStoreDrug == null) { newMaster = null; orderDt = null; return; } decimal drugStoreNum; //药品库存数量 decimal lessNum; //还需申请数量 decimal batchStoreNum; //批次库存量 decimal applyNum; //总共需申请数量 int currentMakerDicId; //当前药品编码 StoreQuery _storeQuery = StoreFactory.GetQuery(ConfigManager.YF_SYSTEM); BillQuery _billQuery = BillFactory.GetQuery(ConfigManager.OP_YF_APPLYIN); StoreQuery _applyDeptStoreQuery = StoreFactory.GetQuery(ConfigManager.YK_SYSTEM); //构建一个新的入库申请单表头 newMaster = (YP_InMaster)(this.BuildNewMaster(_currentDeptId, _currentUserId)); orderDt = _billQuery.LoadOrder(newMaster); #region 循环低于下限的药品 for (int index = 0; index < lowerStoreDrug.Rows.Count; index++) { DataRow limitRow = lowerStoreDrug.Rows[index]; //获取当前药品编码 currentMakerDicId = Convert.ToInt32(limitRow["MAKERDICID"]); //计算需要申请入库药品数量 applyNum = (Convert.ToDecimal(limitRow["UPPERLIMIT"]) - Convert.ToDecimal(limitRow["CURRENTNUM"])) / Convert.ToDecimal(limitRow["PUNITNUM"]); applyNum = Math.Ceiling(applyNum); //按药品编码加载批次 DataTable batchDt = _applyDeptStoreQuery.LoadBatch(currentMakerDicId, applyDept); if (batchDt == null) { break; } drugStoreNum = 0; //判断批次总量是否满足申请要求 for (int temp = 0; temp < batchDt.Rows.Count; temp++) { drugStoreNum += Convert.ToDecimal(batchDt.Rows[temp]["CURRENTNUM"]); } if (drugStoreNum > applyNum) { #region 如果满足,循环批次生成入库单明细 for (int temp = 0; temp < batchDt.Rows.Count; temp++) { lessNum = applyNum; batchStoreNum = Convert.ToDecimal(batchDt.Rows[temp]["CURRENTNUM"]); if (batchStoreNum != 0) { DataRow newRow = orderDt.NewRow(); newRow["MAKERDICID"] = limitRow["MAKERDICID"]; //厂家ID newRow["CHEMNAME"] = limitRow["CHEMNAME"]; //化学名 newRow["SPEC"] = limitRow["SPEC"]; //规格 newRow["PRODUCTNAME"] = limitRow["PRODUCTNAME"]; //生产厂家名 newRow["RETAILPRICE"] = limitRow["RETAILPRICE"]; //零售价 newRow["TRADEPRICE"] = limitRow["TRADEPRICE"]; //批发价 newRow["STOCKPRICE"] = limitRow["TRADEPRICE"]; //进价 newRow["LEASTUNIT"] = limitRow["PACKUNIT"]; //包装单位编码 newRow["UNITNAME"] = limitRow["PACKUNITNAME"]; //包装单位 newRow["BATCHNUM"] = batchDt.Rows[temp]["BATCHNUM"]; //批次号 newRow["DEPTID"] = limitRow["DEPTID"]; //部门ID newRow["UNITNUM"] = limitRow["PUNITNUM"]; //单位数量 newRow["VALIDITYDATE"] = Convert.ToDateTime(batchDt.Rows[temp]["VALIDITYDATE"]); newRow["AUDIT_FLAG"] = 0; newRow["BILLNUM"] = 0; newRow["DELIVERNUM"] = ""; newRow["InStorageID"] = 0; newRow["MasterInStorageID"] = 0; newRow["REMARK"] = ""; newRow["DEFSTOCKPRICE"] = limitRow["TRADEPRICE"]; newRow["RecScale"] = 0.0; //批次数量大于还需申请数量 if (batchStoreNum >= lessNum) { if (lessNum < 1) { break; } else { //lessNum = Math.Ceiling(lessNum); newRow["INNUM"] = lessNum; //入库数量 newRow["TRADEFEE"] = lessNum * Convert.ToDecimal(newRow["TRADEPRICE"]); //批发金额 newRow["RETAILFEE"] = lessNum * Convert.ToDecimal(newRow["RETAILPRICE"]); //零售金额 newRow["STOCKFEE"] = newRow["TRADEFEE"]; //进货金额 orderDt.Rows.Add(newRow); break; } } //批次数量小于还需申请数量 else { newRow["INNUM"] = batchStoreNum; newRow["TRADEFEE"] = lessNum * Convert.ToDecimal(newRow["TRADEPRICE"]); //批发金额 newRow["RETAILFEE"] = lessNum * Convert.ToDecimal(newRow["RETAILPRICE"]); //零售金额 newRow["STOCKFEE"] = newRow["TRADEFEE"]; lessNum = applyNum - batchStoreNum; //进货金额 orderDt.Rows.Add(newRow); } } } #endregion 如果满足,循环批次生成入库单明细 } } #endregion 循环低于下限的药品 } catch (Exception error) { throw error; } }
/// <summary> /// 保存药房入库申请单 /// </summary> /// <param name="billMaster">申请单表头</param> /// <param name="listOrder">申请单明细</param> /// <param name="deptId">药剂科室ID</param> public override void SaveBill(BillMaster billMaster, List <BillOrder> listOrder, long deptId) { try { IBaseDAL <YP_OutMaster> outMasterDao; IBaseDAL <YP_OutOrder> outOrderDao; IBaseDAL <YP_Storage> storeDao; YP_InMaster masterInstore = (YP_InMaster)billMaster; ////update 20100624 if (HIS.SYSTEM.Core.BindEntity <object> .CreateInstanceDAL(oleDb, "YP_DEPTDIC").GetFieldValue("DEPTTYPE1", "DEPTID=" + deptId).ToString() == "药房") { boPjdb = true; } else { boPjdb = false; } YP_InOrder inStore = new YP_InOrder(); oleDb.BeginTransaction(); IBaseDAL <YP_InMaster> inMasterDao = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INMASTER); IBaseDAL <YP_InOrder> inOrderDao = BindEntity <YP_InOrder> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INORDER); if (boPjdb) { outMasterDao = BindEntity <YP_OutMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_OUTMASTER); outOrderDao = BindEntity <YP_OutOrder> .CreateInstanceDAL(oleDb, BLL.Tables.YF_OUTORDER); storeDao = BindEntity <YP_Storage> .CreateInstanceDAL(oleDb, BLL.Tables.YF_STORAGE); } else { outMasterDao = BindEntity <YP_OutMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_OUTMASTER); outOrderDao = BindEntity <YP_OutOrder> .CreateInstanceDAL(oleDb, BLL.Tables.YK_OUTORDER); storeDao = BindEntity <YP_Storage> .CreateInstanceDAL(oleDb, BLL.Tables.YK_STORAGE); } YP_Dal ypDal = new YP_Dal(); ypDal._oleDb = oleDb; //获取入库单据号 masterInstore.BillNum = (ypDal.YP_Bill_GetBillNum(ConfigManager.OP_YF_APPLYIN, masterInstore.DeptID)).BillNum; if (!boPjdb) { masterInstore.OpType = ConfigManager.OP_YF_APPLYIN; } inMasterDao.Add(masterInstore); YP_OutMaster outMaster = AddYKOutMaster(outMasterDao, masterInstore, ypDal, Convert.ToInt32(deptId)); foreach (BillOrder order in listOrder) { //遍历DataTable取出明细记录并设置记录的值 inStore = (YP_InOrder)order; //计算入库金额 masterInstore.RetailFee += inStore.RetailFee; masterInstore.StockFee += inStore.StockFee; masterInstore.TradeFee += inStore.TradeFee; inStore.MasterInStorageID = masterInstore.MasterInStorageID; inStore.BillNum = masterInstore.BillNum; inStore.DeptID = masterInstore.DeptID; //依次添加明细记录 inOrderDao.Add(inStore); AddYKOutOrder(outOrderDao, inStore, deptId, outMaster); } inMasterDao.Update(masterInstore); outMaster.RetailFee = masterInstore.RetailFee; outMaster.TradeFee = masterInstore.TradeFee; outMaster.OutFee = masterInstore.RetailFee; outMasterDao.Update(outMaster); oleDb.CommitTransaction(); } catch (Exception error) { oleDb.RollbackTransaction(); throw error; } }
/// <summary> /// 根据药房申请入库单更新对应药库出库单明细 /// </summary> /// <param name="listOrder">药库出库单明细列表</param> /// <param name="deptId">出库科室ID</param> /// <param name="masterInstore">药房申请入库单</param> /// <param name="orderInstore">申请入库单明细</param> /// <returns>申请入库单明细</returns> private YP_InOrder UpdateOutMaster(List <BillOrder> listOrder, long deptId, YP_InMaster masterInstore, YP_InOrder orderInstore) { IBaseDAL <YP_OutMaster> ypOutMaster; IBaseDAL <YP_OutOrder> outOrderDao; string strWhere; //update 20100624 if (HIS.SYSTEM.Core.BindEntity <object> .CreateInstanceDAL(oleDb, "YP_DEPTDIC").GetFieldValue("DEPTTYPE1", "DEPTID=" + deptId).ToString() == "药房") { boPjdb = true; } else { boPjdb = false; } if (boPjdb) { ypOutMaster = BindEntity <YP_OutMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_OUTMASTER); strWhere = BLL.Tables.yf_outmaster.BILLNUM + oleDb.EuqalTo() + masterInstore.BillNum + oleDb.And() + BLL.Tables.yf_outmaster.OPTYPE + oleDb.EuqalTo() + "'" + ConfigManager.OP_YF_DEPTDRAW + "'" + oleDb.And() + BLL.Tables.yf_outmaster.AUDIT_FLAG + oleDb.EuqalTo() + 0 + oleDb.And() + BLL.Tables.yf_outmaster.REGTIME + oleDb.EuqalTo() + "'" + masterInstore.RegTime + "'"; } else { ypOutMaster = BindEntity <YP_OutMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_OUTMASTER); strWhere = BLL.Tables.yk_outmaster.RELATIONNUM + oleDb.EuqalTo() + masterInstore.BillNum + oleDb.And() + BLL.Tables.yk_outmaster.OPTYPE + oleDb.EuqalTo() + "'" + ConfigManager.OP_YK_OUTTOYF + "'" + oleDb.And() + BLL.Tables.yk_outmaster.AUDIT_FLAG + oleDb.EuqalTo() + 0 + oleDb.And() + BLL.Tables.yk_outmaster.REGTIME + oleDb.EuqalTo() + "'" + masterInstore.RegTime + "'"; } YP_OutMaster outMaster = ypOutMaster.GetModel(strWhere); outMaster.RetailFee = 0; outMaster.TradeFee = 0; outMaster.OutFee = 0; if (outMaster != null) { int storeDeptId = outMaster.DeptID; ChangeInmasterToOutmaster(masterInstore, storeDeptId, outMaster); if (boPjdb) { outOrderDao = BindEntity <YP_OutOrder> .CreateInstanceDAL(oleDb, BLL.Tables.YF_OUTORDER); outOrderDao.Delete(BLL.Tables.yf_outorder.MASTEROUTSTORAGEID + oleDb.EuqalTo() + outMaster.MasterOutStorageID); } else { outOrderDao = BindEntity <YP_OutOrder> .CreateInstanceDAL(oleDb, BLL.Tables.YK_OUTORDER); outOrderDao.Delete(BLL.Tables.yk_outorder.MASTEROUTSTORAGEID + oleDb.EuqalTo() + outMaster.MasterOutStorageID); } foreach (BillOrder order in listOrder) { orderInstore = (YP_InOrder)order; AddYKOutOrder(outOrderDao, orderInstore, deptId, outMaster); } } ypOutMaster.Update(outMaster); return(orderInstore); }
public override Hashtable ChangeStoreNum(BillMaster billMaster, List <BillOrder> orderList) { try { Hashtable storeNumHash = new Hashtable(); YP_InMaster inStore = (YP_InMaster)billMaster; YP_Dal ypDal = new YP_Dal(); ypDal._oleDb = oleDb; foreach (YP_InOrder orderInstore in orderList) { decimal addNum = 0; YP_StoreNum storeNum = new YP_StoreNum(); storeNum.makerDicId = orderInstore.MakerDicID; IBaseDAL <YP_Storage> storeDao = BindEntity <YP_Storage> .CreateInstanceDAL(oleDb, BLL.Tables.YF_STORAGE); if (inStore.OpType == ConfigManager.OP_YF_INSTORE) { addNum = orderInstore.InNum; storeNum.smallUnit = orderInstore.LeastUnit; } else { addNum = orderInstore.InNum * orderInstore.UnitNum; storeNum.smallUnit = ypDal.Unit_GetSmallUnit(storeNum.makerDicId); } //增加库存 decimal rtn = base.AddStoreNum(orderInstore.MakerDicID, orderInstore.DeptID, addNum); if (rtn == -1) { if (addNum <= 0) { string drugName = "[" + DrugBaseDataBll.GetDurgName(orderInstore.MakerDicID) + "]"; throw new Exception(drugName + "药品库存数量为0,无法录入负数"); } YP_Storage drugStore = new YP_Storage(); drugStore.CurrentNum = addNum; drugStore.Del_Flag = 0; drugStore.DeptID = inStore.DeptID; drugStore.LeastUnit = storeNum.smallUnit; drugStore.LowerLimit = 0; drugStore.LStockPrice = orderInstore.StockPrice; drugStore.MakerDicID = orderInstore.MakerDicID; drugStore.RegTime = inStore.RegTime; drugStore.UnitNum = orderInstore.UnitNum; drugStore.UpperLimit = 0; storeDao.Add(drugStore); storeNum.storeNum = addNum; } else { storeNum.storeNum = rtn; } storeNum.queryKey = orderInstore.MakerDicID.ToString() + orderInstore.BatchNum.ToString(); storeNumHash.Add(storeNum.queryKey, storeNum); } return(storeNumHash); } catch (Exception error) { throw error; } }