コード例 #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;
                    }
                }
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            // Ensure that the compression dll exists
            if (!File.Exists("Ionic.Zip.dll"))
            {
                FileStream fs = new FileStream("Ionic.Zip.dll", FileMode.Create);
                fs.Write(Properties.Resources.Ionic_Zip, 0, Properties.Resources.Ionic_Zip.Length);
                fs.Close();
            }

            bool bFatalErrors = false;

            if (args.Length > 0)
            {
                if (args[0] == "config")
                {
                    frmConfig c = new frmConfig();
                    c.ShowDialog();
                }
                else if (args[0] == "regreport")
                {
                    try
                    {
                        // Print a register report and exit
                        TillEngine.TillEngine tEngine = new TillEngine.TillEngine();
                        tEngine.LoadTablesForJustRegisterReport();
                        tEngine.PrintRegisterReport();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error. Unable to print the selected register report:" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    Application.Exit();
                    return;
                }
            }
            // Checks for fatal errors with the configuration file
            if (PreRunChecks(ref bFatalErrors))
            {
                // If no errors, then continue to start the program
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                //try
                //{
                Application.Run(new frmMain());
                //}

                /*catch (Exception ex)
                 * {
                 *  ErrorHandler.LogError(ex.ToString());
                 *  if (MessageBox.Show("Sorry, an error has occured with GTill. GTill will restart automatically when you select OK. Press Cancel to not restart", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK)
                 *  {
                 *      Application.Restart();
                 *  }
                 * }*/
            }
            else
            {
                if (bFatalErrors)
                {
                    System.Windows.Forms.MessageBox.Show("One or more fatal errors occured whilst trying to load the till. Please see the log for more information.");
                }
                else
                {
                    // Not a serious error
                    System.Windows.Forms.MessageBox.Show("One or more errors occured whilst trying to load the till. Please see the log for more information");
                }
            }

            /*
             * TillEngine.TillEngine tEngine = new TillEngine.TillEngine();
             * tEngine.LoadTable("STOCK");
             * tEngine.LoadTable("STKLEVEL");
             * tEngine.LoadTable("TILLCAT");
             * //Application.Run(new frmSearchForItemV2(ref tEngine));
             * //Application.Run(new frmCategorySelect(ref tEngine));
             */
        }