void fasGetAccountCode_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e) { sAccountCodeToReceive = fasGetAccountCode.sGetAccountCode(); if (sAccountCodeToReceive != "NONE_SELECTED") { string[] sExtraInfo = { tEngine.sGetAccountDetailsFromCode(sAccountCodeToReceive)[2].TrimEnd('\0').TrimEnd(' ') }; fiGetAmount = new frmInput(frmInput.FormType.ReceivedOnAccount, pLocation, new Size(sSize.Width, 75), sExtraInfo); fiGetAmount.Show(); fiGetAmount.FormClosing += new FormClosingEventHandler(fiGetAmount_FormClosing); } }
/// <summary> /// Handles a keydown event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void lbKeyName_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { this.Close(); } else if (e.KeyCode == Keys.Enter) { string[] sExtraInfo = { lbKeyName.Items[lbKeyName.SelectedIndex].ToString() }; sCurrentKeyBeingEdited = sExtraInfo[0]; fiGetNewCode = new frmInput(frmInput.FormType.PresetKeyEntry, new Point(this.Left, this.Top + this.Height - 70 - 40), new Size(this.Width, 40), sExtraInfo); fiGetNewCode.Show(); fiGetNewCode.FormClosing += new FormClosingEventHandler(fiGetNewCode_FormClosing); } }
/// <summary> /// Handles the keydown event of the form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void frmPaymentInput_KeyDown(object sender, KeyEventArgs e) { if (nState == 0) // Form is in payment selection stage { if (e.KeyCode == Keys.Right) { if (nCurrentlySelected < 7) { nCurrentlySelected++; } } else if (e.KeyCode == Keys.Left) { if (nCurrentlySelected > 0) { nCurrentlySelected -= 1; } } else if (e.KeyCode == Keys.Down) { if (nCurrentlySelected < 4) { nCurrentlySelected += 4; } } else if (e.KeyCode == Keys.Up) { if (nCurrentlySelected > 3) { nCurrentlySelected -= 4; } } else if (e.KeyCode == Keys.Escape) { sPaymentType = "NULL"; fAmountInput = 0.0f; this.Close(); } else if (e.KeyCode == Keys.Multiply) { sPaymentType = "CASH"; bJumpedStraightToCash = true; SetupForGettingAmount(); } else if (e.KeyCode == Keys.Enter) { switch (nCurrentlySelected) { case 0: sPaymentType = "CASH"; break; case 1: sPaymentType = "CHEQ"; break; case 2: sPaymentType = "CRCD"; break; case 3: sPaymentType = "DEPO"; break; case 4: sPaymentType = "DEPO"; break; case 5: sPaymentType = "CHRG"; this.Close(); break; case 6: fiDiscountAmnt = new frmInput(frmInput.FormType.DiscountAmount, this.Location, this.Size, new string[0]); fiDiscountAmnt.Show(); fiDiscountAmnt.FormClosing += new FormClosingEventHandler(fiDiscountAmnt_FormClosing); break; case 7: sPaymentType = "NULL"; this.Close(); break; } if (nCurrentlySelected != 6) // If discount hasn't been selected { SetupForGettingAmount(); } } else if (!bKeyUp) { try { int nKeyNumber = Convert.ToInt32(e.KeyCode.ToString()[e.KeyCode.ToString().Length - 1].ToString()); SelectCard(nKeyNumber); } catch { ; } } if (nCurrentlySelected == 6 && !bDiscountAllowed) { nCurrentlySelected++; // Just move along to close because discount isn't allowed } if (nCurrentlySelected == 5 && !bChargeToAccountAllowed) { nCurrentlySelected = 7; // Move along to close because charge to account isn't allowed } for (int i = 0; i < lblPaymentChoices.Length; i++) // Unhighlight all options { lblPaymentChoices[i].BackColor = cBackColour; lblPaymentChoices[i].ForeColor = cForeColour; } // Highlight the currently selected option lblPaymentChoices[nCurrentlySelected].BackColor = cForeColour; lblPaymentChoices[nCurrentlySelected].ForeColor = cBackColour; this.Refresh(); } else if (nState == 2) // Credit card selection { if (e.KeyCode == Keys.Escape) // Go back to payment selection { SetupFromCards(); } else { try { // Try to get the credit card that was selected int nKeyNumber = Convert.ToInt32(e.KeyCode.ToString()[e.KeyCode.ToString().Length - 1].ToString()); if (nKeyNumber > 0 && nKeyNumber <= lblCreditCardChoices.Length) { sPaymentType += (e.KeyCode.ToString()[e.KeyCode.ToString().Length - 1]); fAmountInput = TillEngine.TillEngine.fFormattedMoneyString(tbGetAmount.Text); if (!bKeyUp) { sPaymentType = "CRCD" + (e.KeyCode.ToString()[e.KeyCode.ToString().Length - 1]); fAmountInput = fAmountRemainingDue; } this.Close(); } } catch { ; } } } }
/// <summary> /// The handler for when a key is pressed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void lbMenuItems_KeyDown(object sender, KeyEventArgs e) { nTimeUntilTimeOut = 60; lblTimeoutCountdown.Text = ""; if (e.KeyCode == Keys.Escape) { this.Close(); } else if (e.KeyCode == Keys.Enter) { if (currentMenuType == MenuType.MainMenu) { switch (lbMenuItems.SelectedIndex) { case 0: // Toggle printer status tEngine.TogglePrinterStatus(); this.Close(); break; case 1: //Reprint a receipt fltReprintReceipt = new frmLookupTransactions(new Size(this.Width, this.Height - 56), ref tEngine, new Point(this.Left, this.Top + 56), "REPRINT_RECEIPT"); fltReprintReceipt.Show(); fltReprintReceipt.FormClosing += new FormClosingEventHandler(fltReprintReceipt_FormClosing); bOtherFormOpen = true; break; case 2: // Cash paid out fiCashPaidOut = new frmInput(frmInput.FormType.CashPaidOut, new Point(this.Left, this.Height + this.Top - 150), new Size(this.Width, 150), new string[0]); fiCashPaidOut.Show(); fiCashPaidOut.FormClosing += new FormClosingEventHandler(fiCashPaidOut_FormClosing); bOtherFormOpen = true; break; case 3: // Void Transaction fltTransToVoid = new frmLookupTransactions(new Size(this.Width, this.Height - 56), ref tEngine, new Point(this.Left, this.Top + 56), "VOID_TRANSACTION"); fltTransToVoid.Show(); fltTransToVoid.FormClosing += new FormClosingEventHandler(fltTransToVoid_FormClosing); bOtherFormOpen = true; break; case 4: // Look up transactions fltTransactions = new frmLookupTransactions(new Size(this.Width, this.Height - 56), ref tEngine, new Point(this.Left, this.Top + 56), null); fltTransactions.Show(); bOtherFormOpen = true; fltTransactions.FormClosing += new FormClosingEventHandler(fltTransactions_FormClosing); break; case 5: // Money In Till fmitMoneyInTill = new frmMoneyInTill(ref tEngine, new Point(this.Left, this.Top + 56), new Size(this.Width, this.Height - 56)); fmitMoneyInTill.Show(); bOtherFormOpen = true; fmitMoneyInTill.FormClosing += new FormClosingEventHandler(fmitMoneyInTill_FormClosing); break; case 6: // Refund frRefund = new frmRefund(new Size(this.Width, this.Height - 56), new Point(this.Left, this.Top + 56), ref tEngine); frRefund.Show(); bOtherFormOpen = true; frRefund.FormClosing += new FormClosingEventHandler(frRefund_FormClosing); break; case 7: // Define Preset Keys fpkPresets = new frmPresetKeys(new Point(this.Left, this.Top + 56), new Size(this.Width, this.Height - 56), ref tEngine); fpkPresets.Show(); fpkPresets.FormClosing += new FormClosingEventHandler(fpkPresets_FormClosing); bOtherFormOpen = true; break; case 8: // Print a register report tEngine.PrintRegisterReport(); break; case 9: // Receive On Account froaReceiveMoney = new frmReceiveOnAccount(new Point(this.Left, this.Top + this.Height - 150), new Size(this.Width, 150), ref tEngine); bOtherFormOpen = true; froaReceiveMoney.FormClosing += new FormClosingEventHandler(froaReceiveMoney_FormClosing); break; case 10: // Print Stock Levels frmCategorySelect fcSelect = new frmCategorySelect(ref tEngine); fcSelect.ShowDialog(); if (fcSelect.SelectedCategory != "NONE_SELECTED") { tEngine.PrintStockLevelsOfCategory(fcSelect.SelectedCategory); } break; case 11: frmAddToOrder fato = new frmAddToOrder(ref tEngine); fato.ShowDialog(); break; case 13: Application.ExitThread(); //Application.Exit(); break; case 12: tmrUpdateDateTime.Enabled = false; frmSearchForItemV2 fsfBarcode = new frmSearchForItemV2(ref tEngine); fsfBarcode.ShowDialog(); if (fsfBarcode.GetItemBarcode() != "NONE_SELECTED") { tEngine.PrintBarcode(fsfBarcode.GetItemBarcode(), false); } tmrUpdateDateTime.Enabled = true; break; } } else if (currentMenuType == MenuType.AdminMenu) { switch (lbMenuItems.SelectedIndex) { case 0: // Remove a transaction fltTransToRemove = new frmLookupTransactions(new Size(this.Width, this.Height - 56), ref tEngine, new Point(this.Left, this.Top + 56), "REMOVE_TRANSACTION"); try { fltTransToRemove.Show(); fltTransToRemove.FormClosing += new FormClosingEventHandler(fltTransToRemove_FormClosing); bOtherFormOpen = true; } catch { // User backed out of removal ; } break; case 1: if (File.Exists("REPDATA_PREV.DBF") && File.Exists("TDATA_PREV.DBF") && File.Exists("THDR_PREV.DBF") && UserCertain("undo the previous transaction?")) { File.Delete(GTill.Properties.Settings.Default.sRepDataLoc); File.Delete(GTill.Properties.Settings.Default.sTDataLoc); File.Delete(GTill.Properties.Settings.Default.sTHdrLoc); File.Copy("REPDATA_PREV.DBF", GTill.Properties.Settings.Default.sRepDataLoc); File.Copy("TDATA_PREV.DBF", GTill.Properties.Settings.Default.sTDataLoc); File.Copy("THDR_PREV.DBF", GTill.Properties.Settings.Default.sTHdrLoc); tEngine.LoadTable("REPDATA"); tEngine.LoadTable("TDATA"); tEngine.LoadTable("THDR"); this.Close(); } break; case 2: // Print receipt header tEngine.PrintReceiptHeader(); tEngine.EmptyPrinterBuffer(); this.Close(); break; case 3: // Print receipt footer string sDateTime = DateTime.Now.Day + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Year.ToString() + ", " + DateTime.Now.TimeOfDay.Hours.ToString() + ":" + DateTime.Now.TimeOfDay.Minutes.ToString(); string sStaffName = tEngine.GetCurrentStaffName(); string sTransactionNumber = tEngine.GetNextTransactionNumber().ToString(); tEngine.PrintReceiptFooter(sStaffName, sDateTime, sTransactionNumber); tEngine.EmptyPrinterBuffer(); this.Close(); break; case 4: // Process file in INGNG folder if (GTill.Properties.Settings.Default.bUsingDosInsteadOfFloppy) { tEngine.CollectFilesFromDosDrive(); } if (tEngine.ProcessFilesInINGNG()) { if (MessageBox.Show("Not all changes will take effect until GTill has restarted. Restart now?", "Restart Now?", MessageBoxButtons.YesNo) == DialogResult.Yes) { Application.Restart(); } else { MessageBox.Show("Files from INGNG have been processed"); } } this.Close(); break; case 5: // About GTill frmAbout fAbt = new frmAbout(); fAbt.ShowDialog(); break; case 6: // Empty Printer Buffer tEngine.EmptyPrinterBuffer(); this.Close(); break; case 7: // Show the configuration window frmConfig cfg = new frmConfig(); Cursor.Show(); cfg.ShowDialog(); Cursor.Hide(); break; case 8: // Change sales date in REPDATA frmDateInput fdi = new frmDateInput(this.Size); fdi.Visible = false; fdi.ShowDialog(); tEngine.SetDateInRepData(fdi.DateTimeInput); MessageBox.Show("Date was successfully changed to " + fdi.DateTimeInput); this.Close(); break; case 9: tEngine.DemoMode = !tEngine.DemoMode; if (tEngine.DemoMode) { MessageBox.Show("Demonstration Mode has been enabled. No standard transactions will be saved whilst in demonstration mode, although refunds, transaction removals, void transactions etc will still be counted!! Please remember to disable it when you have finished."); } else { MessageBox.Show("Demonstration Mode has been disabled."); } this.Close(); break; case 10: throw new NotSupportedException("Test error!"); break; case 11: tEngine.ApplyCreditCardDiscs(); this.Close(); tEngine.PrintRegisterReport(); break; case 12: frmSingleInputBox fsiGetHex = new frmSingleInputBox("Enter 1 byte hex codes, seperated by spaces (e.g. 01 AF F2)"); tmrUpdateDateTime.Enabled = false; fsiGetHex.ShowDialog(); if (fsiGetHex.Response != "$NONE") { tEngine.PrintTestBarcode(fsiGetHex.Response); } break; case 13: frmBackupDates fbd = new frmBackupDates(); fbd.ShowDialog(); break; } } } }
/// <summary> /// The handler for when a key is pressed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void lbMenuItems_KeyDown(object sender, KeyEventArgs e) { nTimeUntilTimeOut = 60; lblTimeoutCountdown.Text = ""; if (e.KeyCode == Keys.Escape) { this.Close(); } else if (e.KeyCode == Keys.Enter) { if (currentMenuType == MenuType.MainMenu) { switch (lbMenuItems.SelectedIndex) { case 0: // Toggle printer status tEngine.TogglePrinterStatus(); this.Close(); break; case 1: //Reprint a receipt fltReprintReceipt = new frmLookupTransactions(new Size(this.Width, this.Height - 56), ref tEngine, new Point(this.Left, this.Top + 56), "REPRINT_RECEIPT"); fltReprintReceipt.Show(); fltReprintReceipt.FormClosing += new FormClosingEventHandler(fltReprintReceipt_FormClosing); bOtherFormOpen = true; break; case 2: // Cash paid out fiCashPaidOut = new frmInput(frmInput.FormType.CashPaidOut, new Point(this.Left, this.Height + this.Top - 150), new Size(this.Width, 150), new string[0]); fiCashPaidOut.Show(); fiCashPaidOut.FormClosing += new FormClosingEventHandler(fiCashPaidOut_FormClosing); bOtherFormOpen = true; break; case 3: // Void Transaction fltTransToVoid = new frmLookupTransactions(new Size(this.Width, this.Height - 56), ref tEngine, new Point(this.Left, this.Top + 56), "VOID_TRANSACTION"); fltTransToVoid.Show(); fltTransToVoid.FormClosing += new FormClosingEventHandler(fltTransToVoid_FormClosing); bOtherFormOpen = true; break; case 4: // Look up transactions fltTransactions = new frmLookupTransactions(new Size(this.Width, this.Height - 56), ref tEngine, new Point(this.Left, this.Top + 56), null); fltTransactions.Show(); bOtherFormOpen = true; fltTransactions.FormClosing += new FormClosingEventHandler(fltTransactions_FormClosing); break; case 5: // Money In Till fmitMoneyInTill = new frmMoneyInTill(ref tEngine, new Point(this.Left, this.Top + 56), new Size(this.Width, this.Height - 56)); fmitMoneyInTill.Show(); bOtherFormOpen = true; fmitMoneyInTill.FormClosing += new FormClosingEventHandler(fmitMoneyInTill_FormClosing); break; case 6: // Refund frRefund = new frmRefund(new Size(this.Width, this.Height - 56), new Point(this.Left, this.Top + 56), ref tEngine); frRefund.Show(); bOtherFormOpen = true; frRefund.FormClosing += new FormClosingEventHandler(frRefund_FormClosing); break; case 7: // Define Preset Keys fpkPresets = new frmPresetKeys(new Point(this.Left, this.Top + 56), new Size(this.Width, this.Height - 56), ref tEngine); fpkPresets.Show(); fpkPresets.FormClosing += new FormClosingEventHandler(fpkPresets_FormClosing); bOtherFormOpen = true; break; case 8: // Print a register report tEngine.PrintRegisterReport(); break; case 9: // Receive On Account froaReceiveMoney = new frmReceiveOnAccount(new Point(this.Left, this.Top + this.Height - 150), new Size(this.Width, 150), ref tEngine); bOtherFormOpen = true; froaReceiveMoney.FormClosing += new FormClosingEventHandler(froaReceiveMoney_FormClosing); break; case 10: Application.ExitThread(); //Application.Exit(); break; } } else if (currentMenuType == MenuType.AdminMenu) { switch (lbMenuItems.SelectedIndex) { case 0: // Remove a transaction fltTransToRemove = new frmLookupTransactions(new Size(this.Width, this.Height - 56), ref tEngine, new Point(this.Left, this.Top + 56), "REMOVE_TRANSACTION"); try { fltTransToRemove.Show(); fltTransToRemove.FormClosing += new FormClosingEventHandler(fltTransToRemove_FormClosing); bOtherFormOpen = true; } catch { // User backed out of removal ; } break; case 1: if (File.Exists("REPDATA_PREV.DBF") && File.Exists("TDATA_PREV.DBF") && File.Exists("THDR_PREV.DBF") && UserCertain("undo the previous transaction?")) { File.Delete(GTill.Properties.Settings.Default.sRepDataLoc); File.Delete(GTill.Properties.Settings.Default.sTDataLoc); File.Delete(GTill.Properties.Settings.Default.sTHdrLoc); File.Copy("REPDATA_PREV.DBF", GTill.Properties.Settings.Default.sRepDataLoc); File.Copy("TDATA_PREV.DBF", GTill.Properties.Settings.Default.sTDataLoc); File.Copy("THDR_PREV.DBF", GTill.Properties.Settings.Default.sTHdrLoc); tEngine.LoadTable("REPDATA"); tEngine.LoadTable("TDATA"); tEngine.LoadTable("THDR"); this.Close(); } break; case 2: // Print receipt header tEngine.PrintReceiptHeader(); break; case 3: // Print receipt footer string sDateTime = DateTime.Now.Day + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Year.ToString() + ", " + DateTime.Now.TimeOfDay.Hours.ToString() + ":" + DateTime.Now.TimeOfDay.Minutes.ToString(); string sStaffName = tEngine.GetCurrentStaffName(); string sTransactionNumber = tEngine.GetNextTransactionNumber().ToString(); tEngine.PrintReceiptFooter(sStaffName, sDateTime, sTransactionNumber); break; case 4: // Process file in INGNG folder tEngine.ProcessFilesInINGNG(); break; case 5: // About GTill frmAbout fAbt = new frmAbout(); fAbt.ShowDialog(); break; } } } }