Ejemplo n.º 1
0
		private void VoidItem()
		{
			Data.SalesTransactionItemDetails Details;

			int iRow = dgItems.CurrentRowIndex;

			if (iRow >= 0)
			{
				if (dgItems[iRow, 8].ToString() != "VOID")
				{
					DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.VoidItem);

					if (loginresult == DialogResult.OK)
					{
						if (mclsTerminalDetails.ItemVoidConfirmation)
						{
							if (MessageBox.Show("Are you sure you want to void this item?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
							{
								return;
							}
						}

                        Details = getCurrentRowItemDetails();
                        clsEvent.AddEvent("[" + lblCashier.Text + "] Voiding item no. " + Details.ItemNo + "".PadRight(15) + ":" + Details.Description + ".");
						try
						{
							// override the transaction item status
							TransactionItemStatus _previousTransactionItemStatus = Details.TransactionItemStatus;

							Details.TransactionItemStatus = TransactionItemStatus.Void;

                            Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                            mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

							clsSalesTransactions.VoidItem(Details.TransactionItemsID, mclsSalesTransactionDetails.TransactionDate);
                            clsEvent.AddEventLn("Voiding item #: " + Details.ItemNo + "".PadRight(15) + ":" + Details.Description + ".", true);

							// Added May 7, 2011 to Cater Reserved and Commit functionality    
							ReservedAndCommitItem(Details, _previousTransactionItemStatus);
                            clsSalesTransactions.CommitAndDispose();

                            InsertAuditLog(AccessTypes.VoidItem, "Voiding item #: " + Details.ItemNo + "".PadRight(15) + ":" + Details.Description + "." + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);

							dgItems[iRow, 8] = "VOID";
							dgItems[iRow, 9] = "0.00";
							dgItems[iRow, 10] = "0.00";
							dgItems[iRow, 11] = "0.00";
							dgItems[iRow, 13] = "0.00";
                            dgItems[iRow, 21] = TransactionItemStatus.Void.ToString("d");

							SetItemDetails();
							
							clsEvent.AddEventLn("Done!", true);
							
							ComputeSubTotal(); setTotalDetails();

							try
							{
								DisplayItemToTurretDelegate DisplayItemToTurretDel = new DisplayItemToTurretDelegate(DisplayItemToTurret);
								DisplayItemToTurretDel.BeginInvoke("VOID-" + Details.ProductCode, Details.ProductUnitCode, Details.Quantity, Details.Price, Details.Discount, Details.PromoApplied, Details.Amount, Details.VAT, Details.EVAT, null, null);
							}
							catch { }
							if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto)
							{
								PrintItemDelegate PrintItemDel = new PrintItemDelegate(PrintItem);
                                PrintItemDel.BeginInvoke(Details.ItemNo, Details.ProductCode + " - VOID ", Details.ProductUnitCode, Details.Quantity, Details.Price, Details.Discount, Details.PromoApplied, Details.Amount, Details.VAT, Details.EVAT, Details.DiscountCode, Details.ItemDiscountType, null, null);
								//PrintItemDel.BeginInvoke(Details.ProductCode + " - VOID ", Details.ProductUnitCode, Details.Quantity, Details.Price, Details.Discount, Details.PromoApplied, Details.Amount, Details.VAT, Details.EVAT, null, null);
							}

						}
						catch (Exception ex)
						{
                            InsertErrorLogToFile(ex, "ERROR!!! Voiding item." + Details.ItemNo + "".PadRight(15) + ":" + Details.Description); 
                        }
					}
				}
			}
		}