/// <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_DRMaster dispMaster = (YP_DRMaster)billMaster; dispMaster.RetailFee = 0; YP_Storage store = new YP_Storage(); //将发药单据表头写入数据库 if (listOrder.Count > 0) { //开启发药事务 oleDb.BeginTransaction(); string strWhere = BLL.Tables.yf_drmaster.RECIPEID + oleDb.EuqalTo() + dispMaster.RecipeID.ToString(); if (BindEntity <YP_DRMaster> .CreateInstanceDAL(oleDb, Tables.YF_DRMASTER).Exists(strWhere)) { throw new Exception("该张发票已经发过药品,请刷新病人列表"); } BindEntity <HIS.Model.YP_DRMaster> .CreateInstanceDAL(oleDb, Tables.YF_DRMASTER).Add(dispMaster); //更新处方头 MZ_BLL.YP_Interface.UpdateSendDrugFlag(dispMaster.RecipeID); //将生成的发药单据表头标识ID赋给所有发药明细 foreach (BillOrder baseOrder in listOrder) { YP_DROrder order = (YP_DROrder)baseOrder; order.MasterDrugOCID = dispMaster.MasterDrugOCID; YP_DROrder drOrder = (YP_DROrder)order; BindEntity <HIS.Model.YP_DROrder> .CreateInstanceDAL(oleDb, Tables.YF_DRORDER).Add(order); dispMaster.RetailFee += order.RetailFee; } dispMaster.RetailFee = dispMaster.RetailFee * dispMaster.RecipeNum; BindEntity <HIS.Model.YP_DRMaster> .CreateInstanceDAL(oleDb, Tables.YF_DRMASTER).Update(dispMaster); Hashtable storeTable = StoreFactory.GetProcessor(dispMaster.OpType).ChangeStoreNum(billMaster, listOrder); //foreach (YP_StoreNum storeInfo in storeTable.Values) //{ // if (storeInfo.storeNum == -1) // { // noStoreList.Add(storeInfo); // } //} AccountFactory.GetWriter(dispMaster.OpType).WriteAccount(billMaster, listOrder, storeTable); oleDb.CommitTransaction(); } } catch (Exception error) { if (oleDb.IsInTransaction) { oleDb.RollbackTransaction(); } throw error; } }
public override void UpdateStoreLimit(YP_Storage store) { try { BindEntity <HIS.Model.YP_Storage> .CreateInstanceDAL(oleDb, Tables.YK_STORAGE).Update(store); } catch (Exception error) { throw error; } }
public override decimal QueryNum(int makerDicId, int deptId) { IBaseDAL <YP_Storage> storeDao = BindEntity <YP_Storage> .CreateInstanceDAL(oleDb, BLL.Tables.YK_STORAGE); YP_Storage currentStore = storeDao.GetModel("MakerDicID=" + makerDicId.ToString() + " AND DeptId=" + deptId.ToString()); if (currentStore != null) { return(currentStore.CurrentNum); } else { return(0); } }
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; } }
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; } }
/// <summary> /// 更新库存上下线 /// </summary> /// <param name="store">药品库存实体</param> public abstract void UpdateStoreLimit(YP_Storage store);