Пример #1
0
        /// <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;
                    }
                }
            }
        }