/// <summary> /// Deletes the A receive doc entry. /// </summary> /// <param name="receiveDocID">The receive doc ID.</param> /// <param name="userID">The user ID.</param> /// <exception cref="System.Exception"></exception> public static void DeleteAReceiveDocEntry(int receiveDocID, int userID) { var rd = new ReceiveDoc(); rd.LoadByPrimaryKey(receiveDocID); if (rd.RowCount > 0) { if (rd.HasTransactions()) { string printedIDs = ""; var issueDoc = new IssueDoc(); issueDoc.LoadByReceiveDocID(rd.ID); issueDoc.Rewind(); while (!issueDoc.EOF) { var stvs = new BLL.Issue(); stvs.LoadByPrimaryKey(issueDoc.STVID); printedIDs += stvs.IDPrinted.ToString(CultureInfo.InvariantCulture) + " ,"; issueDoc.MoveNext(); } printedIDs = printedIDs.Remove(printedIDs.Length - 1, 1); throw new Exception( string.Format("Please cancel/void the following Stvs: With PrintedIDs : {0}", printedIDs)); } HandleReceiveDocDeleting(receiveDocID, userID, rd); } }
public static void Log(BLL.Issue issue, BLL.Receipt receipt, decimal conversionfactor) { var errorCorrection = new ErrorCorrection(); errorCorrection.AddNew(); errorCorrection.UserID = CurrentContext.LoggedInUser.ID; errorCorrection.IssueID = issue.ID; errorCorrection.ReceiptID = receipt.ID; errorCorrection.ConversionFactor = conversionfactor; errorCorrection.Save(); }
private static void HandleReceiveDocDeleting(int receiveDocID, int userID, ReceiveDoc rd) { //Check if there is a Related Picklists var pld = new PickListDetail(); pld.LoadByReceiveDocID(receiveDocID); pld.Rewind(); if(pld.RowCount > 0) { var pl = new PickList(); pl.LoadByPrimaryKey(pld.PickListID); var order = new Order(); order.LoadByPrimaryKey(pl.OrderID); string printedIDs = ""; var stvs = new BLL.Issue(); stvs.Where.PickListID.Value = pl.ID; stvs.Query.Load(); stvs.Rewind(); while (!stvs.EOF) { printedIDs += stvs.IDPrinted.ToString(CultureInfo.InvariantCulture) + " ,"; stvs.MoveNext(); } printedIDs = printedIDs.Remove(printedIDs.Length - 1, 1); throw new Exception( string.Format("Please cancel/void the following Stvs: Ref No = {0} With PrintedIDs : {1}", order.RefNo,printedIDs)); } // Add new record on ReceiveDocDeleted var recDel = ReceiveDocDeleted.AddNewLog(rd, userID); // Delete related ReceivePallet var receivePallet = new BLL.ReceivePallet(); receivePallet.LoadByReceiveDocID(receiveDocID); receivePallet.Rewind(); while(!receivePallet.EOF) { receivePallet.MarkAsDeleted(); receivePallet.MoveNext(); } // Delete related ReceivePriceConfirmation var receivePriceConfirmation = new ReceivePriceConfirmation(); receivePriceConfirmation.LoadByReceiveDocID(rd.ID); receivePriceConfirmation.MarkAsDeleted(); // Delete related ReceiveDocShortage var rdShr = new ReceiveDocShortage(); rdShr.Where.ReceiveDocID.Value = rd.ID; rdShr.Query.Load(); rdShr.Rewind(); while(!rdShr.EOF) { rdShr.MarkAsDeleted(); rdShr.MoveNext(); } // Delete related ReceiveDocConfirmation var rdConf = new ReceiveDocConfirmation(); rdConf.Where.ReceiveDocID.Value = rd.ID; rdConf.Query.Load(); rdConf.Rewind(); while(!rdConf.EOF) { rdConf.MarkAsDeleted(); rdConf.MoveNext(); } rd.MarkAsDeleted(); var transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); transaction.BeginTransaction(); try { receivePallet.Save(); receivePriceConfirmation.Save(); rdShr.Save(); rdConf.Save(); recDel.Save(); rd.Save(); transaction.CommitTransaction(); } catch (Exception exception) { transaction.RollbackTransaction(); throw; } }