Exemple #1
0
        /// <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 refMaster = (YP_DRMaster)billMaster;
                refMaster.RetailFee = 0;
                oleDb.BeginTransaction();
                //将发药单据表头写入数据库
                if (listOrder.Count > 0)
                {
                    //添加退药表头
                    BindEntity <HIS.Model.YP_DRMaster> .CreateInstanceDAL(oleDb, Tables.YF_DRMASTER).Add(refMaster);

                    foreach (YP_DROrder order in listOrder)
                    {
                        order.MasterDrugOCID = refMaster.MasterDrugOCID;
                        BindEntity <HIS.Model.YP_DROrder> .CreateInstanceDAL(oleDb, Tables.YF_DRORDER).Add(order);

                        refMaster.RetailFee += order.RetailFee;
                    }
                    refMaster.RetailFee = refMaster.RetailFee * refMaster.RecipeNum;
                    BindEntity <HIS.Model.YP_DRMaster> .CreateInstanceDAL(oleDb, Tables.YF_DRMASTER).Update(refMaster);

                    Hashtable storeTable = StoreFactory.GetProcessor(refMaster.OpType).ChangeStoreNum(billMaster, listOrder);
                    AccountFactory.GetWriter(refMaster.OpType).WriteAccount(billMaster, listOrder, storeTable);
                }
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                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_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;
            }
        }
Exemple #3
0
        /// <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;
            }
        }
Exemple #4
0
        /// <summary>
        /// 住院单人发药
        /// </summary>
        /// <param name="listOrder">发药单明细列表</param>
        /// <param name="dispMaster">发药单表头</param>
        /// <param name="uniformId">统领ID</param>
        private void SingleDisp(List <BillOrder> listOrder, YP_DRMaster dispMaster, int uniformId)
        {
            BindEntity <HIS.Model.YP_DRMaster> .CreateInstanceDAL(oleDb, Tables.YF_DRMASTER).Add(dispMaster);

            //将生成的发药单据表头标识ID赋给所有发药明细
            foreach (BillOrder baseOrder in listOrder)
            {
                YP_DROrder order = (YP_DROrder)baseOrder;
                order.MasterDrugOCID = dispMaster.MasterDrugOCID;
                ZY_BLL.YP_Interface.UpdateSendDrugFlag(order.OrderRecipeID);
                order.UniformID = uniformId;
                BindEntity <HIS.Model.YP_DROrder> .CreateInstanceDAL(oleDb, Tables.YF_DRORDER).Add(order);
            }
            Hashtable storeTable = StoreFactory.GetProcessor(dispMaster.OpType).ChangeStoreNum(dispMaster, listOrder);

            AccountFactory.GetWriter(dispMaster.OpType).WriteAccount(dispMaster, listOrder, storeTable);
        }
Exemple #5
0
        /// <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;
            }
        }
