Example #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:
                        // 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;
                    }
                }
            }
        }
Example #2
0
 void frmLookupTransactionsV2_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyValue >= 65 && e.KeyValue <= 90 && !e.Shift)
     {
         sSearchTerm     += e.KeyCode.ToString();
         bTextBoxHasFocus = true;
     }
     else if (e.KeyValue >= 47 && e.KeyValue <= 57)
     {
         sSearchTerm     += (e.KeyValue - 48).ToString();
         bTextBoxHasFocus = true;
     }
     else if (e.KeyValue >= 96 && e.KeyValue <= 106)
     {
         sSearchTerm     += (e.KeyValue - 96).ToString();
         bTextBoxHasFocus = true;
     }
     else if (e.KeyValue == 8)
     {
         string sNewSearchTerm = "";
         for (int i = 0; i < sSearchTerm.Length - 1; i++)
         {
             sNewSearchTerm += sSearchTerm[i].ToString();
         }
         if (sSearchTerm == "CAT:")
         {
             sSearchTerm = "";
         }
         else
         {
             sSearchTerm = sNewSearchTerm;
         }
         bTextBoxHasFocus = true;
     }
     else if (e.KeyValue == 32)
     {
         sSearchTerm     += " ";
         bTextBoxHasFocus = true;
     }
     else if (e.KeyValue == 13 && bTextBoxHasFocus)
     {
         // Do search
         if (sSearchTerm.Length > 1)
         {
             this.CreateGraphics().DrawString("Searching by code, please wait.", new Font(GTill.Properties.Settings.Default.sFontName, 12.0f), new SolidBrush(Color.Red), new PointF(10, 107));
             SearchForItems();
             bTextBoxHasFocus = false;
         }
     }
     else if (e.KeyValue == 9)
     {
         bHideNoStockItems = !bHideNoStockItems;
         CountNumberOfResultsToShow();
         nCurrentItemSelected = 0;
         nScrolledDown        = 0;
         if (nOfSearchResultsBeingDisplayed == 0)
         {
             bTextBoxHasFocus = true;
         }
     }
     else if (e.KeyValue == 40)
     {
         // Move Down
         if (bTextBoxHasFocus)
         {
             bTextBoxHasFocus     = false;
             nCurrentItemSelected = 0;
             nScrolledDown        = 0;
         }
         else
         {
             if (nCurrentItemSelected + 1 < nOfSearchResultsBeingDisplayed)
             {
                 nCurrentItemSelected++;
             }
             else if (!bTextBoxHasFocus)
             {
                 // Prevent it from going to the top when going too far down
                 //bTextBoxHasFocus = true;
             }
             if (nCurrentItemSelected > nScrolledDown + nOfResultsDrawnToScreen && nCurrentItemSelected < nOfSearchResultsBeingDisplayed)
             {
                 nScrolledDown++;
             }
         }
     }
     else if (e.KeyValue == 38)
     {
         // Move up
         if (nCurrentItemSelected > 0)
         {
             nCurrentItemSelected -= 1;
         }
         else if (nCurrentItemSelected == 0 && bTextBoxHasFocus)
         {
             /*bTextBoxHasFocus = false;
              * nCurrentItemSelected = nOfSearchResultsBeingDisplayed - 1;
              * nScrolledDown = nOfSearchResultsBeingDisplayed - nOfResultsDrawnToScreen - 1;
              * if (nScrolledDown < 0)
              *  nScrolledDown = 0;*/
             // Prevent it from going to the bottom when going too far up
         }
         else if (nCurrentItemSelected == 0 && !bTextBoxHasFocus)
         {
             bTextBoxHasFocus = true;
         }
         if (nCurrentItemSelected < nScrolledDown)
         {
             nScrolledDown -= 1;
         }
     }
     else if (e.KeyValue == 27)
     {
         if (bTextBoxHasFocus)
         {
             this.Close();
         }
         else
         {
             bTextBoxHasFocus     = true;
             nScrolledDown        = 0;
             nCurrentItemSelected = 0;
         }
     }
     else if (e.KeyCode == Keys.Subtract || e.KeyCode == Keys.OemMinus)
     {
         if (bTextBoxHasFocus)
         {
             sSearchTerm     += "-";
             bTextBoxHasFocus = true;
         }
     }
     else if (e.KeyCode == Keys.Enter)
     {
         sSelectedBarcode = getSelectedBarcode();
         this.Close();
     }
     else if (e.Shift && e.KeyCode == Keys.P)
     {
         // Print out a barcode
         string sCode = getSelectedBarcode();
         if (sCode != "")
         {
             tEngine.PrintBarcode(sCode, false);
         }
     }
     else if (e.KeyCode == Keys.F5)
     {
         fcSelect = new frmCategorySelect(ref tEngine);
         fcSelect.ShowDialog();
         if (fcSelect.SelectedCategory != "NONE_SELECTED")
         {
             sSearchTerm = "CAT:" + fcSelect.SelectedCategory;
             SearchForItems();
             if (nOfSearchResultsBeingDisplayed > 0)
             {
                 nScrolledDown        = 0;
                 nCurrentItemSelected = 0;
                 bTextBoxHasFocus     = false;
             }
         }
         fcSelect.Dispose();
     }
     else if (e.KeyCode == Keys.F6)
     {
         this.Hide();
         frmSearchForItem fsi = new frmSearchForItem(ref tEngine);
         fsi.ShowDialog();
         sSelectedBarcode = fsi.GetItemBarcode();
         this.Close();
     }
     else if (e.KeyCode == Keys.Oem1)
     {
         sSearchTerm += ":";
     }
     else if (e.KeyCode == Keys.PageDown)
     {
         nScrolledDown += nOfResultsDrawnToScreen;
         if (nScrolledDown + nOfResultsDrawnToScreen >= nOfSearchResultsBeingDisplayed)
         {
             nScrolledDown = nOfSearchResultsBeingDisplayed - nOfResultsDrawnToScreen;
         }
         nCurrentItemSelected = nScrolledDown;
     }
     else if (e.Shift)
     {
         // Do nothing - wait for the next key
         ;
     }
     else
     {
         bTextBoxHasFocus = true;
     }
     this.Refresh();
 }