Ejemplo n.º 1
0
 public void RefreshHead(string frmName)
 {
     if (frmName == "FrmInStoreDetailDW")
     {
         DW_InStoreHead editHead = frmInstoreDetailDW.GetInHeadInfoDW();
         currentDWHead.InvoiceDate  = editHead.InvoiceDate;
         currentDWHead.BillTime     = editHead.BillTime;
         currentDWHead.InvoiceNo    = editHead.InvoiceNo;
         currentDWHead.DeliveryNo   = editHead.DeliveryNo;
         currentDWHead.SupplierID   = editHead.SupplierID;
         currentDWHead.SupplierName = editHead.SupplierName;
         currentDWHead.BusiType     = editHead.BusiType;
     }
     else
     {
         DS_InstoreHead editHead = frmInstoreDetailDS.GetInHeadInfoDS();
         currentDSHead.InvoiceDate  = editHead.InvoiceDate;
         currentDSHead.BillTime     = editHead.BillTime;
         currentDSHead.InvoiceNO    = editHead.InvoiceNO;
         currentDSHead.DeliveryNO   = editHead.DeliveryNO;
         currentDSHead.SupplierID   = editHead.SupplierID;
         currentDSHead.SupplierName = editHead.SupplierName;
         currentDSHead.BusiType     = editHead.BusiType;
     }
 }
Ejemplo n.º 2
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_InStoreDetail detail = billDetails as DS_InStoreDetail;
            DS_InstoreHead   head   = billHead as DS_InstoreHead;

            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.InDetailID;
            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.LendAmount    = detail.Amount;
                account.LendRetailFee = detail.Amount * (account.RetailPrice / packAmount);
                account.LendStockFee  = detail.Amount * (account.StockPrice / packAmount);
            }
            else
            {
                account.StockPrice    = detail.StockPrice;
                account.RetailPrice   = detail.RetailPrice;
                account.LendAmount    = detail.Amount;
                account.LendRetailFee =
                    detail.Amount * (account.RetailPrice / packAmount);
                account.LendStockFee = detail.Amount * (account.StockPrice / packAmount);
            }

            account.OverAmount    = storeResult.BatchAllot[0].StoreAmount;
            account.OverStockFee  = storeResult.BatchAllot[0].StoreAmount * (account.StockPrice / packAmount);
            account.OverRetailFee = storeResult.BatchAllot[0].StoreAmount * (account.RetailPrice / packAmount);
            account.save();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 从界面获取药房入库表头信息
        /// </summary>
        /// <returns>药房入库表头信息</returns>
        public DS_InstoreHead GetInHeadInfoDS()
        {
            DS_InstoreHead inHead = new DS_InstoreHead();

            frmFormInHead.GetValue <DS_InstoreHead>(inHead);
            inHead.SupplierName = txtSupport.Text.Trim();
            return(inHead);
        }
Ejemplo n.º 4
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.º 5
0
        /// <summary>
        /// 药库出库头转药房入库头
        /// </summary>
        /// <param name="dwhead">药库出库主实体</param>
        /// <param name="userId">操作用户ID</param>
        /// <param name="userName">操作用户名</param>
        /// <param name="bussType">业务类型</param>
        /// <returns>入库头对象</returns>
        public DS_InstoreHead ConvertInFromDWOutHead(DW_OutStoreHead dwhead, int userId, string userName, string bussType)
        {
            DS_InstoreHead dshead = new DS_InstoreHead();

            dshead.DelFlag        = 0;
            dshead.BusiType       = bussType;
            dshead.BillTime       = System.DateTime.Now;
            dshead.DeptID         = dwhead.ToDeptID;
            dshead.RegEmpID       = userId;
            dshead.RegEmpName     = userName;
            dshead.RegTime        = DateTime.Now;
            dshead.StockFee       = dwhead.StockFee;
            dshead.RetailFee      = dwhead.RetailFee;
            dshead.OutStoreHeadID = dwhead.OutStoreHeadID;
            return(dshead);
        }
Ejemplo n.º 6
0
        public ServiceResponseData GetEditBillHead()
        {
            string belongSys = requestData.GetData <string>(0);
            int    billID    = requestData.GetData <int>(1);

            if (belongSys == DGConstant.OP_DW_SYSTEM)
            {
                DW_InStoreHead head = (DW_InStoreHead)NewObject <DW_InStoreHead>().getmodel(billID);
                responseData.AddData(head);
            }
            else
            {
                DS_InstoreHead head = (DS_InstoreHead)NewObject <DS_InstoreHead>().getmodel(billID);
                responseData.AddData(head);
            }

            return(responseData);
        }
Ejemplo n.º 7
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.º 8
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);
        }