Exemple #6
0
        /// <summary>
        /// 住院单人发药
        /// </summary>
        /// <param name="listOrder">发药单明细列表</param>
        /// <param name="dispMaster">发药单表头</param>
        /// <param name="uniformId">统领ID</param>
        private void SingleDisp(List <BillOrder> listOrder, YP_DRMaster dispMaster, int uniformId)
        {
            dispMaster.RetailFee = Decimal.Round(dispMaster.RetailFee + (decimal)0.00000000001, 2);
            BindEntity <HIS.Model.YP_DRMaster> .CreateInstanceDAL(oleDb, Tables.YF_DRMASTER).Add(dispMaster);

            HIS.Interface.IZY_Data zyInterFace = new HIS.Interface.ZY_Data();
            //将生成的发药单据表头标识ID赋给所有发药明细
            for (int index = 0; index < listOrder.Count; index++)
            {
                YP_DROrder order = (YP_DROrder)listOrder[index];
                order.MasterDrugOCID = dispMaster.MasterDrugOCID;
                order.UniformID      = uniformId;
                if (order.DrugOCNum != 0)
                {
                    BindEntity <HIS.Model.YP_DROrder> .CreateInstanceDAL(oleDb, Tables.YF_DRORDER).Add(order);
                }
                else
                {
                    listOrder.Remove(order);
                    index--;// add zenghao 20100823
                }
                if (order.DrugOC_Flag == 1)
                {
                    zyInterFace.UpdateSendFlag(order.OrderRecipeID, order.DrugOC_Flag, order.DrugOCNum, order.RetailFee);
                }
                else
                {
                    zyInterFace.UpdateSendFlag(order.OrderRecipeID, 2, -order.DrugOCNum, -order.RetailFee);
                }
            }
            Hashtable storeTable = StoreFactory.GetProcessor(dispMaster.OpType).ChangeStoreNum(dispMaster, listOrder);

            foreach (YP_StoreNum storeInfo in storeTable.Values)
            {
                if (storeInfo.storeNum == -1)
                {
                    noStoreList.Add(storeInfo);
                }
            }
            AccountFactory.GetWriter(dispMaster.OpType).WriteAccount(dispMaster, listOrder, storeTable);
        }
        /// <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
            {
                //更改标识位
                HIS.DAL.YP_Dal ypDal = new YP_Dal();
                ypDal._oleDb = oleDb;
                //审核表头对象
                List <BillOrder> totalListOrder = new List <BillOrder>();
                string           str            = Tables.yf_checkmaster.AUDIT_FLAG + oleDb.EuqalTo() + "0" + oleDb.And() +
                                                  Tables.yf_checkmaster.DEL_FLAG + oleDb.NotEqualTo() + "1" + oleDb.And() +
                                                  Tables.yf_checkmaster.DEPTID + oleDb.EuqalTo() + auditDeptID.ToString();
                List <YP_CheckMaster> listMaster = BindEntity <HIS.Model.YP_CheckMaster> .CreateInstanceDAL(oleDb,
                                                                                                            Tables.YF_CHECKMASTER).GetListArray(str);

                if (listMaster.Count <= 0)
                {
                    ConfigManager.EndCheck((int)auditerID);
                    throw new Exception("没有单据需要审核!");
                }
                DateTime _currentTime = XcDate.ServerDateTime;
                int      groupNum     = (ypDal.YP_Bill_GetBillNum(ConfigManager.OP_YF_AUDITCHECK,
                                                                  auditDeptID)).BillNum;
                foreach (YP_CheckMaster checkMaster in listMaster)
                {
                    if (checkMaster.BillNum == 0)
                    {
                        throw new Exception("当前还有单据在盘点中,请确认所有盘点单据都保存成功");
                    }
                    checkMaster.AuditNum      = groupNum;
                    checkMaster.Audit_Flag    = 1;
                    checkMaster.AuditPeopleID = Convert.ToInt32(auditerID);
                    checkMaster.AuditTime     = _currentTime;
                    checkMaster.DeptID        = Convert.ToInt32(auditDeptID);
                    //读取审核表头对象对应的审核明细链表
                    str = Tables.yf_checkorder.MASTERCHECKID + oleDb.EuqalTo() + checkMaster.MasterCheckID;
                    List <YP_CheckOrder> listOrder = BindEntity <HIS.Model.YP_CheckOrder> .CreateInstanceDAL(oleDb,
                                                                                                             Tables.YF_CHECKORDER).GetListArray(str);

                    //构建盘点汇总明细表
                    AddOrderListByMakerId(totalListOrder, listOrder);
                }
                oleDb.BeginTransaction();
                foreach (YP_CheckMaster checkMaster in listMaster)
                {
                    BindEntity <YP_CheckMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_CHECKMASTER).Update(checkMaster);

                    string nameAndValue = Tables.yf_checkorder.AUDIT_FLAG + oleDb.EuqalTo() + "1";
                    BindEntity <HIS.Model.YP_CheckOrder> .CreateInstanceDAL(oleDb,
                                                                            Tables.YF_CHECKORDER).Update(BLL.Tables.yf_checkorder.MASTERCHECKID + oleDb.EuqalTo() + checkMaster.MasterCheckID,
                                                                                                         nameAndValue);
                }
                YP_CheckMaster newMaster = new YP_CheckMaster();
                newMaster.AuditTime = _currentTime;
                newMaster.DeptID    = Convert.ToInt32(auditDeptID);
                newMaster.BillNum   = groupNum;
                newMaster.OpType    = ConfigManager.OP_YF_AUDITCHECK;
                Hashtable storeTable = StoreFactory.GetProcessor(ConfigManager.OP_YF_CHECK).ChangeStoreNum(newMaster, totalListOrder);
                AccountFactory.GetWriter(ConfigManager.OP_YF_CHECK).WriteAccount(newMaster, totalListOrder, storeTable);
                ConfigManager.EndCheck((int)auditDeptID);
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                if (oleDb.IsInTransaction)
                {
                    oleDb.RollbackTransaction();
                }
                throw error;
            }
        }
