private void VoidTransaction() { if (!mboIsInTransaction) { MessageBox.Show("Sorry you cannot void an empty transaction.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show("Are you sure you want to void this transaction?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.VoidTransaction); if (loginresult == DialogResult.OK) { try { clsEvent.AddEventLn("[" + lblCashier.Text + "] Voiding transaction no. " + lblTransNo.Text, true); mclsSalesTransactionDetails.TransactionStatus = TransactionStatus.Void; if (mclsTerminalDetails.AutoPrint == PrintingPreference.AskFirst) if (MessageBox.Show("Would you like to print this transaction?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, (mclsSysConfigDetails.isDefaultButtonYesInPrintTransaction ? MessageBoxDefaultButton.Button1 : MessageBoxDefaultButton.Button2)) == DialogResult.Yes) mclsTerminalDetails.AutoPrint = PrintingPreference.Normal; // Sep 14, 2014 Control printing in mclsFilePrinter.Write //if (mclsTerminalDetails.AutoPrint == PrintingPreference.Normal) //{ //if (mclsTerminalDetails.IsPrinterAutoCutter) // PrintReportPageHeaderSectionChecked(true); //else PrintReportHeadersSection(true); mboIsItemHeaderPrinted = true; foreach (System.Data.DataRow dr in ItemDataTable.Rows) { string stItemNo = "" + dr["ItemNo"].ToString(); string stProductUnitCode = "" + dr["ProductUnitCode"].ToString(); decimal decPrice = Convert.ToDecimal(dr["Price"]); decimal decDiscount = Convert.ToDecimal(dr["Discount"]); decimal decAmount = Convert.ToDecimal(dr["Amount"]); decimal decVAT = Convert.ToDecimal(dr["VAT"]); decimal decEVAT = Convert.ToDecimal(dr["EVAT"]); decimal decPromoApplied = Convert.ToDecimal(dr["PromoApplied"]); string stProductCode = ""; decimal decQuantity = 0; string stDiscountCode = "" + dr["DiscountCode"].ToString(); DiscountTypes ItemDiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), dr["ItemDiscountType"].ToString()); if (dr["Quantity"].ToString().IndexOf("RETURN") != -1) { stProductCode = "" + dr["ProductCode"].ToString() + "-RET"; decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - RETURN", "").Trim()); decAmount = -decAmount; } else if (dr["Quantity"].ToString().IndexOf("DEMO") != -1) { stProductCode = "" + dr["ProductCode"].ToString() + "-DEMO"; decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - DEMO", "").Trim()); decAmount = 0; } else if (dr["Quantity"].ToString() != "VOID") { stProductCode = "" + dr["ProductCode"].ToString(); decQuantity = Convert.ToDecimal(dr["Quantity"]); } if (dr["Quantity"].ToString().IndexOf("VOID") != -1) { if (mclsTerminalDetails.WillPrintVoidItem) if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default) PrintItem(stItemNo, stProductCode, stProductUnitCode, decQuantity, decPrice, decDiscount, decPromoApplied, decAmount, decVAT, decEVAT, stDiscountCode, ItemDiscountType); } else { if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default) PrintItem(stItemNo, stProductCode, stProductUnitCode, decQuantity, decPrice, decDiscount, decPromoApplied, decAmount, decVAT, decEVAT, stDiscountCode, ItemDiscountType); } //} // Sep 14, 2014 Control printing in mclsFilePrinter.Write } Cursor.Current = Cursors.WaitCursor; Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction); mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction; // Added May 7, 2011 to Cater Reserved and Commit functionality #region Reserved And Commit //if (mclsTerminalDetails.ReservedAndCommit == true) //{ System.Data.DataTable dt = (System.Data.DataTable)dgItems.DataSource; for (int x = 0; x < dt.Rows.Count; x++) { dgItems.CurrentRowIndex = x; Data.SalesTransactionItemDetails Details = getCurrentRowItemDetails(); if (Details.TransactionItemStatus != TransactionItemStatus.Void) { Details.TransactionItemStatus = TransactionItemStatus.Void; ReservedAndCommitItem(Details, Details.TransactionItemStatus); } } //} #endregion //UpdateTerminalReportDelegate updateterminalDel = new UpdateTerminalReportDelegate(UpdateTerminalReport); UpdateTerminalReport(TransactionStatus.Void, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, 0, 0, 0, 0, 0, 0, 0, PaymentTypes.NotYetAssigned); //UpdateCashierReportDelegate updatecashierDel = new UpdateCashierReportDelegate(UpdateCashierReport); UpdateCashierReport(TransactionStatus.Void, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, 0, 0, 0, 0, 0, 0, 0, PaymentTypes.NotYetAssigned); clsSalesTransactions.Void(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.GrossSales, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.NetSales, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.SNRDiscount, mclsSalesTransactionDetails.PWDDiscount, mclsSalesTransactionDetails.OtherDiscount, mclsSalesTransactionDetails.TransDiscount, mclsSalesTransactionDetails.TransDiscountType, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.CashierID, mclsSalesTransactionDetails.CashierName); clsSalesTransactions.UpdateTerminalNo(mclsSalesTransactionDetails.TransactionID, lblTerminalNo.Text); // Sep 24, 2014 : update back the LastCheckInDate to min date Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction); mConnection = clsContact.Connection; mTransaction = clsContact.Transaction; clsContact.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE); // 22Nov2014 : remove the merge tables when closed or void RemoveFromMergeTable(mclsSalesTransactionDetails.CustomerDetails.ContactCode); try { clsSalesTransactions.CommitAndDispose(); } catch { mclsSalesTransactionDetails.TransactionStatus = TransactionStatus.Open; } InsertAuditLog(AccessTypes.VoidTransaction, "VOID transaction #".PadRight(15) + ":" + lblTransNo.Text + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode); clsEvent.AddEventLn("Done transaction no. " + lblTransNo.Text + " has been void.", true); if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default) { PrintReportFooterSection(true, TransactionStatus.Void, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.Charge, 0, 0, 0, 0, 0, 0, 0, 0, 0, null, null, null, null); } else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice) { PrintSalesInvoice(); } else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt) { PrintDeliveryReceipt(); } else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR) { PrintSalesInvoice(); PrintDeliveryReceipt(); } //Added April 12, 2014 else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.OfficialReceiptAndDR) { PrintOfficialReceipt(); PrintDeliveryReceipt(); } //Added February 10, 2010 else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300Printer) { PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300Printer); } //Added May 11, 2010 else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceOrDR) { PrintDeliveryReceipt(); } //Added January 17, 2011 else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300PlusPrinter) { PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300PlusPrinter); } //Added February 22, 2011 else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300PlusAmazon) { PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300PlusAmazon); //8.5inc x 7inch } this.LoadOptions(); MessageBox.Show("Transaction has been VOID. Press OK button to continue...", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information); Cursor.Current = Cursors.Default; } catch (Exception ex) { InsertErrorLogToFile(ex, "ERROR!!! Voiding transaction."); } } }