Ejemplo n.º 1
0
        /// <summary>
        /// 删除药房入库单
        /// </summary>
        /// <param name="billID">药房入库单表头ID</param>
        public override void DeleteBill(int billID)
        {
            DS_InstoreHead inHead = (DS_InstoreHead)NewObject <DS_InstoreHead>().getmodel(billID);

            if (inHead.AuditFlag == 1)
            {
                throw new Exception("当前单据已经审核,无法删除");
            }
            else
            {
                inHead.DelFlag = 1;
                inHead.save();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 保存药房入库单
        /// </summary>
        /// <typeparam name="THead">药房入库单表头模板</typeparam>
        /// <typeparam name="TDetail">药房入库单明细模板</typeparam>
        /// <param name="billHead">药房入库单表头</param>
        /// <param name="billDetails">药房入库单明细</param>
        public override void SaveBill <THead, TDetail>(THead billHead, List <TDetail> billDetails)
        {
            DS_InstoreHead          inHead   = billHead as DS_InstoreHead;
            List <DS_InStoreDetail> inDetals = billDetails as List <DS_InStoreDetail>;

            inHead.RegTime = System.DateTime.Now;
            string serialNO = NewObject <SerialNumberSource>().GetSerialNumber(SnType.药品, inHead.DeptID, inHead.BusiType);

            inHead.BillNO = Convert.ToInt64(serialNO);
            BindDb(inHead);
            inHead.save();
            if (inHead.InHeadID > 0)
            {
                foreach (DS_InStoreDetail detail in inDetals)
                {
                    detail.InHeadID = inHead.InHeadID;
                    detail.BillNO   = inHead.BillNO;
                    detail.DeptID   = inHead.DeptID;
                    BindDb(detail);
                    detail.save();
                }
            }
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 审核单据
        /// </summary>
        /// <param name="headID">药房入库单表头ID</param>
        /// <param name="auditEmpID">审核人ID</param>
        /// <param name="auditEmpName">审核人姓名</param>
        /// <returns>处理结果</returns>
        public override DGBillResult AuditBill(int headID, int auditEmpID, string auditEmpName)
        {
            DS_InstoreHead head   = (DS_InstoreHead)NewObject <DS_InstoreHead>().getmodel(headID);
            DGBillResult   result = new DGBillResult();

            if (head != null)
            {
                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)
                {
                    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   = detail.UnitAmount;
                    storeParam.Amount       = detail.Amount;//包装数*系数+基本单位数
                    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
                    {
                        WriteAccount(head, detail, storeRtn, packAmount);
                    }
                }

                result.Result = 0;
                return(result);
            }

            return(result);
        }