/// <summary> /// 删除单据 /// </summary> /// <param name="id">出库头id</param> public void DeleteBill(int id) { MW_OutStoreHead inHead = (MW_OutStoreHead)NewObject <MW_OutStoreHead>().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_OutStoreHead head = billHead as MW_OutStoreHead; List <MW_OutStoreDetail> inDetals = billDetails as List <MW_OutStoreDetail>; 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.OutStoreHeadID > 0) { foreach (MW_OutStoreDetail detail in inDetals) { detail.OutHeadID = head.OutStoreHeadID; detail.BillNO = head.BillNO; detail.DeptID = head.DeptID; BindDb(detail); detail.save(); } } }
/// <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_OutStoreHead head = (MW_OutStoreHead)NewObject <MW_OutStoreHead>().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_OutStoreDetail> lstDetails = NewObject <MW_OutStoreDetail>().getlist <MW_OutStoreDetail>("OutHeadID=" + headID); head.AuditEmpID = auditEmpID; head.AuditEmpName = auditEmpName; head.AuditTime = System.DateTime.Now; head.AuditFlag = 1; head.save(); foreach (MW_OutStoreDetail 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>().ReduceStore(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.MaterialID + "批次号:" + detail.BatchNO; result.LstNotEnough.Add(notEnough); result.ErrMsg = "【" + notEnough.MaterialInfo + "】库存不足"; } else { result.ErrMsg = "药品更新库存出错"; } return(result); } else { WriteAccount(head, detail, storeRtn); } } result.Result = 0; return(result); } return(result); }