Exemple #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="billMaster"></param>
        /// <param name="auditerID"></param>
        /// <param name="auditDeptID"></param>
        public override void AuditBill(BillMaster billMaster, long auditerID, long auditDeptID)
        {
            YP_OutMaster outStore = (YP_OutMaster)billMaster;
            string       strWhere = BLL.Tables.yf_outmaster.MASTEROUTSTORAGEID + oleDb.EuqalTo() + outStore.MasterOutStorageID
                                    + oleDb.And() + BLL.Tables.yf_outmaster.AUDIT_FLAG + oleDb.EuqalTo() + "1";

            if (BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_OUTMASTER).Exists(strWhere))
            {
                throw new Exception("该张单据已经审核过。。。");
            }
            try
            {
                //更改标识位
                oleDb.BeginTransaction();
                DateTime _currentTime             = XcDate.ServerDateTime;
                IBaseDAL <YP_OutMaster> masterDao = BindEntity <YP_OutMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_OUTMASTER);

                IBaseDAL <YP_OutOrder> orderDao = BindEntity <YP_OutOrder> .CreateInstanceDAL(oleDb, BLL.Tables.YF_OUTORDER);

                //审核表头信息
                outStore.Audit_Flag    = 1;
                outStore.AuditTime     = _currentTime;
                outStore.AuditPeopleID = Convert.ToInt32(auditerID);
                //获取明细对象链表
                List <YP_OutOrder> listStore = orderDao.GetListArray("MasterOutStorageID=" + outStore.MasterOutStorageID + "");
                base.AuditPrice(outStore, listStore, ConfigManager.YF_SYSTEM);
                masterDao.Update(outStore);
                List <BillOrder> listOrder = new List <BillOrder>();
                //审核明细
                foreach (YP_OutOrder orderOutstore in listStore)
                {
                    orderOutstore.Audit_Flag = 1;
                    orderDao.Update(orderOutstore);
                    listOrder.Add(orderOutstore);
                }
                Hashtable storeTable = StoreFactory.GetProcessor(outStore.OpType).ChangeStoreNum(billMaster, listOrder);
                AccountFactory.GetWriter(outStore.OpType).WriteAccount(billMaster, listOrder, storeTable);
                //如果是药房申领单,则对药房入库申领单进行审核
//add  平级药房调拨 张运辉 [20100531]
                object obj = HIS.SYSTEM.Core.BindEntity <object> .CreateInstanceDAL(oleDb, "yp_deptdic").GetFieldValue("DEPTTYPE1", "DEPTID=" + outStore.OutDeptId);

                if (obj != null && obj.ToString() == "药房")
                //if (outStore.OpType == ConfigManager.OP_YF_APPLYIN)
                {
                    BillMaster             inStore;
                    IBaseDAL <YP_InMaster> yfInMaster = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INMASTER);

                    inStore = yfInMaster.GetModel("BillNum=" + outStore.RelationNum.ToString()
                                                  + " AND OpType='" + ConfigManager.OP_YF_PJDB + "'"
                                                  + " AND Audit_Flag=0" + " AND DeptID=" + outStore.OutDeptId.ToString());
                    new ApplyInProcessor().AuditBill(inStore, auditerID, auditDeptID);
                }
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                outStore.Audit_Flag = 0;
                if (oleDb.IsInTransaction)
                {
                    oleDb.RollbackTransaction();
                }
                throw error;
            }
        }