public ResultModel Complete(UserModel user, int sIId) { ResultModel result = new ResultModel(); try { DAL.SIDAL sIDAL = new SIDAL(); NFMT.Operate.DAL.InvoiceDAL invoiceDAL = new Operate.DAL.InvoiceDAL(); DAL.SIDetailDAL detailDAL = new SIDetailDAL(); using (System.Transactions.TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //获取财务票 result = sIDAL.Get(user, sIId); if (result.ResultStatus != 0) return result; NFMT.Invoice.Model.SI sI = result.ReturnValue as NFMT.Invoice.Model.SI; if (sI == null || sI.SIId <= 0) { result.ResultStatus = -1; result.Message = "发票验证失败"; return result; } //获取发票 result = invoiceDAL.Get(user, sI.InvoiceId); if (result.ResultStatus != 0) return result; NFMT.Operate.Model.Invoice invoice = result.ReturnValue as NFMT.Operate.Model.Invoice; if (invoice == null || invoice.InvoiceId <= 0) { result.ResultStatus = -1; result.Message = "发票获取失败"; return result; } //发票完成 result = invoiceDAL.Complete(user, invoice); if (result.ResultStatus != 0) return result; //获取明细 result = detailDAL.Load(user, sI.SIId); if (result.ResultStatus != 0) return result; List<Model.SIDetail> details = result.ReturnValue as List<Model.SIDetail>; if (details == null) { result.ResultStatus = -1; result.Message = "发票明细获取失败"; return result; } foreach (Model.SIDetail detail in details) { result = detailDAL.Complete(user, detail); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }
public ResultModel Update(UserModel user, NFMT.Operate.Model.Invoice invoice, Model.SI si, List<Model.SIDetail> siDetails) { ResultModel result = new ResultModel(); NFMT.Operate.DAL.InvoiceDAL invoiceDAL = new Operate.DAL.InvoiceDAL(); DAL.SIDAL sIDAL = new SIDAL(); DAL.SIDetailDAL sIDetailDAL = new SIDetailDAL(); NFMT.User.DAL.CorporationDAL corporationDAL = new User.DAL.CorporationDAL(); try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //获取发票信息 result = invoiceDAL.Get(user, invoice.InvoiceId); if (result.ResultStatus != 0) return result; NFMT.Operate.Model.Invoice resultObj = result.ReturnValue as NFMT.Operate.Model.Invoice; if (resultObj == null || resultObj.InvoiceId <= 0) { result.Message = "获取发票信息失败"; result.ResultStatus = -1; return result; } //获取公司信息 result = corporationDAL.Get(user, invoice.InCorpId); if (result.ResultStatus != 0) return result; NFMT.User.Model.Corporation corp = result.ReturnValue as NFMT.User.Model.Corporation; if (corp == null) { result.ResultStatus = -1; result.Message = "公司信息不存在"; return result; } resultObj.InCorpName = corp.CorpName; result = corporationDAL.Get(user, invoice.OutCorpId); if (result.ResultStatus != 0) return result; corp = result.ReturnValue as NFMT.User.Model.Corporation; if (corp == null) { result.ResultStatus = -1; result.Message = "公司信息不存在"; return result; } resultObj.OutCorpName = corp.CorpName; resultObj.InvoiceDate = invoice.InvoiceDate; resultObj.InvoiceName = invoice.InvoiceName; resultObj.InvoiceType = invoice.InvoiceType; resultObj.InvoiceBala = invoice.InvoiceBala; resultObj.CurrencyId = invoice.CurrencyId; resultObj.InvoiceDirection = invoice.InvoiceDirection; resultObj.OutCorpId = invoice.OutCorpId; resultObj.InCorpId = invoice.InCorpId; resultObj.Memo = invoice.Memo; //更新发票信息 result = invoiceDAL.Update(user, resultObj); if (result.ResultStatus != 0) return result; //更新价外票信息 result = sIDAL.Update(user, si); if (result.ResultStatus != 0) return result; //作废价外票 result = sIDetailDAL.InvalidAll(user, si.SIId); if (result.ResultStatus != 0) return result; foreach (Model.SIDetail detail in siDetails) { detail.SIId = si.SIId; result = sIDetailDAL.Insert(user, detail); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception e) { result.ResultStatus = -1; result.Message = e.Message; } return result; }
public ResultModel CreateSIApply(UserModel user, NFMT.Operate.Model.Apply apply, List<Model.InvoiceApplySIDetail> details, bool isSubmitAudit) { ResultModel result = new ResultModel(); try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { NFMT.Operate.DAL.ApplyDAL applyDAL = new NFMT.Operate.DAL.ApplyDAL(); result = applyDAL.Insert(user, apply); if (result.ResultStatus != 0) return result; int applyId = (int)result.ReturnValue; decimal totalBala = 0; NFMT.Operate.DAL.InvoiceDAL invoiceDAL = new Operate.DAL.InvoiceDAL(); foreach (Model.InvoiceApplySIDetail detail in details) { result = invoiceDAL.Get(user, detail.InvoiceId); if (result.ResultStatus != 0) return result; NFMT.Operate.Model.Invoice invoice = result.ReturnValue as NFMT.Operate.Model.Invoice; totalBala += invoice.InvoiceBala; } result = invoiceapplyDAL.Insert(user, new Model.InvoiceApply() { ApplyId = applyId, TotalBala = totalBala }); if (result.ResultStatus != 0) return result; int invoiceApplyId = (int)result.ReturnValue; DAL.InvoiceApplySIDetailDAL invoiceApplySIDetailDAL = new InvoiceApplySIDetailDAL(); foreach (Model.InvoiceApplySIDetail detail in details) { detail.InvoiceApplyId = invoiceApplyId; detail.ApplyId = applyId; result = invoiceApplySIDetailDAL.Insert(user, detail); if (result.ResultStatus != 0) return result; } if (isSubmitAudit) { apply.ApplyId = applyId; NFMT.WorkFlow.AutoSubmit submit = new WorkFlow.AutoSubmit(); NFMT.WorkFlow.ITaskProvider taskProvider = new NFMT.Invoice.TaskProvider.InvoiceApplyTaskProvider(); result = submit.Submit(user, apply, taskProvider, WorkFlow.MasterEnum.发票申请审核); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } finally { if (result.ResultStatus != 0) this.Log.ErrorFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue); else if (this.Log.IsInfoEnabled) this.Log.InfoFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue); } return result; }
public ResultModel Goback(UserModel user, int sIId) { ResultModel result = new ResultModel(); try { DAL.SIDAL sIDAL = new SIDAL(); NFMT.Operate.DAL.InvoiceDAL invoiceDAL = new Operate.DAL.InvoiceDAL(); using (System.Transactions.TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //获取价外票 result = sIDAL.Get(user, sIId); if (result.ResultStatus != 0) return result; NFMT.Invoice.Model.SI sI = result.ReturnValue as NFMT.Invoice.Model.SI; if (sI == null || sI.SIId <= 0) { result.ResultStatus = -1; result.Message = "发票验证失败"; return result; } //获取发票 result = invoiceDAL.Get(user, sI.InvoiceId); if (result.ResultStatus != 0) return result; NFMT.Operate.Model.Invoice invoice = result.ReturnValue as NFMT.Operate.Model.Invoice; if (invoice == null || invoice.InvoiceId <= 0) { result.ResultStatus = -1; result.Message = "发票获取失败"; return result; } //撤返发票 result = invoiceDAL.Goback(user, invoice); if (result.ResultStatus != 0) return result; //工作流任务关闭 WorkFlow.DAL.DataSourceDAL sourceDAL = new WorkFlow.DAL.DataSourceDAL(); result = sourceDAL.SynchronousStatus(user, invoice); if (result.ResultStatus != 0) return result; scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }
public ResultModel UpdateSIApply(UserModel user, NFMT.Operate.Model.Apply apply, Model.InvoiceApply invoiceApply, List<Model.InvoiceApplySIDetail> details) { ResultModel result = new ResultModel(); try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { NFMT.Operate.DAL.ApplyDAL applyDAL = new NFMT.Operate.DAL.ApplyDAL(); result = applyDAL.Get(user, apply.ApplyId); if (result.ResultStatus != 0) return result; NFMT.Operate.Model.Apply applyRes = result.ReturnValue as NFMT.Operate.Model.Apply; if (applyRes == null) { result.ResultStatus = -1; result.Message = "获取申请信息失败"; return result; } applyRes.ApplyCorp = apply.ApplyCorp; applyRes.ApplyDept = apply.ApplyDept; applyRes.EmpId = user.EmpId; applyRes.ApplyTime = DateTime.Now; applyRes.ApplyDesc = apply.ApplyDesc; result = applyDAL.Update(user, applyRes); if (result.ResultStatus != 0) return result; decimal totalBala = 0; NFMT.Operate.DAL.InvoiceDAL invoiceDAL = new Operate.DAL.InvoiceDAL(); foreach (Model.InvoiceApplySIDetail detail in details) { result = invoiceDAL.Get(user, detail.InvoiceId); if (result.ResultStatus != 0) return result; NFMT.Operate.Model.Invoice invoice = result.ReturnValue as NFMT.Operate.Model.Invoice; totalBala += invoice.InvoiceBala; } invoiceApply.TotalBala = totalBala; result = invoiceapplyDAL.Update(user, invoiceApply); if (result.ResultStatus != 0) return result; DAL.InvoiceApplySIDetailDAL invoiceApplySIDetailDAL = new InvoiceApplySIDetailDAL(); result = invoiceApplySIDetailDAL.InvalidAll(user, invoiceApply.InvoiceApplyId); if (result.ResultStatus != 0) return result; foreach (Model.InvoiceApplySIDetail detail in details) { detail.InvoiceApplyId = invoiceApply.InvoiceApplyId; detail.ApplyId = apply.ApplyId; result = invoiceApplySIDetailDAL.Insert(user, detail); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } finally { if (result.ResultStatus != 0) this.Log.ErrorFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue); else if (this.Log.IsInfoEnabled) this.Log.InfoFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue); } return result; }