private void AddItem(Data.SalesTransactionItemDetails clsItemDetails) { try { clsItemDetails.ItemNo = Convert.ToString(ItemDataTable.Rows.Count + 1); clsItemDetails.TransactionDate = mclsSalesTransactionDetails.TransactionDate; clsItemDetails.PaxNo = 0; clsItemDetails = ApplyPromo(clsItemDetails); clsItemDetails = ComputeItemTotal(clsItemDetails); // set the grossales, vat, discounts, etc. System.Data.DataRow dr = ItemDataTable.NewRow(); dr = setCurrentRowItemDetails(dr, clsItemDetails); clsItemDetails.TransactionItemsID = AddItemToDB(clsItemDetails); dr["TransactionItemsID"] = clsItemDetails.TransactionItemsID; // Added May 7, 2011 to Cater Reserved and Commit functionality ReservedAndCommitItem(clsItemDetails, clsItemDetails.TransactionItemStatus); try { dgItems.UnSelect(dgItems.CurrentRowIndex); } catch { } ItemDataTable.Rows.Add(dr); mclsSalesTransactionDetails.TransactionItemsList.Add(clsItemDetails); dgItems.CurrentRowIndex = ItemDataTable.Rows.Count; try { dgItems.Select(dgItems.CurrentRowIndex); dgItems.CurrentRowIndex = dgItems.CurrentRowIndex; } catch { } SetItemDetails(); ComputeSubTotal(); setTotalDetails(); Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction); mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction; clsSalesTransactions.UpdateSubTotal(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.DiscountCode, mclsSalesTransactionDetails.DiscountRemarks, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.ChargeAmount, mclsSalesTransactionDetails.ChargeCode, mclsSalesTransactionDetails.ChargeRemarks, mclsSalesTransactionDetails.ChargeType); clsSalesTransactions.CommitAndDispose(); try { DisplayItemToTurretDelegate DisplayItemToTurretDel = new DisplayItemToTurretDelegate(DisplayItemToTurret); DisplayItemToTurretDel.BeginInvoke(clsItemDetails.ProductCode, clsItemDetails.ProductUnitCode, clsItemDetails.Quantity, clsItemDetails.Price, clsItemDetails.Discount, clsItemDetails.PromoApplied, clsItemDetails.Amount, clsItemDetails.VAT, clsItemDetails.EVAT, null, null); } catch { } if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto) { PrintItemDelegate PrintItemDel = new PrintItemDelegate(PrintItem); PrintItemDel.BeginInvoke(clsItemDetails.ItemNo, clsItemDetails.ProductCode, clsItemDetails.ProductUnitCode, clsItemDetails.Quantity, clsItemDetails.Price, clsItemDetails.Discount, clsItemDetails.PromoApplied, clsItemDetails.Amount, clsItemDetails.VAT, clsItemDetails.EVAT, clsItemDetails.DiscountCode, clsItemDetails.ItemDiscountType, null, null); } } catch (Exception ex) { InsertErrorLogToFile(ex, "ERROR!!! Adding sales item. TRACE: "); throw ex; } }
private void setItemAsDemo() { Data.SalesTransactionItemDetails Details; int iRow = dgItems.CurrentRowIndex; if (iRow >= 0) { if (dgItems[iRow, 8].ToString() != "VOID") { if (dgItems[iRow, 8].ToString().IndexOf("RETURN") == -1 && dgItems[iRow, 8].ToString().IndexOf("DEMO") == -1) { DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.SetItemAsDemo); if (loginresult == DialogResult.OK) { if (MessageBox.Show("Are you sure you want to set this item DEMO?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } Details = getCurrentRowItemDetails(); clsEvent.AddEvent("[" + lblCashier.Text + "] Setting demo item no. " + Details.ItemNo + "".PadRight(15) + ":" + Details.Description + "."); try { // override the transaction item status TransactionItemStatus _previousTransactionItemStatus = Details.TransactionItemStatus; Details.TransactionItemStatus = TransactionItemStatus.Demo; Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction); mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction; clsSalesTransactions.setItemAsDemo(Details.TransactionItemsID, mclsSalesTransactionDetails.TransactionDate); clsEvent.AddEventLn("Setting demo item #: " + Details.ItemNo + "".PadRight(15) + ":" + Details.Description + ".", true); // 21May2015 :Shouldn't have an effect in the inventory. // it's already punched //ReservedAndCommitItem(Details, _previousTransactionItemStatus); clsSalesTransactions.CommitAndDispose(); InsertAuditLog(AccessTypes.VoidItem, "Voiding item #: " + Details.ItemNo + "".PadRight(15) + ":" + Details.Description + "." + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode); dgItems[iRow, 8] = Details.Quantity.ToString("#,##0.##") + " - DEMO"; dgItems[iRow, 9] = "0.00"; dgItems[iRow, 10] = "0.00"; dgItems[iRow, 11] = "0.00"; dgItems[iRow, 13] = "0.00"; dgItems[iRow, 14] = "0.00"; dgItems[iRow, 15] = "0.00"; dgItems[iRow, 16] = "0.00"; dgItems[iRow, 21] = TransactionItemStatus.Demo.ToString("d"); dgItems[iRow, 31] = "0.00"; //PromoApplied dgItems[iRow, 32] = "0.00"; //PurchasePrice dgItems[iRow, 33] = "0.00"; //PurchaseAmount dgItems[iRow, 43] = "0.00"; //PercentageCommision dgItems[iRow, 44] = "0.00"; //Commision dgItems[iRow, 45] = "0.00"; //RewardPoints SetItemDetails(); clsEvent.AddEventLn("Done!", true); ComputeSubTotal(); setTotalDetails(); try { DisplayItemToTurretDelegate DisplayItemToTurretDel = new DisplayItemToTurretDelegate(DisplayItemToTurret); DisplayItemToTurretDel.BeginInvoke("DEMO-" + 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 + " - DEMO ", 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!!! Setting demo item." + Details.ItemNo + "".PadRight(15) + ":" + Details.Description); } } } } } }
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); } } } } }
private void ReturnItem() { if (mboIsRefund || mclsTerminalDetails.IsParkingTerminal) return; DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.ReturnItem); if (loginresult == DialogResult.OK) { TransactionNoWnd clsTransactionNoWnd = new TransactionNoWnd(); clsTransactionNoWnd.TransactionNoLength = mclsTerminalDetails.TransactionNoLength; clsTransactionNoWnd.TerminalNo = mclsTerminalDetails.TerminalNo; clsTransactionNoWnd.TerminalDetails = mclsTerminalDetails; clsTransactionNoWnd.ShowDialog(this); DialogResult result = clsTransactionNoWnd.Result; string strTransactionNo = clsTransactionNoWnd.TransactionNo; string strTerminalNo = clsTransactionNoWnd.TerminalNo; clsTransactionNoWnd.Close(); clsTransactionNoWnd.Dispose(); if (result == DialogResult.OK) { TransactionReturnItemSelectWnd ItemWnd = new TransactionReturnItemSelectWnd(); ItemWnd.SysConfigDetails = mclsSysConfigDetails; ItemWnd.TransactionNo = strTransactionNo; ItemWnd.TerminalDetails = mclsTerminalDetails; ItemWnd.TransactionTerminalNo = strTerminalNo; ItemWnd.ShowDialog(this); if (ItemWnd.Result == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; if (!mboIsInTransaction) { lblTransDate.Text = DateTime.Now.ToString("MMM. dd, yyyy hh:mm:ss tt"); if (!this.CreateTransaction()) return; } Data.SalesTransactionItemDetails clsItemDetails = ItemWnd.Details; clsItemDetails = ComputeItemTotal(clsItemDetails); // set the grossales, vat, discounts, etc. clsItemDetails.TransactionItemStatus = TransactionItemStatus.Return; System.Data.DataRow dr = ItemDataTable.NewRow(); clsItemDetails.TransactionItemStatus = TransactionItemStatus.Return; clsItemDetails.ItemNo = Convert.ToString(ItemDataTable.Rows.Count + 1); dr = setCurrentRowItemDetails(dr, clsItemDetails); Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction); mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction; clsItemDetails.TransactionItemsID = AddItemToDB(clsItemDetails); dr["TransactionItemsID"] = clsItemDetails.TransactionItemsID.ToString(); // Sep 14, 2013: Removed if return. Return should have no effect in Reserved and Commit // Added May 7, 2011 to Cater Reserved and Commit functionality // ReservedAndCommitItem(clsItemDetails, clsItemDetails.TransactionItemStatus); ItemDataTable.Rows.Add(dr); mclsSalesTransactionDetails.TransactionItemsList.Add(clsItemDetails); dgItems.CurrentRowIndex = ItemDataTable.Rows.Count; dgItems.Select(dgItems.CurrentRowIndex); SetItemDetails(); ComputeSubTotal(); setTotalDetails(); clsSalesTransactions.UpdateSubTotal(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.DiscountCode, mclsSalesTransactionDetails.DiscountRemarks, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.ChargeAmount, mclsSalesTransactionDetails.ChargeCode, mclsSalesTransactionDetails.ChargeRemarks, mclsSalesTransactionDetails.ChargeType); clsSalesTransactions.CommitAndDispose(); InsertAuditLog(AccessTypes.RefundTransaction, "Return Item " + clsItemDetails.ProductCode + "." + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode); try { DisplayItemToTurretDelegate DisplayItemToTurretDel = new DisplayItemToTurretDelegate(DisplayItemToTurret); DisplayItemToTurretDel.BeginInvoke("RET-" + clsItemDetails.ProductCode, clsItemDetails.ProductUnitCode, clsItemDetails.Quantity, clsItemDetails.Price, clsItemDetails.Discount, clsItemDetails.PromoApplied, clsItemDetails.Amount, clsItemDetails.VAT, clsItemDetails.EVAT, null, null); } catch { } if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto) { PrintItemDelegate PrintItemDel = new PrintItemDelegate(PrintItem); string strProductCode = clsItemDetails.ProductCode; if (!string.IsNullOrEmpty(clsItemDetails.MatrixDescription)) strProductCode += "-" + clsItemDetails.MatrixDescription; PrintItemDel.BeginInvoke(clsItemDetails.ItemNo, strProductCode + " - RET ", clsItemDetails.ProductUnitCode, clsItemDetails.Quantity, clsItemDetails.Price, clsItemDetails.Discount, clsItemDetails.PromoApplied, clsItemDetails.Amount, clsItemDetails.VAT, clsItemDetails.EVAT, clsItemDetails.DiscountCode, clsItemDetails.ItemDiscountType, null, null); } Cursor.Current = Cursors.Default; } ItemWnd.Close(); ItemWnd.Dispose(); } } }