/// <summary> /// 台账写入 /// </summary> /// <typeparam name="THead">药库入库单表头模板</typeparam> /// <typeparam name="TDetail">药库入库单明细模板</typeparam> /// <param name="billHead">药库入库单表头</param> /// <param name="billDetails">药库入库单明细</param> /// <param name="storeResult">库存处理结果</param> public override void WriteAccount <THead, TDetail>(THead billHead, TDetail billDetails, DGStoreResult storeResult) { DW_InStoreDetail detail = billDetails as DW_InStoreDetail; DW_InStoreHead head = billHead as DW_InStoreHead; int actYear; int actMonth; string errMsg; if (!GetAccountTime(head.DeptID, out errMsg, out actYear, out actMonth)) { throw new Exception(errMsg); } DW_Account account = NewObject <DW_Account>(); account.BalanceYear = actYear; account.BalanceMonth = actMonth; account.AccountType = 0; account.BalanceFlag = 0; 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.LendAmount = detail.Amount; account.BillNO = detail.BillNo; account.RegTime = DateTime.Now; if (head.BusiType == DGConstant.OP_DW_BACKSTORE) { account.StockPrice = storeResult.BatchAllot[0].StockPrice; account.RetailPrice = storeResult.BatchAllot[0].RetailPrice; account.LendAmount = detail.Amount; account.LendRetailFee = account.LendAmount * account.RetailPrice; account.LendStockFee = account.LendAmount * account.StockPrice; account.OverAmount = storeResult.BatchAllot[0].StoreAmount; account.OverRetailFee = storeResult.BatchAllot[0].StoreAmount * account.RetailPrice; account.OverStockFee = storeResult.BatchAllot[0].StoreAmount * account.StockPrice; } else { account.StockPrice = detail.StockPrice; account.RetailPrice = detail.RetailPrice; account.LendAmount = detail.Amount; account.LendRetailFee = detail.RetailFee; account.LendStockFee = detail.StockFee; account.OverAmount = storeResult.BatchAllot[0].StoreAmount; account.OverRetailFee = storeResult.BatchAllot[0].StoreAmount * account.RetailPrice; account.OverStockFee = storeResult.BatchAllot[0].StoreAmount * account.StockPrice; } account.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); }
public void SaveBill(string frmName) { Action <ClientRequestData> requestAction = null; ServiceResponseData retdata = null; RefreshHead(frmName); if (frmName == "FrmInStoreDetailDW") { currentDWHead.StockFee = 0; currentDWHead.RetailFee = 0; List <DW_InStoreDetail> lstDetails = new List <DW_InStoreDetail>(); for (int index = 0; index < currentDWDetails.Rows.Count; index++) { DW_InStoreDetail detail = ConvertExtend.ToObject <DW_InStoreDetail>(currentDWDetails, index); decimal pAmount = 0; if (currentDWDetails.Rows[index]["pAmount"] != DBNull.Value) { pAmount = Convert.ToDecimal(currentDWDetails.Rows[index]["pAmount"].ToString()); } detail.Amount = pAmount; 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_InStoreDetail> >(lstDetails); request.AddData <List <int> >(frmInstoreDetailDW.GetDeleteDetails()); }); retdata = InvokeWcfService("DrugProject.Service", "InStoreController", "SaveBill", requestAction); DGBillResult result = retdata.GetData <DGBillResult>(0); if (result.Result == 0) { MessageBoxShowSimple("单据已经保存成功,如果没有配置自动审核.请及时审核单据"); if (billStatus == DGEnum.BillEditStatus.ADD_STATUS) { frmInstoreDetailDW.NewBillClear(); } else { frmInstoreDetailDW.CloseCurrentWindow(); } } else { string rtnMsg = result.ErrMsg; MessageBoxShowSimple("单据保存失败:" + result.ErrMsg); } } else { currentDSHead.StockFee = 0; currentDSHead.RetailFee = 0; List <DS_InStoreDetail> lstDetails = new List <DS_InStoreDetail>(); for (int index = 0; index < currentDSDetails.Rows.Count; index++) { DS_InStoreDetail detail = ConvertExtend.ToObject <DS_InStoreDetail>(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); 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_InStoreDetail> >(lstDetails); request.AddData <List <int> >(frmInstoreDetailDS.GetDeleteDetails()); }); retdata = InvokeWcfService("DrugProject.Service", "InStoreController", "SaveBill", requestAction); DGBillResult result = retdata.GetData <DGBillResult>(0); if (result.Result == 0) { MessageBoxShowSimple("单据已经保存成功,如果没有配置自动审核.请及时审核单据"); if (billStatus == DGEnum.BillEditStatus.ADD_STATUS) { frmInstoreDetailDS.NewBillClear(); } else { frmInstoreDetailDS.CloseCurrentWindow(); } } else { string rtnMsg = result.ErrMsg; MessageBoxShowSimple("单据保存失败:" + result.ErrMsg); } //bool result = retdata.GetData<bool>(0); //if (result) //{ // MessageBoxShowSimple("单据保存入库,请及时审核..."); // if (billStatus == DGEnum.BillEditStatus.ADD_STATUS) // frmInstoreDetailDS.NewBillClear(); // else // frmInstoreDetailDS.CloseCurrentWindow(); //} //else //{ // string rtnMsg = retdata.GetData<string>(1); // MessageBoxShowSimple("单据保存失败:" + rtnMsg); //} } }