/// <summary> /// 写入调价单台账 /// </summary> /// <typeparam name="THead">调价单表头</typeparam> /// <typeparam name="TDetail">调价单明细</typeparam> /// <param name="billHead">单据头</param> /// <param name="billDetails">单据明细</param> /// <param name="storeResult">库存处理结果</param> public void WriteAccount <THead, TDetail>(THead billHead, TDetail billDetails, DGStoreResult storeResult) { DG_AdjHead adjHead = billHead as DG_AdjHead; DG_AdjDetail currentDetail = billDetails as DG_AdjDetail; currentDetail.AdjHeadID = adjHead.AdjHeadID; currentDetail.BillNO = adjHead.BillNO; #region 操作药库批次和明细表 List <DW_Batch> dwlist = NewDao <IDWDao>().GetBatchList(currentDetail.BatchNO, currentDetail.DrugID); foreach (DW_Batch dwbatch in dwlist) { SaveAccout(dwbatch, currentDetail); } #endregion #region 操作药房批次和明细表 List <DS_Batch> dslist = NewDao <IDSDao>().GetBatchList(currentDetail.BatchNO, currentDetail.DrugID); foreach (DS_Batch dsbatch in dslist) { SaveAccout(dsbatch, currentDetail); } #endregion }
public void ExcutePrice(string adjCode, string remark, DataTable detaildt) { DG_AdjHead newhead = new DG_AdjHead(); newhead.AdjCode = adjCode; newhead.Remark = remark; newhead.BillNO = 0; newhead.ExecTime = DateTime.Now; newhead.ExecFlag = 1; newhead.DelFlag = 0; newhead.AuditFlag = 1; newhead.BusiType = DGConstant.OP_DW_ADJPRICE; newhead.RegEmpID = LoginUserInfo.EmpId; newhead.RegTime = DateTime.Now; newhead.DeptID = frmAdjPriceDetail.DeptID; List <DG_AdjDetail> lstDetails = new List <DG_AdjDetail>(); for (int index = 0; index < detaildt.Rows.Count; index++) { DG_AdjDetail detail = ConvertExtend.ToObject <DG_AdjDetail>(detaildt, index); detail.UnitID = Convert.ToInt32(detaildt.Rows[index]["MiniUnitID"]); detail.UnitName = detaildt.Rows[index]["MiniUnit"].ToString(); detail.PackUnitID = Convert.ToInt32(detaildt.Rows[index]["PackUnitID"]); detail.PackUnitName = detaildt.Rows[index]["PackUnit"].ToString(); lstDetails.Add(detail); } Action <ClientRequestData> requestAction = ((ClientRequestData request) => { request.AddData(lstDetails); request.AddData(newhead); request.AddData(LoginUserInfo.WorkId); }); ServiceResponseData retdata = InvokeWcfService("DrugProject.Service", "AdjPriceController", "ExcutePrice", requestAction); frmAdjPriceDetail.ExcuteComplete(retdata.GetData <DGBillResult>(0)); }
/// <summary> /// 保存台账 /// </summary> /// <typeparam name="TBatch">批次类型</typeparam> /// <param name="batchs">批次对象</param> /// <param name="currentDetail">当前调价明细单对象</param> public void SaveAccout <TBatch>(TBatch batchs, DG_AdjDetail currentDetail) { string errMsg = string.Empty; int actYear = 0; int actMonth = 0; int actId = 0; if (batchs.GetType() == typeof(DW_Batch)) { DW_Batch batch = batchs as DW_Batch; currentDetail.AdjAmount = batch.BatchAmount; batch.RetailPrice = currentDetail.NewRetailPrice; this.BindDb(batch); int dwresult = batch.save(); if (dwresult > 0) { this.BindDb(currentDetail); int detailresult = currentDetail.save(); if (detailresult > 0) { if (!GetDWAccountTime(batch.DeptID, out errMsg, out actYear, out actMonth, out actId)) { throw new Exception(errMsg); } DW_Account newaccount = new DW_Account(); newaccount.AccountType = 0; newaccount.BalanceFlag = 0; newaccount.BalanceID = actId; newaccount.BalanceMonth = actMonth; newaccount.BalanceYear = actYear; newaccount.BatchNO = batch.BatchNO; newaccount.BillNO = currentDetail.BillNO; newaccount.BusiType = DGConstant.OP_DW_ADJPRICE; newaccount.CTypeID = NewDao <IDWDao>().GetTypeId(batch.BatchNO, batch.DrugID); newaccount.LendRetailFee = currentDetail.NewRetailPrice > currentDetail.OldRetailPrice ? (currentDetail.NewRetailPrice - currentDetail.OldRetailPrice) * currentDetail.AdjAmount : 0; newaccount.DebitRetailFee = currentDetail.NewRetailPrice < currentDetail.OldRetailPrice ? (currentDetail.OldRetailPrice - currentDetail.NewRetailPrice) * currentDetail.AdjAmount : 0; newaccount.OverRetailFee = currentDetail.NewRetailPrice * currentDetail.AdjAmount; newaccount.DebitAmount = 0; newaccount.LendAmount = 0; newaccount.OverAmount = currentDetail.AdjAmount; newaccount.OverStockFee = batch.StockPrice * currentDetail.AdjAmount; newaccount.DebitStockFee = 0; newaccount.LendStockFee = 0; newaccount.DeptID = batch.DeptID; newaccount.DetailID = detailresult; newaccount.DrugID = batch.DrugID; newaccount.UnitName = currentDetail.PackUnitName; newaccount.UnitID = currentDetail.UnitID; newaccount.StockPrice = batch.StockPrice; newaccount.RegTime = DateTime.Now; newaccount.RetailPrice = currentDetail.NewRetailPrice; this.BindDb(newaccount); newaccount.save(); } } } else { DS_Batch batch = batchs as DS_Batch; currentDetail.AdjAmount = batch.BatchAmount; batch.RetailPrice = currentDetail.NewRetailPrice; this.BindDb(batch); int dsresult = batch.save(); if (dsresult > 0) { this.BindDb(currentDetail); int detailresult = currentDetail.save(); if (detailresult > 0) { if (!GetDSAccountTime(batch.DeptID, out errMsg, out actYear, out actMonth, out actId)) { throw new Exception(errMsg); } DS_Account newaccount = new DS_Account(); newaccount.AccountType = 0; newaccount.BalanceFlag = 0; newaccount.BalanceID = actId; newaccount.BalanceMonth = actMonth; newaccount.BalanceYear = actYear; newaccount.BatchNO = batch.BatchNO; newaccount.BillNO = currentDetail.BillNO; newaccount.BusiType = DGConstant.OP_DS_ADJPRICE; newaccount.CTypeID = NewDao <IDSDao>().GetTypeId(batch.BatchNO, batch.DrugID); newaccount.LendRetailFee = (currentDetail.NewRetailPrice > currentDetail.OldRetailPrice) ? ((currentDetail.NewRetailPrice - currentDetail.OldRetailPrice) * (currentDetail.AdjAmount / batch.UnitAmount)) : 0; newaccount.DebitRetailFee = (currentDetail.NewRetailPrice < currentDetail.OldRetailPrice) ? ((currentDetail.OldRetailPrice - currentDetail.NewRetailPrice) * (currentDetail.AdjAmount / batch.UnitAmount)) : 0; newaccount.OverRetailFee = (currentDetail.NewRetailPrice * (currentDetail.AdjAmount / batch.UnitAmount)); newaccount.DebitAmount = 0; newaccount.LendAmount = 0; newaccount.OverAmount = currentDetail.AdjAmount; newaccount.OverStockFee = (batch.StockPrice * (currentDetail.AdjAmount / batch.UnitAmount)); newaccount.DebitStockFee = 0; newaccount.LendStockFee = 0; newaccount.DeptID = batch.DeptID; newaccount.DetailID = detailresult; newaccount.DrugID = batch.DrugID; newaccount.UnitName = currentDetail.UnitName; newaccount.UnitID = currentDetail.UnitID; newaccount.StockPrice = batch.StockPrice; newaccount.RegTime = DateTime.Now; newaccount.RetailPrice = currentDetail.NewRetailPrice; this.BindDb(newaccount); newaccount.save(); } } } }
/// <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 "111": //采购入库 case "112": //期初入库 case "113": //药库退货 DW_InStoreDetail inStoreDetail = (DW_InStoreDetail)NewObject <DW_InStoreDetail>().getmodel(detailID); if (inStoreDetail != null) { DW_InStoreHead instoreHead = (DW_InStoreHead)NewObject <DW_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 "121": //流通出库 case "122": //内耗出库 case "123": //药库报损 case "124": //药库退库 DW_OutStoreDetail outStoreDetail = (DW_OutStoreDetail)NewObject <DW_OutStoreDetail>().getmodel(detailID); if (outStoreDetail != null) { DW_OutStoreHead outStoreHead = (DW_OutStoreHead)NewObject <DW_OutStoreHead>().getmodel(outStoreDetail.OutHeadID); if (outStoreHead != 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 "142": //盘点审核 DW_AuditDetail auditDetail = (DW_AuditDetail)NewObject <DW_AuditDetail>().getmodel(detailID); if (auditDetail != null) { DW_AuditHead auditHead = (DW_AuditHead)NewObject <DW_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 "151": //药库调价 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); }
/// <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); }