Ejemplo n.º 9
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)
        {
            DW_OutStoreHead outHead = (DW_OutStoreHead)NewObject <DW_OutStoreHead>().getmodel(headID);

            outHead.AuditEmpID   = auditEmpID;
            outHead.AuditEmpName = auditEmpName;
            outHead.AuditTime    = System.DateTime.Now;
            outHead.AuditFlag    = 1;
            outHead.save();
            List <DW_OutStoreDetail> lstDetails = NewObject <DW_OutStoreDetail>().getlist <DW_OutStoreDetail>("OutHeadID=" + headID);
            DGBillResult             result     = new DGBillResult();

            foreach (var outDeatils in lstDetails)
            {
                StoreParam storeParam = new StoreParam();
                storeParam.Amount       = outDeatils.Amount;
                storeParam.BatchNO      = outDeatils.BatchNO;
                storeParam.DeptID       = outDeatils.DeptID;
                storeParam.DrugID       = outDeatils.DrugID;
                storeParam.RetailPrice  = outDeatils.RetailPrice;
                storeParam.StockPrice   = outDeatils.StockPrice;
                storeParam.UnitID       = outDeatils.UnitID;
                storeParam.UnitName     = outDeatils.UnitName;
                storeParam.ValidityTime = outDeatils.ValidityDate;
                DGStoreResult storeRtn = iStore.ReduceStore(storeParam);
                if (storeRtn.Result != 0)
                {
                    result.Result = 1;
                    if (storeRtn.Result == 1)
                    {
                        result.LstNotEnough = new List <DGNotEnough>();
                        DGNotEnough notEnough = new DGNotEnough();
                        notEnough.DeptID     = outHead.DeptID;
                        notEnough.DrugID     = outDeatils.DrugID;
                        notEnough.LackAmount = outDeatils.Amount - storeRtn.StoreAmount;
                        notEnough.DrugInfo   = "药品批次号:" + outDeatils.BatchNO;
                        result.LstNotEnough.Add(notEnough);
                        result.ErrMsg = "【" + notEnough.DrugInfo + "】库存不足";
                    }
                    else
                    {
                        result.ErrMsg = "药品更新库存出错";
                    }

                    return(result);
                }
                else
                {
                    WriteAccount(outHead, outDeatils, storeRtn);
                }
            }

            if (outHead.BusiType == DGConstant.OP_DW_CIRCULATEOUT || outHead.BusiType == DGConstant.OP_DW_RETURNSTORE)
            {
                //流通出库业务和退库业务
                var                     t         = outHead.BusiType == DGConstant.OP_DW_CIRCULATEOUT ? DGConstant.OP_DS_CIRCULATEIN:DGConstant.OP_DS_RETURNSOTRE;
                DS_InstoreHead          dshead    = NewObject <DGBillConverter>().ConvertInFromDWOutHead(outHead, auditEmpID, auditEmpName, t);
                IDGBill                 iProcess  = NewObject <DGBillFactory>().GetBillProcess(t);
                List <DS_InStoreDetail> dsInStore = NewObject <DGBillConverter>().ConvertInFromDwStoreDetail(headID);
                iProcess.SaveBill(dshead, dsInStore);//药房入库
                Basic_SystemConfig config = NewObject <IDGDao>().GetDeptParameters(dshead.DeptID, "AutoAuditInstore");
                if (config != null)
                {
                    //药房是否需要审核
                    if (config.Value == "1")
                    {
                        result = iProcess.AuditBill(dshead.InHeadID, auditEmpID, auditEmpName);
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 10
0
        public ServiceResponseData SaveBill()
        {
            string       belongSys = requestData.GetData <string>(0);
            string       busiType  = requestData.GetData <string>(1);
            IDGBill      iProcess  = NewObject <DGBillFactory>().GetBillProcess(busiType);
            DGBillResult result    = new DGBillResult();

            if (belongSys == DGConstant.OP_DW_SYSTEM)
            {
                DW_InStoreHead          head    = requestData.GetData <DW_InStoreHead>(2);
                List <DW_InStoreDetail> details = requestData.GetData <List <DW_InStoreDetail> >(3);
                List <int> deleteDetails        = requestData.GetData <List <int> >(4);
                oleDb.BeginTransaction();
                try
                {
                    foreach (int detailID in deleteDetails)
                    {
                        NewObject <DW_InStoreDetail>().delete(detailID);
                    }

                    iProcess.SaveBill(head, details);
                    Basic_SystemConfig config = NewObject <IDGDao>().GetDeptParameters(head.DeptID, "AutoAuditInstore");
                    if (config != null)
                    {
                        //是否配置需要审核
                        if (config.Value == "1")
                        {
                            result = iProcess.AuditBill(head.InHeadID, LoginUserInfo.EmpId, LoginUserInfo.EmpName, LoginUserInfo.WorkId);
                        }
                    }

                    if (result.Result == 0)
                    {
                        oleDb.CommitTransaction();
                    }
                    else
                    {
                        oleDb.RollbackTransaction();
                    }

                    responseData.AddData(result);
                }
                catch (Exception error)
                {
                    oleDb.RollbackTransaction();
                    result.Result = 1;
                    result.ErrMsg = error.Message;
                    responseData.AddData(result);
                }
            }
            else
            {
                DS_InstoreHead          head    = requestData.GetData <DS_InstoreHead>(2);
                List <DS_InStoreDetail> details = requestData.GetData <List <DS_InStoreDetail> >(3);
                List <int> deleteDetails        = requestData.GetData <List <int> >(4);
                oleDb.BeginTransaction();
                try
                {
                    foreach (int detailID in deleteDetails)
                    {
                        NewObject <DS_InStoreDetail>().delete(detailID);
                    }

                    iProcess.SaveBill(head, details);
                    Basic_SystemConfig config = NewObject <IDGDao>().GetDeptParameters(head.DeptID, "AutoAuditInstore");
                    if (config != null)
                    {
                        //是否直接审核
                        if (config.Value == "1")
                        {
                            result = iProcess.AuditBill(head.InHeadID, LoginUserInfo.EmpId, LoginUserInfo.EmpName, LoginUserInfo.WorkId);
                        }
                    }

                    if (result.Result == 0)
                    {
                        oleDb.CommitTransaction();
                    }
                    else
                    {
                        oleDb.RollbackTransaction();
                    }

                    responseData.AddData(result);
                }
                catch (Exception error)
                {
                    oleDb.RollbackTransaction();
                    result.Result = 1;
                    result.ErrMsg = error.Message;
                    responseData.AddData(result);
                }
            }

            return(responseData);
        }
Ejemplo n.º 11
0
        public void InitBillHead(string frmName, DGEnum.BillEditStatus billEditStatus, int currentBillID)
        {
            billStatus = billEditStatus;
            if (frmName == "FrmInStoreDW")
            {
                if (billStatus == DGEnum.BillEditStatus.ADD_STATUS)
                {
                    DW_InStoreHead inHead = new DW_InStoreHead();
                    inHead.AuditFlag    = 0;
                    inHead.AuditEmpID   = 0;
                    inHead.AuditEmpName = string.Empty;
                    inHead.Remark       = string.Empty;
                    inHead.OpEmpID      = 0;
                    inHead.OpEmpName    = string.Empty;
                    inHead.DeptID       = selectedDeptID;
                    inHead.BusiType     = DGConstant.OP_DW_BUYINSTORE;
                    inHead.BillTime     = System.DateTime.Now;
                    inHead.RegEmpID     = GetUserInfo().EmpId;
                    inHead.RegEmpName   = GetUserInfo().EmpName;
                    currentDWHead       = inHead;
                    frmInstoreDetailDW.BindInHeadInfo(currentDWHead);
                }
                else
                {
                    Action <ClientRequestData> requestAction = ((ClientRequestData request) =>
                    {
                        request.AddData(DGConstant.OP_DW_SYSTEM);
                        request.AddData(currentBillID);
                    });
                    ServiceResponseData retdata     = InvokeWcfService("DrugProject.Service", "InStoreController", "GetEditBillHead", requestAction);
                    DW_InStoreHead      inStoreHead = retdata.GetData <DW_InStoreHead>(0);
                    currentDWHead = inStoreHead;
                    frmInstoreDetailDW.BindInHeadInfo(currentDWHead);
                }

                frmInstoreDetailDW.InitControStatus(billEditStatus);
            }
            else
            {
                if (billStatus == DGEnum.BillEditStatus.ADD_STATUS)
                {
                    DS_InstoreHead head = new DS_InstoreHead();
                    head.AuditFlag    = 0;
                    head.AuditEmpID   = 0;
                    head.AuditEmpName = string.Empty;
                    head.Remark       = string.Empty;
                    head.OpEmpID      = 0;
                    head.OpEmpName    = string.Empty;
                    head.DeptID       = selectedDeptID;
                    head.BusiType     = DGConstant.OP_DW_BUYINSTORE;
                    head.BillTime     = System.DateTime.Now;
                    head.RegEmpID     = GetUserInfo().EmpId;
                    head.RegEmpName   = GetUserInfo().EmpName;
                    currentDSHead     = head;
                    frmInstoreDetailDS.BindInHeadInfo(currentDSHead);
                }
                else
                {
                    Action <ClientRequestData> requestAction = ((ClientRequestData request) =>
                    {
                        request.AddData(DGConstant.OP_DS_SYSTEM);
                        request.AddData(currentBillID);
                    });
                    ServiceResponseData retdata = InvokeWcfService("DrugProject.Service", "InStoreController", "GetEditBillHead", requestAction);
                    DS_InstoreHead      inHead  = retdata.GetData <DS_InstoreHead>(0);
                    inHead.DeptID   = selectedDeptID;
                    inHead.BusiType = DGConstant.OP_DS_FIRSTIN;
                    currentDSHead   = inHead;
                    frmInstoreDetailDS.BindInHeadInfo(inHead);
                }

                frmInstoreDetailDS.InitControStatus(billEditStatus);
            }
        }
Ejemplo n.º 12
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.º 13
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);
        }