public FormMain()
        {
            // vars
            bool goAgain;

            // get list of invalid chars for system
            invalidChars = Path.GetInvalidFileNameChars();

            // check for existence of required iText DLL
            if (!File.Exists("itextsharp.dll"))
            {
                do
                {
                    // (re)set vars
                    goAgain = false;

                    try
                    {
                        // extract file
                        File.WriteAllBytes("itextsharp.dll", Properties.Resources.itextsharp);
                    }
                    catch (Exception err)
                    {
                        // ask user what they want to do
                        switch (MessageBox.Show(this, "There was an error while trying to extract the required file for generating the time sheet.\n\n" + err.Message + "\n\nAbort will close this application. Ignore will temporarily disable the option to make the time sheets.", "Extract File Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error))
                        {
                            // exit the app
                            case DialogResult.Abort: this.Close();
                                break;
                            // try extracting the file again
                            case DialogResult.Retry: goAgain = true;
                                break;
                            // disable option to generate time sheets and add the reason why
                            case DialogResult.Ignore: ToolStripMenuItemGenerate.Enabled = false;
                                ToolStripMenuItemGenerate.ToolTipText = "The required file isn't available.";
                                break;
                        }
                    }
                } while (goAgain);
            }

            // create gui
            InitializeComponent();

            //Start the clock
            //System.Windows.Forms.Timer clockTimer = new System.Windows.Forms.Timer();

            if (sql.GetDataTable("select employeeID from employees;").Rows.Count == 0)
            {
                var result = MessageBox.Show(this, "It looks like there aren't any registered cards yet. You can add a card by pressing Alt + N on the keyboard, or by clicking on the 'Add new card' option from the 'Manage Cards' menu."
                    + "\n\n Would you like to check to attemp importing an existing database?", "No Registered Cards", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);

                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    ImportCardList cardList = new ImportCardList("cardList");
                }
            }
            else
                autoClockOut();
        }
Esempio n. 2
0
        public FormMain()
        {
            // vars
            bool goAgain;

            // check for existence of required iText DLL
            if (!File.Exists("itextsharp.dll"))
            {
                do
                {
                    // (re)set vars
                    goAgain = false;

                    try {
                        // extract file
                        File.WriteAllBytes("itextsharp.dll", Properties.Resources.itextsharp);
                    } catch (Exception err) {
                        // ask user what they want to do
                        switch (MessageBox.Show(this, "There was an error while trying to extract the required file for generating the time sheet.\n\n" + err.Message + "\n\nAbort will close this application. Ignore will temporarily disable the option to make the time sheets.", "Extract File Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error))
                        {
                        // exit the app
                        case DialogResult.Abort:
                            Close();
                            break;

                        // try extracting the file again
                        case DialogResult.Retry:
                            goAgain = true;
                            break;

                        // disable option to generate time sheets and add the reason why
                        case DialogResult.Ignore:
                            ToolStripMenuItemGenerate.Enabled     = false;
                            ToolStripMenuItemGenerate.ToolTipText = "The required file isn't available.";
                            break;
                        }
                    }
                } while (goAgain);
            }

            // create gui
            InitializeComponent();

            //Start the clock
            //System.Windows.Forms.Timer clockTimer = new System.Windows.Forms.Timer();


            if (sql.GetDataTable("select employeeID from employees;").Rows.Count == 0)
            {
                var result = MessageBox.Show(this, "It looks like there aren't any registered cards yet. You can add a card by pressing Alt + N on the keyboard, or by clicking on the 'Add new card' option from the 'Manage Cards' menu."
                                             + "\n\n Would you like to check to attemp importing an existing database?", "No Registered Cards", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);

                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    ImportCardList cardList = new ImportCardList("cardList");
                }
            }
            else
            {
                autoClockOut();
            }
        }