Exemplo n.º 1
0
        /// <summary>
        /// 台账写入--批次发退药价格差额台账
        /// </summary>
        /// <param name="billHead">发药单表头</param>
        /// <param name="billDetails">发药单明细</param>
        /// <param name="storeParam">库存参数</param>
        /// <param name="batchAllot">批次</param>
        public void WriteAccount(DS_OPDispHead billHead, DS_OPDispDetail billDetails, StoreParam storeParam, DGBatchAllot batchAllot)
        {
            int    actYear;
            int    actMonth;
            string errMsg;

            if (!GetAccountTime(billHead.DeptID, out errMsg, out actYear, out actMonth))
            {
                throw new Exception(errMsg);
            }

            DS_Account account = NewObject <DS_Account>();

            account.BalanceYear  = actYear;
            account.BalanceMonth = actMonth;
            account.AccountType  = 3;//药房
            account.BalanceFlag  = 0;
            account.BatchNO      = billDetails.BatchNO;
            account.BusiType     = billHead.BusiType;
            account.CTypeID      = billDetails.CTypeID;
            account.DeptID       = billDetails.DeptID;
            account.DetailID     = billDetails.DispDetailID;
            account.DrugID       = billDetails.DrugID;
            account.UnitID       = billDetails.UnitID;
            account.UnitName     = billDetails.UnitName;
            account.RegTime      = DateTime.Now;

            //盘盈 借方
            //盘亏 贷方
            if (storeParam.RetailPrice < billDetails.RetailPrice)
            {
                //该批次大于处方零售价写入 贷方
                account.StockPrice  = billDetails.StockPrice;
                account.RetailPrice = billDetails.RetailPrice;
                //发生调整时,数量为0,只调价格
                account.DebitAmount    = 0; //Math.Abs(billDetails.DispAmount);
                account.DebitRetailFee = GetFee(Math.Abs(billDetails.DispAmount), billDetails.UnitAmount, billDetails.RetailPrice, billHead.RecipeAmount) - GetFee(Math.Abs(billDetails.DispAmount), billDetails.UnitAmount, storeParam.RetailPrice, billHead.RecipeAmount);
                account.DebitStockFee  = GetFee(Math.Abs(billDetails.DispAmount), billDetails.UnitAmount, billDetails.StockPrice, billHead.RecipeAmount) - GetFee(Math.Abs(billDetails.DispAmount), billDetails.UnitAmount, storeParam.StockPrice, billHead.RecipeAmount);

                account.OverAmount    = batchAllot.StoreAmount;
                account.OverRetailFee = batchAllot.StoreAmount * (account.RetailPrice / batchAllot.UnitAmount);
                account.OverStockFee  = batchAllot.StoreAmount * (account.StockPrice / batchAllot.UnitAmount);
            }
            else
            {
                //发药 借方
                account.StockPrice  = billDetails.StockPrice;
                account.RetailPrice = billDetails.RetailPrice;
                //发生调整时,数量为0,只调价格
                account.LendAmount    = 0;//billDetails.DispAmount;
                account.LendRetailFee = GetFee(billDetails.DispAmount, billDetails.UnitAmount, storeParam.RetailPrice, billHead.RecipeAmount) - GetFee(billDetails.DispAmount, billDetails.UnitAmount, billDetails.RetailPrice, billHead.RecipeAmount);
                account.LendStockFee  = GetFee(billDetails.DispAmount, billDetails.UnitAmount, storeParam.StockPrice, billHead.RecipeAmount) - GetFee(billDetails.DispAmount, billDetails.UnitAmount, billDetails.StockPrice, billHead.RecipeAmount);

                account.OverAmount    = batchAllot.StoreAmount;
                account.OverRetailFee = batchAllot.StoreAmount * (account.RetailPrice / batchAllot.UnitAmount);
                account.OverStockFee  = batchAllot.StoreAmount * (account.StockPrice / batchAllot.UnitAmount);
            }

            account.save();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 将费用明细转换成实体模型
        /// </summary>
        /// <param name="dtRefund">退药明细</param>
        /// <param name="deptId">药房ID</param>
        /// <returns>将费用明细转换成实体模型集</returns>
        private List <DS_OPDispDetail> ConvertRefundDetailModel(DataTable dtRefund, int deptId)
        {
            List <DS_OPDispDetail> dispDetail = new List <DS_OPDispDetail>();

            foreach (DataRow row in dtRefund.Rows)
            {
                DS_OPDispDetail modelDetail = new DS_OPDispDetail();
                modelDetail.DispHeadID  = 0;
                modelDetail.FeeDetailID = Convert.ToInt32(row["ReDetailID"]);
                modelDetail.CTypeID     = Convert.ToInt32(row["CTypeID"]);
                modelDetail.DrugID      = Convert.ToInt32(row["DrugID"]);
                modelDetail.DrugSpec    = row["Spec"].ToString();
                modelDetail.ChemName    = row["ChemName"].ToString();
                modelDetail.ProductName = row["ProductName"].ToString();
                modelDetail.UnitID      = Convert.ToInt32(row["MiniUnitID"]);
                modelDetail.UnitName    = row["MiniUnit"].ToString();
                modelDetail.PackUnit    = row["PackUnit"].ToString();
                modelDetail.UnitAmount  = Convert.ToInt32(row["UnitNO"]);
                modelDetail.DispAmount  = Convert.ToInt32(row["RefundAmount"]);
                modelDetail.RetailPrice = Convert.ToDecimal(row["RetailPrice"]);
                modelDetail.StockPrice  = Convert.ToDecimal(row["StockPrice"]);
                modelDetail.BatchNO     = string.Empty;
                modelDetail.RetailFee   = Convert.ToDecimal(row["RefundFee"]);
                decimal base_num = 0;//基本数--转换成包装数还剩多少基本数
                base_num = Convert.ToInt32(row["RefundAmount"]) % Convert.ToInt32(row["UnitNO"]);
                decimal relation_num = Convert.ToDecimal(row["UnitNO"]);
                decimal presAmount   = Convert.ToDecimal(row["RefundAmount"]);
                decimal pack_num     = Convert.ToDecimal((presAmount - base_num) / relation_num);
                decimal price        = Convert.ToDecimal(row["StockPrice"]);
                decimal num          = Convert.ToDecimal(row["PresAmount"]);
                modelDetail.StockFee      = (pack_num * price + (price / relation_num) * base_num) * num;
                modelDetail.RetFlag       = 1;//发药0退药1
                modelDetail.RefundFlag    = 0;
                modelDetail.UseAmount     = 0;
                modelDetail.UseWay        = string.Empty;
                modelDetail.Frequency     = string.Empty;
                modelDetail.UseUnit       = string.Empty;
                modelDetail.Orders        = string.Empty;
                modelDetail.DeptID        = deptId;
                modelDetail.FeeItemHeadID = Convert.ToInt32(row["FeeItemHeadID"]);
                dispDetail.Add(modelDetail);
            }

            return(dispDetail);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 将费用明细转换成实体模型
        /// </summary>
        /// <param name="feeHeadIds">过滤条件</param>
        /// <param name="deptId">药房</param>
        /// <returns>将费用明细转换成实体模型集</returns>
        private List <DS_OPDispDetail> ConvertFeeDetailModel(string feeHeadIds, int deptId)
        {
            List <DS_OPDispDetail> dispDetail = new List <DS_OPDispDetail>();
            DataTable dtFeeDetails            = NewObject <DrugStoreManagement>().GetFeeItemDetail(feeHeadIds);

            foreach (DataRow row in dtFeeDetails.Rows)
            {
                DS_OPDispDetail modelDetail = new DS_OPDispDetail();
                modelDetail.DispHeadID    = 0;
                modelDetail.FeeDetailID   = Convert.ToInt32(row["PresDetailID"]);
                modelDetail.CTypeID       = Convert.ToInt32(row["CTypeID"]);
                modelDetail.DrugID        = Convert.ToInt32(row["DrugID"]);
                modelDetail.DrugSpec      = row["Spec"].ToString();
                modelDetail.ChemName      = row["ChemName"].ToString();
                modelDetail.ProductName   = row["ProductName"].ToString();
                modelDetail.UnitID        = Convert.ToInt32(row["MiniUnitID"]);
                modelDetail.UnitName      = row["MiniUnit"].ToString();
                modelDetail.PackUnit      = row["PackUnit"].ToString();
                modelDetail.UnitAmount    = Convert.ToInt32(row["UnitNO"]);
                modelDetail.DispAmount    = Convert.ToInt32(row["Amount"]);
                modelDetail.RetailPrice   = Convert.ToDecimal(row["RetailPrice"]);
                modelDetail.StockPrice    = Convert.ToDecimal(row["StockPrice"]);
                modelDetail.BatchNO       = string.Empty;
                modelDetail.RetailFee     = Convert.ToDecimal(row["TotalFee"]);
                modelDetail.StockFee      = 0;
                modelDetail.RetFlag       = 0;//发药0退药1
                modelDetail.RefundFlag    = 0;
                modelDetail.UseAmount     = 0;
                modelDetail.UseWay        = string.Empty;
                modelDetail.Frequency     = string.Empty;
                modelDetail.UseUnit       = string.Empty;
                modelDetail.Orders        = string.Empty;
                modelDetail.DeptID        = deptId;
                modelDetail.FeeItemHeadID = Convert.ToInt32(row["FeeItemHeadID"]);
                dispDetail.Add(modelDetail);
            }

            return(dispDetail);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 台账写入--批次发退药数量台账
        /// </summary>
        /// <param name="billHead">发药单表头</param>
        /// <param name="billDetails">发药单明细</param>
        /// <param name="batchAllot">批次</param>
        /// <param name="refundFlag">退药标志</param>
        /// <param name="storeParam">库存处理参数</param>
        public void WriteAccount(DS_OPDispHead billHead, DS_OPDispDetail billDetails, DGBatchAllot batchAllot, int refundFlag, StoreParam storeParam)
        {
            int    actYear;
            int    actMonth;
            string errMsg;

            if (!GetAccountTime(billHead.DeptID, out errMsg, out actYear, out actMonth))
            {
                throw new Exception(errMsg);
            }

            DS_Account account = NewObject <DS_Account>();

            account.BalanceYear  = actYear;
            account.BalanceMonth = actMonth;
            account.AccountType  = 0;//药房
            account.BalanceFlag  = 0;
            account.BatchNO      = billDetails.BatchNO;
            account.BusiType     = billHead.BusiType;
            account.CTypeID      = billDetails.CTypeID;
            account.DeptID       = billDetails.DeptID;
            account.DetailID     = billDetails.DispDetailID;
            account.DrugID       = billDetails.DrugID;
            account.UnitID       = billDetails.UnitID;
            account.UnitName     = billDetails.UnitName;
            account.RegTime      = DateTime.Now;
            account.UnitAmount   = batchAllot.UnitAmount;

            //盘盈 借方
            //盘亏 贷方
            if (billDetails.RetFlag == 1 || refundFlag == 1)
            {
                //退药 借方
                account.StockPrice    = storeParam.StockPrice;
                account.RetailPrice   = storeParam.RetailPrice;
                account.LendAmount    = Math.Abs(billDetails.DispAmount);
                account.LendRetailFee = batchAllot.DispRetailFee;
                account.LendStockFee  = batchAllot.DispStockFee;

                account.OverAmount = batchAllot.StoreAmount;

                //当药品批次价格和实际价格不一致时,退药按实际价格退
                if (storeParam.RetailPrice.Equals(batchAllot.RetailPrice) == false)
                {
                    account.OverRetailFee = batchAllot.StoreAmount * (storeParam.RetailPrice / storeParam.UnitAmount);
                }
                else
                {
                    account.OverRetailFee = batchAllot.StoreAmount * (batchAllot.RetailPrice / batchAllot.UnitAmount);
                }

                if (storeParam.StockPrice.Equals(batchAllot.StockPrice) == false)
                {
                    account.OverStockFee = batchAllot.StoreAmount * (storeParam.StockPrice / storeParam.UnitAmount);
                }
                else
                {
                    account.OverStockFee = batchAllot.StoreAmount * (batchAllot.StockPrice / batchAllot.UnitAmount);
                }
            }
            else
            {
                //发药 贷方
                account.StockPrice     = storeParam.StockPrice;
                account.RetailPrice    = storeParam.RetailPrice;
                account.DebitAmount    = billDetails.DispAmount;
                account.DebitRetailFee = batchAllot.DispRetailFee;
                account.DebitStockFee  = batchAllot.DispStockFee;

                account.OverAmount = batchAllot.StoreAmount;

                //当发药时价格和实际批次价格不一致时,剩余价格等于加上要发出的数量*调价后的金额减去发出药量的总金额(发出药量是按批次表原有的价格算的)
                if (storeParam.RetailPrice.Equals(batchAllot.RetailPrice) == false)
                {
                    account.OverRetailFee = ((batchAllot.StoreAmount + billDetails.DispAmount) * (batchAllot.RetailPrice / batchAllot.UnitAmount)) - batchAllot.DispRetailFee;
                }
                else
                {
                    account.OverRetailFee = batchAllot.StoreAmount * (batchAllot.RetailPrice / batchAllot.UnitAmount);
                }

                if (storeParam.StockPrice.Equals(batchAllot.StockPrice) == false)
                {
                    account.OverStockFee = ((batchAllot.StoreAmount + billDetails.DispAmount) * (batchAllot.StockPrice / batchAllot.UnitAmount)) - batchAllot.DispStockFee;
                }
                else
                {
                    account.OverStockFee = batchAllot.StoreAmount * (batchAllot.StockPrice / batchAllot.UnitAmount);
                }
            }

            account.save();
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取头表信息
        /// </summary>
        /// <param name="opType">业务类型</param>
        /// <param name="deptId">科室Id</param>
        /// <param name="detailID">明细Id</param>
        /// <returns>头表信息</returns>
        public BillMasterShower GetBillHeadInfo(string opType, int deptId, int detailID)
        {
            BillMasterShower shower = new BillMasterShower();

            switch (opType)
            {
            case "011":    //采购入库
            case "012":    //期初入库
            case "013":    //流通入库
                DS_InStoreDetail inStoreDetail = (DS_InStoreDetail)NewObject <DS_InStoreDetail>().getmodel(detailID);
                if (inStoreDetail != null)
                {
                    DS_InstoreHead instoreHead = (DS_InstoreHead)NewObject <DS_InstoreHead>().getmodel(inStoreDetail.InHeadID);
                    if (instoreHead != null)
                    {
                        shower.RegTime          = instoreHead.RegTime;
                        shower.AuditTime        = instoreHead.AuditTime;
                        shower.BillNo           = instoreHead.BillNO.ToString();
                        shower.RelationPeopleNo = instoreHead.OpEmpID.ToString();
                        shower.RelationPeople   = instoreHead.OpEmpName;
                        shower.RelationUnit     = instoreHead.SupplierName;
                        shower.RetailFee        = instoreHead.RetailFee;
                        shower.StockFee         = instoreHead.StockFee;
                        shower.OpType           = GetBusiTypeName(opType);
                        shower.RegPeople        = instoreHead.RegEmpName;
                        shower.Remark           = instoreHead.Remark;
                    }
                }

                break;

            case "021":    //内耗出库
            case "022":    //报损出库
                DS_OutStoreDetail outStoreDetail = (DS_OutStoreDetail)NewObject <DS_OutStoreDetail>().getmodel(detailID);
                if (outStoreDetail != null)
                {
                    DS_OutStoreHead outStoreHead = (DS_OutStoreHead)NewObject <DS_OutStoreHead>().getmodel(outStoreDetail.OutHeadID);
                    if (outStoreDetail != null)
                    {
                        shower.RegTime          = outStoreHead.RegTime;
                        shower.AuditTime        = outStoreHead.AuditTime;
                        shower.BillNo           = outStoreHead.BillNO.ToString();
                        shower.RelationPeopleNo = "暂无";
                        shower.RelationPeople   = "暂无";
                        shower.RelationUnit     = outStoreHead.ToDeptName;
                        shower.RetailFee        = outStoreHead.RetailFee;
                        shower.StockFee         = outStoreHead.StockFee;
                        shower.OpType           = GetBusiTypeName(opType);
                        shower.RegPeople        = outStoreHead.RegEmpName;
                        shower.Remark           = outStoreHead.Remark;
                    }
                }

                break;

            case "031":    //门诊发药
            case "032":    //门诊退药
                DS_OPDispDetail oPDispDetail = (DS_OPDispDetail)NewObject <DS_OPDispDetail>().getmodel(detailID);
                if (oPDispDetail != null)
                {
                    DS_OPDispHead oPDispHead = (DS_OPDispHead)NewObject <DS_OPDispHead>().getmodel(oPDispDetail.DispHeadID);
                    if (oPDispHead != null)
                    {
                        shower.RegTime          = oPDispHead.DispTime;
                        shower.AuditTime        = oPDispHead.DispTime;
                        shower.BillNo           = oPDispHead.BillNO.ToString();
                        shower.RelationPeopleNo = "暂无";
                        shower.RelationPeople   = "暂无";
                        shower.RelationUnit     = oPDispHead.PresDeptName;
                        shower.RetailFee        = oPDispHead.RetailFee;
                        shower.StockFee         = 0;
                        shower.OpType           = GetBusiTypeName(opType);
                        shower.RegPeople        = oPDispHead.PharmacistName;
                        shower.Remark           = string.Empty;
                    }
                }

                break;

            case "033":    //住院发药
                DS_IPDispDetail iPDispDetail = (DS_IPDispDetail)NewObject <DS_IPDispDetail>().getmodel(detailID);
                if (iPDispDetail != null)
                {
                    DS_IPDispHead iPDispHead = (DS_IPDispHead)NewObject <DS_IPDispHead>().getmodel(iPDispDetail.DispHeadID);
                    if (iPDispHead != null)
                    {
                        shower.RegTime          = iPDispHead.DispTime;
                        shower.AuditTime        = iPDispHead.DispTime;
                        shower.BillNo           = iPDispHead.BillNO.ToString();
                        shower.RelationPeopleNo = "暂无";
                        shower.RelationPeople   = "暂无";
                        shower.RelationUnit     = GetDeptName(iPDispHead.DeptID);
                        shower.RetailFee        = iPDispHead.RetailFee;
                        shower.StockFee         = 0;
                        shower.OpType           = GetBusiTypeName(opType);
                        shower.RegPeople        = GetEmpName(iPDispHead.PharmacistID);
                        shower.Remark           = string.Empty;
                    }
                }

                break;

            case "042":    //盘点审核
                DS_AuditDetail auditDetail = (DS_AuditDetail)NewObject <DS_AuditDetail>().getmodel(detailID);
                if (auditDetail != null)
                {
                    DS_AuditHead auditHead = (DS_AuditHead)NewObject <DS_AuditHead>().getmodel(auditDetail.AuditHeadID);
                    if (auditHead != null)
                    {
                        shower.RegTime          = auditHead.AuditTime;
                        shower.AuditTime        = auditHead.AuditTime;
                        shower.BillNo           = auditHead.BillNO.ToString();
                        shower.RelationPeopleNo = auditHead.EmpID.ToString();
                        shower.RelationPeople   = auditHead.EmpName;
                        shower.RelationUnit     = GetDeptName(auditHead.DeptID);
                        shower.RetailFee        = auditHead.CheckRetailFee;
                        shower.StockFee         = auditHead.CheckStockFee;
                        shower.OpType           = GetBusiTypeName(opType);
                        shower.RegPeople        = auditHead.EmpName;
                        shower.Remark           = string.Empty;
                    }
                }

                break;

            case "051":    //药房调价
                DG_AdjDetail adjDetail = (DG_AdjDetail)NewObject <DG_AdjDetail>().getmodel(detailID);
                if (adjDetail != null)
                {
                    DG_AdjHead adjHead = (DG_AdjHead)NewObject <DG_AdjHead>().getmodel(adjDetail.AdjHeadID);
                    if (adjHead != null)
                    {
                        shower.RegTime          = adjHead.RegTime;
                        shower.AuditTime        = adjHead.ExecTime;
                        shower.BillNo           = adjHead.BillNO.ToString();
                        shower.RelationPeopleNo = adjHead.RegEmpID.ToString();
                        shower.RelationPeople   = GetEmpName(adjHead.RegEmpID);
                        shower.RelationUnit     = GetDeptName(adjHead.DeptID);
                        shower.RetailFee        = 0;
                        shower.StockFee         = 0;
                        shower.OpType           = GetBusiTypeName(opType);
                        shower.RegPeople        = GetEmpName(adjHead.RegEmpID);
                        shower.Remark           = adjHead.Remark;
                    }
                }

                break;
            }

            return(shower);
        }