public ActionResult RejectInvoice(AddInvoiceViewModel viewModel) { string errorMessage = ""; prepcode = this.PrepCode; // Format reason string. string reason = DateTime.Now.ToString() + " " + prepcode; reason += " - " + viewModel.REJECTOPTION + " / " + viewModel.REJECTDESCRIPTION; // Mark invoice as rejected. if (!RejectPegasysInvoice(viewModel)) { errorMessage = "Reject invoice failed. "; } // Write transhist entry. string memo = "Image Rejected from data entry - " + reason; var mgrTH = new TransHistManager(); TRANSHIST th = CreateTransHistForChange(viewModel, memo, DataEntry.ImgReject); mgrTH.InsertTransHist(th); // Update imagelist. var mgrIL = new ImageListManager(); IMAGELIST il = mgrIL.GetImageListByImageId(viewModel.IMAGEID); if (il != null) { // Mark as rejected and update. mgrIL.RejectImageList(viewModel.IMAGEID, prepcode, reason); } else { var mgrILH = new ImageListHistManager(); IMAGELISTHIST ilh = mgrILH.GetImageListHistByImageId(viewModel.IMAGEID); if (ilh != null) { // Convert to ImageList and mark as rejected. il = mgrIL.MapToImageList(ilh); MarkImageListAsRejected(il, reason); // Add to ImageList. mgrIL.InsertImageList(il); // Remove from ImageListHist. mgrILH.DeleteImageListHist(ilh); } else { // Uh oh. No imagelisthist entry. errorMessage += viewModel.IMAGEID + " does not exist in the ImageListHist table."; } } // Reload the index page to move to the next invoice, if available. TempData["ErrorMessage"] = errorMessage; return(RedirectToAction("Index", new { InvoiceType = viewModel.INVOICETYPE })); }
public ActionResult AddInvoice(AddInvoiceViewModel viewModel) { prepcode = this.PrepCode; // Key this invoice. if (!KeyPegasysInvoice(viewModel)) { TempData["ErrorMessage"] = "Update failed for invoice " + viewModel.INV_KEY_ID; } // Write transhist entries. string memo = ""; string allProcess = ""; switch (viewModel.INVOICETYPE) { case DataEntry.TypeTops: memo = DataEntry.TopsMemo; allProcess = DataEntry.TopsAllProcess; break; case DataEntry.TypeNonTops: memo = (viewModel.GENE043S ? DataEntry.NonTopsMemoError : DataEntry.NonTopsMemo); allProcess = DataEntry.NonTopsAllProcess; break; case DataEntry.TypeConst: memo = (viewModel.GENE043S ? DataEntry.ConstMemoError : DataEntry.ConstMemo); allProcess = DataEntry.ConstAllProcess; break; case DataEntry.TypeNonConst: memo = DataEntry.NonConstMemo; allProcess = DataEntry.NonConstAllProcess; break; default: // Shouldn't get here. break; } var mgrTH = new TransHistManager(); TRANSHIST th = CreateTransHistForChange(viewModel, memo, allProcess); mgrTH.InsertTransHist(th); var mgrITH = new ImageTransHistManager(); IMAGETRANSHIST ith = CreateImageTransHistForChange(viewModel, memo); mgrITH.InsertImageTransHist(ith); // Reload the index page to move to the next invoice, if available. return(RedirectToAction("Index", new { InvoiceType = viewModel.INVOICETYPE })); }
public bool Initialize(EXCEPTION exc, string prepCode, string strACT) { SetVariables(exc, prepCode, "CHANGEACT"); var AskVal = "EMPTY"; //Used thisform.r_act before if (!String.IsNullOrWhiteSpace(exception.ACT)) { AskVal = exception.ACT; } //Update Exceptions Table. var fieldsToUpdate = new List <string> { "ACT" }; exception.ACT = strACT; UpdateException(exception, fieldsToUpdate); //Update the related Pegasys frm table and transhist if (exception.ERR_CODE == "P200") { TransHistManager transHistManager = new TransHistManager(); transHistManager.UpdateActByInvKeyId(exception.INV_KEY_ID, strACT); var rtnInv = GetPegasysInvoiceByKey(exception.INV_KEY_ID); if (rtnInv != null) { fieldsToUpdate = new List <string> { "ACT" }; rtnInv.ACT = strACT; UpdatePegasysInvoice(rtnInv, fieldsToUpdate); } } else if (exception.ERR_CODE == "A200") { TransHistManager transHistManager = new TransHistManager(); transHistManager.UpdateActByRRId(exception.RR_ID, strACT); var rtnRR = GetPegasysRRByKey(exception.RR_ID); if (rtnRR != null) { fieldsToUpdate = new List <string> { "ACT" }; rtnRR.ACT = strACT; UpdatePegasysRR(rtnRR, fieldsToUpdate); } } else if (exception.ERR_CODE == "M200") { TransHistManager transHistManager = new TransHistManager(); transHistManager.UpdateActByAeId(exception.AE_ID, strACT); var rtnAE = GetPegasysAEByKey(exception.AE_ID); if (rtnAE != null) { fieldsToUpdate = new List <string> { "ACT" }; rtnAE.ACT = strACT; UpdatePegasysAE(rtnAE, fieldsToUpdate); } } //Insert a Transhist Record recording the change to Act number //Used thisform.r_act before var strCuffMemo = string.Format("ACT Number Changed from {0} to {1}.", exception.ACT, strACT); InsertTranshist(exception, "", strCuffMemo, "", prepCode); //Does not close out of the screen and enables the button //By returning true it should enable the button on the screen return(true); //THISFORM.cmdPoRequest1.ENABLED = true; }