Exemplo n.º 1
0
        /// <summary>
        /// 台账写入
        /// </summary>
        /// <typeparam name="THead">药房出库单表头模板</typeparam>
        /// <typeparam name="TDetail">药房出库单明细模板</typeparam>
        /// <param name="billHead">药房出库单表头</param>
        /// <param name="billDetails">药房出库单明细</param>
        /// <param name="storeResult">库存处理结果</param>
        /// <param name="packAmount">包装数量</param>
        public void WriteAccount <THead, TDetail>(THead billHead, TDetail billDetails, DGStoreResult storeResult, decimal packAmount)
        {
            //1、构建台账表实体;
            //2、根据台账表内容填写相应的信息;
            //3、保存台账表
            DS_OutStoreDetail detail = billDetails as DS_OutStoreDetail;
            DS_OutStoreHead   head   = billHead as DS_OutStoreHead;
            int    actYear;
            int    actMonth;
            string errMsg;

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

            packAmount = packAmount > 0 ? packAmount : GetPackAmount(detail.DrugID);
            DS_Account account = NewObject <DS_Account>();

            account.BalanceYear  = actYear;
            account.BalanceMonth = actMonth;
            account.AccountType  = 0;
            account.BalanceFlag  = 0;
            account.BillNO       = head.BillNO;
            account.BatchNO      = detail.BatchNO;
            account.BusiType     = head.BusiType;
            account.CTypeID      = detail.CTypeID;
            account.DeptID       = head.DeptID;
            account.DetailID     = detail.OutDetailID;
            account.DrugID       = detail.DrugID;
            account.UnitID       = detail.UnitID;
            account.UnitName     = detail.UnitName;
            account.RegTime      = System.DateTime.Now;
            account.UnitAmount   = Convert.ToInt32(packAmount);
            if (head.BusiType == DGConstant.OP_DS_RETURNSOTRE)
            {
                account.StockPrice     = storeResult.BatchAllot[0].StockPrice;
                account.RetailPrice    = storeResult.BatchAllot[0].RetailPrice;
                account.DebitAmount    = detail.Amount;
                account.DebitRetailFee = account.DebitAmount * (account.RetailPrice / packAmount);
                account.DebitStockFee  = account.DebitAmount * (account.StockPrice / packAmount);
            }
            else
            {
                account.StockPrice     = detail.StockPrice;
                account.RetailPrice    = detail.RetailPrice;
                account.DebitAmount    = detail.Amount;
                account.DebitRetailFee = account.DebitAmount * (account.RetailPrice / packAmount);
                account.DebitStockFee  = account.DebitAmount * (account.StockPrice / packAmount);
            }

            account.OverAmount    = storeResult.BatchAllot[0].StoreAmount;
            account.OverStockFee  = storeResult.BatchAllot[0].StoreAmount * (account.RetailPrice / packAmount);
            account.OverRetailFee = storeResult.BatchAllot[0].StoreAmount * (account.StockPrice / packAmount);
            account.save();
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public void SaveBill(string frmName)
        {
            Action <ClientRequestData> requestAction = null;
            ServiceResponseData        retdata       = null;

            RefreshHead(frmName);
            if (frmName == "FrmOutStoreDetailDW")
            {
                currentDWHead.StockFee  = 0;
                currentDWHead.RetailFee = 0;
                List <DW_OutStoreDetail> lstDetails = new List <DW_OutStoreDetail>();
                for (int index = 0; index < currentDWDetails.Rows.Count; index++)
                {
                    DW_OutStoreDetail detail = ConvertExtend.ToObject <DW_OutStoreDetail>(currentDWDetails, index);
                    var pAmount = 0;
                    if (currentDWDetails.Rows[index]["pAmount"] != DBNull.Value)
                    {
                        pAmount = Convert.ToInt32(currentDWDetails.Rows[index]["pAmount"].ToString());
                    }

                    detail.Amount            = pAmount;
                    detail.DeptID            = currentDWHead.DeptID;
                    detail.ToDeptID          = currentDWHead.ToDeptID;
                    currentDWHead.StockFee  += detail.StockFee;
                    currentDWHead.RetailFee += detail.RetailFee;
                    lstDetails.Add(detail);
                }

                requestAction = ((ClientRequestData request) =>
                {
                    request.AddData(DGConstant.OP_DW_SYSTEM);
                    request.AddData(currentDWHead.BusiType);
                    request.AddData(currentDWHead);
                    request.AddData <List <DW_OutStoreDetail> >(lstDetails);
                    request.AddData <List <int> >(frmOutstoreDetailDW.GetDeleteDetails());
                });

                if (frmOutstoreDetailDW.IsApplyStatus == true)
                {
                    retdata = InvokeWcfService("DrugProject.Service", "OutStoreController", "SaveBillFromApply", requestAction);
                }
                else
                {
                    retdata = InvokeWcfService("DrugProject.Service", "OutStoreController", "SaveBill", requestAction);
                }

                DGBillResult result = retdata.GetData <DGBillResult>(0);
                if (result.Result == 0)
                {
                    frmOutstoreDetailDW.IsApplyStatus = false;
                    MessageBoxShowSimple("单据已经保存成功,如果没有配置自动审核.请及时审核单据");
                    if (billStatus == DGEnum.BillEditStatus.ADD_STATUS)
                    {
                        frmOutstoreDetailDW.NewBillClear();
                    }
                    else
                    {
                        frmOutstoreDetailDW.CloseCurrentWindow();
                    }
                }
                else
                {
                    MessageBoxShowSimple("单据保存失败:" + result.ErrMsg);
                }
            }
            else
            {
                currentDSHead.StockFee  = 0;
                currentDSHead.RetailFee = 0;
                List <DS_OutStoreDetail> lstDetails = new List <DS_OutStoreDetail>();
                for (int index = 0; index < currentDSDetails.Rows.Count; index++)
                {
                    DS_OutStoreDetail detail = ConvertExtend.ToObject <DS_OutStoreDetail>(currentDSDetails, index);

                    var uAmount = 0;

                    if (currentDSDetails.Rows[index]["uAmount"] != DBNull.Value)
                    {
                        uAmount = Convert.ToInt32(currentDSDetails.Rows[index]["uAmount"].ToString());
                    }

                    var pAmount = 0;
                    if (currentDSDetails.Rows[index]["pAmount"] != DBNull.Value)
                    {
                        pAmount = Convert.ToInt32(currentDSDetails.Rows[index]["pAmount"].ToString());
                    }

                    var packAmount = currentDSDetails.Rows[index]["packAmount"] == DBNull.Value
                        ? 0
                        : Convert.ToInt32(currentDSDetails.Rows[index]["packAmount"]);

                    detail.Amount = uAmount + (pAmount * packAmount);

                    detail.DeptID            = currentDSHead.DeptID;
                    detail.ToDeptID          = currentDSHead.ToDeptID;
                    currentDSHead.StockFee  += detail.StockFee;
                    currentDSHead.RetailFee += detail.RetailFee;
                    lstDetails.Add(detail);
                }

                requestAction = ((ClientRequestData request) =>
                {
                    request.AddData(DGConstant.OP_DS_SYSTEM);
                    request.AddData(currentDSHead.BusiType);
                    request.AddData(currentDSHead);
                    request.AddData <List <DS_OutStoreDetail> >(lstDetails);
                    request.AddData <List <int> >(frmOutstoreDetailDS.GetDeleteDetails());
                });
                retdata = InvokeWcfService("DrugProject.Service", "OutStoreController", "SaveBill", requestAction);

                DGBillResult result = retdata.GetData <DGBillResult>(0);
                if (result.Result == 0)
                {
                    MessageBoxShowSimple("单据已经保存成功,如果没有配置自动审核.请及时审核单据");
                    if (billStatus == DGEnum.BillEditStatus.ADD_STATUS)
                    {
                        frmOutstoreDetailDS.NewBillClear();
                    }
                    else
                    {
                        frmOutstoreDetailDS.CloseCurrentWindow();
                    }
                }
                else
                {
                    MessageBoxShowSimple("单据保存失败:" + result.ErrMsg);
                }
            }
        }