/// <summary> /// 获取入库单 /// </summary> /// <returns>入库单</returns> public MW_InStoreHead GetInHeadInfo() { MW_InStoreHead inHead = new MW_InStoreHead(); frmFormInHead.GetValue <MW_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 void WriteAccount <THead, TDetail>(THead billHead, TDetail billDetails, MWStoreResult storeResult) { MW_InStoreDetail detail = billDetails as MW_InStoreDetail; MW_InStoreHead head = billHead as MW_InStoreHead; int actYear; int actMonth; string errMsg; if (!GetAccountTime(head.DeptID, out errMsg, out actYear, out actMonth)) { throw new Exception(errMsg); } MW_Account account = NewObject <MW_Account>(); account.BalanceYear = actYear; account.BalanceMonth = actMonth; account.AccountType = 0; account.BalanceFlag = 0; account.BatchNO = detail.BatchNo; account.BusiType = head.BusiType; account.DeptID = head.DeptID; account.DetailID = detail.InDetailID; account.MaterialID = detail.MaterialID; account.UnitID = detail.UnitID; account.UnitName = detail.UnitName; account.LendAmount = detail.Amount; account.BillNO = detail.BillNo; account.RegTime = DateTime.Now; if (head.BusiType == MWConstant.OP_MW_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(); }
public ServiceResponseData GetEditBillHead() { string belongSys = requestData.GetData <string>(0); int billID = requestData.GetData <int>(1); MW_InStoreHead head = (MW_InStoreHead)NewObject <MW_InStoreHead>().getmodel(billID); responseData.AddData(head); return(responseData); }
public void RefreshHead(string frmName) { MW_InStoreHead editHead = ifrmInstoreDetail.GetInHeadInfo(); currentHead.InvoiceTime = editHead.InvoiceTime; currentHead.BillTime = editHead.BillTime; currentHead.InvoiceNo = editHead.InvoiceNo; currentHead.DeliveryNo = editHead.DeliveryNo; currentHead.SupplierID = editHead.SupplierID; currentHead.SupplierName = editHead.SupplierName; currentHead.BusiType = editHead.BusiType; }
public ServiceResponseData SaveBill() { string belongSys = requestData.GetData <string>(0); string busiType = requestData.GetData <string>(1); IMwBill iProcess = NewObject <MwBillFactory>().GetBillProcess(busiType); MWBillResult result = new MWBillResult(); MW_InStoreHead head = requestData.GetData <MW_InStoreHead>(2); List <MW_InStoreDetail> details = requestData.GetData <List <MW_InStoreDetail> >(3); List <int> deleteDetails = requestData.GetData <List <int> >(4); oleDb.BeginTransaction(); try { foreach (int detailID in deleteDetails) { NewObject <MW_InStoreDetail>().delete(detailID); } iProcess.SaveBill(head, details); Basic_SystemConfig config = NewObject <IMWDao>().GetDeptParameters(head.DeptID, "AutoAuditInstore"); if (config != null) { if (config.Value == "1") { result = iProcess.AuditBill(head.InHeadID, LoginUserInfo.EmpId, LoginUserInfo.EmpName); } } 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); }
/// <summary> /// 删除单据 /// </summary> /// <param name="id">主键ID</param> public void DeleteBill(int id) { MW_InStoreHead inHead = (MW_InStoreHead)NewObject <MW_InStoreHead>().getmodel(id); if (inHead.AuditFlag == 1) { throw new Exception("当前单据已经审核,无法删除"); } else { inHead.DelFlag = 1; inHead.save(); } }
/// <summary> /// 保存入库单 /// </summary> /// <typeparam name="THead">头实体</typeparam> /// <typeparam name="TDetail">明细实体列表</typeparam> /// <param name="billHead">单据头</param> /// <param name="billDetails">单据明细</param> public void SaveBill <THead, TDetail>(THead billHead, List <TDetail> billDetails) { MW_InStoreHead head = billHead as MW_InStoreHead; List <MW_InStoreDetail> inDetals = billDetails as List <MW_InStoreDetail>; head.RegTime = System.DateTime.Now; string serialNO = NewObject <SerialNumberSource>().GetSerialNumber(SnType.物资, head.DeptID, head.BusiType); head.BillNo = Convert.ToInt64(serialNO); BindDb(head); head.save(); if (head.InHeadID > 0) { foreach (MW_InStoreDetail detail in inDetals) { detail.InHeadID = head.InHeadID; detail.BillNo = head.BillNo; detail.DeptID = head.DeptID; BindDb(detail); detail.save(); } } }
public void InitBillHead(string frmName, MWEnum.BillEditStatus billEditStatus, int currentBillID) { billStatus = billEditStatus; if (billStatus == MWEnum.BillEditStatus.ADD_STATUS) { MW_InStoreHead inHead = new MW_InStoreHead(); inHead.AuditFlag = 0; inHead.AuditEmpID = 0; inHead.AuditEmpName = string.Empty; inHead.Remark = string.Empty; inHead.OpEmpID = LoginUserInfo.EmpId; inHead.DeptID = selectedDeptID; inHead.BusiType = DGConstant.OP_DW_BUYINSTORE; inHead.BillTime = System.DateTime.Now; inHead.RegEmpID = GetUserInfo().EmpId; inHead.RegEmpName = GetUserInfo().EmpName; currentHead = inHead; ifrmInstoreDetail.BindInHeadInfo(currentHead); } else { Action <ClientRequestData> requestAction = ((ClientRequestData request) => { request.AddData(MWConstant.OP_MW_INSTORE); request.AddData(currentBillID); }); ServiceResponseData retdata = InvokeWcfService("DrugProject.Service", "MaterialInStoreController", "GetEditBillHead", requestAction); MW_InStoreHead inStoreHead = retdata.GetData <MW_InStoreHead>(0); currentHead.DeptID = selectedDeptID; currentHead = inStoreHead; ifrmInstoreDetail.BindInHeadInfo(currentHead); } ifrmInstoreDetail.InitControStatus(billEditStatus); }
/// <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 "211": //采购入库 case "212": //期初入库 case "213": //物资库退货 MW_InStoreDetail inStoreDetail = (MW_InStoreDetail)NewObject <MW_InStoreDetail>().getmodel(detailID); if (inStoreDetail != null) { MW_InStoreHead instoreHead = (MW_InStoreHead)NewObject <MW_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 = GetEmpName(instoreHead.OpEmpID); 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 "221": //流通出库 case "222": //内耗出库 case "223": //物资库报损 case "224": //物资库退库 MW_OutStoreDetail outStoreDetail = (MW_OutStoreDetail)NewObject <MW_OutStoreDetail>().getmodel(detailID); if (outStoreDetail != null) { MW_OutStoreHead outStoreHead = (MW_OutStoreHead)NewObject <MW_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 "242": //盘点审核 MW_AuditDetail auditDetail = (MW_AuditDetail)NewObject <MW_AuditDetail>().getmodel(detailID); if (auditDetail != null) { MW_AuditHead auditHead = (MW_AuditHead)NewObject <MW_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 "251": //物资库调价 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> /// <returns>审核返回结果</returns> public MWBillResult AuditBill(int headID, int auditEmpID, string auditEmpName) { MW_InStoreHead head = (MW_InStoreHead)NewObject <MW_InStoreHead>().getmodel(headID); MWBillResult result = new MWBillResult(); if (!NewObject <MaterialDeptMgr>().IsDeptChecked(head.DeptID)) { result.Result = 1; result.ErrMsg = "当前科室处于盘点状态或者没有设置科室的盘点状态 不能处理业务操作"; return(result); } if (head.AuditFlag == 1) { result.Result = 1; result.ErrMsg = "物资已经被审核,请刷新数据"; return(result); } if (head != null) { List <MW_InStoreDetail> lstDetails = NewObject <MW_InStoreDetail>().getlist <MW_InStoreDetail>("InHeadID=" + headID); head.AuditEmpID = auditEmpID; head.AuditEmpName = auditEmpName; head.AuditTime = System.DateTime.Now; head.AuditFlag = 1; head.save(); foreach (MW_InStoreDetail detail in lstDetails) { StoreParam storeParam = new StoreParam(); storeParam.BatchNO = detail.BatchNo; storeParam.DeptID = head.DeptID; storeParam.MaterialId = detail.MaterialID; storeParam.RetailPrice = detail.RetailPrice; storeParam.StockPrice = detail.StockPrice; storeParam.UnitID = detail.UnitID; storeParam.UnitName = detail.UnitName; storeParam.ValidityTime = detail.ValidityDate; storeParam.UnitAmount = 1; storeParam.Amount = detail.Amount; storeParam.PackAmount = 1; storeParam.BussConstant = head.BusiType; MWStoreResult storeRtn = NewObject <MwStore>().AddStore(storeParam); if (storeRtn.Result != 0) { result.Result = 1; if (storeRtn.Result == 1) { result.LstNotEnough = new List <MWNotEnoughInfo>(); MWNotEnoughInfo notEnough = new MWNotEnoughInfo(); notEnough.DeptID = head.DeptID; notEnough.MaterialId = detail.MaterialID; notEnough.LackAmount = storeRtn.StoreAmount + detail.Amount; notEnough.MaterialInfo = "药品批次号:" + detail.BillNo; result.LstNotEnough.Add(notEnough); result.ErrMsg = "【" + notEnough.MaterialId + "】库存不足"; } else { result.ErrMsg = "药品更新库存出错"; } return(result); } else { WriteAccount(head, detail, storeRtn); } } result.Result = 0; return(result); } return(result); }