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; } }
/// <summary> /// 从界面获取药库入库表头信息 /// </summary> /// <returns>药库入库表头信息</returns> public DW_InStoreHead GetInHeadInfoDW() { DW_InStoreHead inHead = new DW_InStoreHead(); frmFormInHead.GetValue <DW_InStoreHead>(inHead); inHead.SupplierName = txtSupport.Text.Trim(); return(inHead); }
/// <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="headID">药库入库单表头</param> /// <param name="auditEmpID">审核人ID</param> /// <param name="auditEmpName">审核人姓名</param> /// <returns>单据处理结果</returns> public override DGBillResult AuditBill(int headID, int auditEmpID, string auditEmpName) { DW_InStoreHead head = (DW_InStoreHead)NewObject <DW_InStoreHead>().getmodel(headID); List <DW_InStoreDetail> lstDetails = NewObject <DW_InStoreDetail>().getlist <DW_InStoreDetail>("InHeadID=" + headID); head.AuditEmpID = auditEmpID; head.AuditEmpName = auditEmpName; head.AuditTime = System.DateTime.Now; head.AuditFlag = 1; head.save(); DGBillResult result = new DGBillResult(); foreach (DW_InStoreDetail detail in lstDetails) { StoreParam storeParam = new StoreParam(); storeParam.Amount = detail.Amount; storeParam.BatchNO = detail.BatchNo; storeParam.DeptID = head.DeptID; storeParam.DrugID = detail.DrugID; storeParam.RetailPrice = detail.RetailPrice; storeParam.StockPrice = detail.StockPrice; storeParam.UnitID = detail.UnitID; storeParam.UnitName = detail.UnitName; storeParam.ValidityTime = detail.ValidityDate; storeParam.BussConstant = head.BusiType; //storeParam.PackUnit = detail.PackUnit; 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); } } result.Result = 0; return(result); }
/// <summary> /// 删除药库入库单 /// </summary> /// <param name="billID">药库入库单表头ID</param> public override void DeleteBill(int billID) { DW_InStoreHead inHead = (DW_InStoreHead)NewObject <DW_InStoreHead>().getmodel(billID); if (inHead.AuditFlag == 1) { throw new Exception("当前单据已经审核,无法删除"); } else { inHead.DelFlag = 1; inHead.save(); } }
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); }
/// <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) { DW_InStoreHead inHead = billHead as DW_InStoreHead; List <DW_InStoreDetail> inDetals = billDetails as List <DW_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 (DW_InStoreDetail detail in inDetals) { detail.InHeadID = inHead.InHeadID; detail.BillNo = inHead.BillNo; detail.DeptID = inHead.DeptID; BindDb(detail); detail.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="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) { DW_InStoreHead head = (DW_InStoreHead)NewObject <DW_InStoreHead>().getmodel(headID); List <DW_InStoreDetail> lstDetails = NewObject <DW_InStoreDetail>().getlist <DW_InStoreDetail>("InHeadID=" + headID); head.AuditEmpID = auditEmpID; head.AuditEmpName = auditEmpName; head.AuditTime = System.DateTime.Now; head.AuditFlag = 1; head.save(); DGBillResult result = new DGBillResult(); if (!NewObject <DrugDeptMgr>().IsDeptChecked(head.DeptID, workId)) { result.Result = 1; result.ErrMsg = "当前科室处于盘点状态或者没有设置科室的盘点状态 不能处理业务操作"; return(result); } foreach (DW_InStoreDetail detail in lstDetails) { //获取批次数据 DW_Batch batch = NewDao <IDWDao>().GetBatchAmount(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.Amount = detail.Amount; storeParam.BatchNO = detail.BatchNo; storeParam.DeptID = head.DeptID; storeParam.DrugID = detail.DrugID; storeParam.RetailPrice = detail.RetailPrice; storeParam.StockPrice = detail.StockPrice; storeParam.UnitID = detail.UnitID; storeParam.UnitName = detail.UnitName; storeParam.ValidityTime = detail.ValidityDate; storeParam.BussConstant = head.BusiType; //storeParam.PackUnit = detail.PackUnit; 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); } } result.Result = 0; return(result); }
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); }
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); } }