Exemple #1
0
        private void TextBoxID_KeyDown(object sender, KeyEventArgs e)
        {
            try {
                // check for user or scanner 'pressing' enter
                if (e.KeyData.ToString().Equals("Return"))
                {
                    // don't let the textbox handle it further
                    e.SuppressKeyPress = true;

                    // don't allow changing the card id
                    TextBoxCardID.ReadOnly = true;

                    // notify user if card wasn't found
                    if (!(Helper.EmployeeExists(TextBoxCardID.Text, sql)))
                    {
                        MessageBox.Show(this, "The card you entered wasn't found. Are you sure you typed it in correctly?", "Card Not Found!", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        // enable editing of card id
                        TextBoxCardID.ReadOnly = false;
                        TextBoxCardID.Focus();
                        TextBoxCardID.SelectAll();
                    }
                    else
                    {
                        // move on to next control
                        DateTimePickerIn.Focus();
                    }
                }
            } catch (Exception err) {
                TextBoxCardID.ReadOnly = false;
                MessageBox.Show(this, "There was an error while trying to make sure the card was recognized.\n\n" + err.Message, "Load Card List Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
        private void ButtonReset_Click(object sender, EventArgs e)
        {
            // make sure nothing needs to be saved
            if (ButtonSave.Enabled)
            {
                // switch on user choice
                switch (MessageBox.Show(this, "There are unsaved changes. Would you like to save them before resetting this window?", "Unsaved Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk))
                {
                case DialogResult.Yes:
                    ButtonSave_Click(sender, e);
                    break;

                case DialogResult.Cancel: return;
                }
            }

            // reset gui
            TextBoxCardID.Clear();
            TextBoxCardID.Enabled       = true;
            ComboBoxMonth.SelectedIndex = DateTime.Today.Month - 1;
            ComboBoxMonth.Enabled       = true;
            NumericUpDownYear.Value     = (decimal)DateTime.Today.Year;
            NumericUpDownYear.Enabled   = true;
            DataGridViewTimes.ClearSelection();
            DataGridViewTimes.RowStateChanged -= new System.Windows.Forms.DataGridViewRowStateChangedEventHandler(DataGridViewTimes_RowStateChanged);
            DataGridViewTimes.DataSource       = null;
            DisableUI();
            DisableTimePickers();
            ButtonLoad.Enabled = true;
        }
Exemple #3
0
 private void ResetGui()
 {
     TextBoxCardID.Enabled     = true;
     ComboBoxMonth.Enabled     = true;
     NumericUpDownYear.Enabled = true;
     ButtonGenerate.Enabled    = true;
     ButtonGenerate.Text       = "Generate Time Sheet";
     TextBoxCardID.Focus();
     TextBoxCardID.SelectAll();
 }
Exemple #4
0
        private void ButtonAdd_Click(object sender, EventArgs e)
        {
            // check for card id being validated
            if (!TextBoxCardID.ReadOnly)
            {
                // validate card
                try {
                    // don't allow changing the card id
                    TextBoxCardID.ReadOnly = true;

                    // confirm card was found
                    if (!(Helper.EmployeeExists(TextBoxCardID.Text, sql)))
                    {
                        // display notification
                        MessageBox.Show(this, "The card you entered wasn't found. Are you sure you typed it in correctly?", "Card Not Found!", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        // enable editing of card id
                        TextBoxCardID.ReadOnly = false;
                        TextBoxCardID.Focus();
                        TextBoxCardID.SelectAll();

                        // prevent further processing
                        return;
                    }
                } catch (Exception err) {
                    // enable editing of card id
                    TextBoxCardID.ReadOnly = false;

                    // display error
                    MessageBox.Show(this, "There was an error while trying to make sure the card was recognized.\n\n" + err.Message, "Load Card List Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    // prevent further processing
                    return;
                }
            }

            try {
                DateTimePickerIn.Value  = datePicker.Value.Date + DateTimePickerIn.Value.TimeOfDay;
                DateTimePickerOut.Value = datePicker.Value.Date + DateTimePickerOut.Value.TimeOfDay;

                Dictionary <String, String> data = new Dictionary <String, String>();
                data.Add("employeeID", TextBoxCardID.Text.Trim());
                data.Add("clockIn", DateTimePickerIn.Value.ToString(StringFormats.sqlTimeFormat));
                data.Add("clockOut", DateTimePickerOut.Value.ToString(StringFormats.sqlTimeFormat));

                sql.Insert("timeStamps", data);
            } catch (Exception err) {
                MessageBox.Show(this, "There was an error while trying to save your additional time to your time log file.\n\n" + err.Message, "Add Time Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // close form
            Close();
        }
Exemple #5
0
        private void ButtonRemove_Click(object sender, EventArgs e)
        {
            // vars
            bool found = false;

            dt = sql.GetDataTable("select * from employees where employeeID=" + TextBoxCardID.Text.Trim() + ";");

            // check if this is the card we're looking for
            if (dt.Rows.Count == 1)
            {
                // mark as found
                found = true;

                // confirm deletion of card
                if (MessageBox.Show(this, "Are you sure you want to delete " + dt.Rows[0].ItemArray[1].ToString() + "'s card?\n(Card/Student ID: " + dt.Rows[0].ItemArray[0].ToString() + ")", "Confirm Card Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                {
                    // write to file
                    try {
                        sql.Delete("employees", String.Format("employeeID = {0}", dt.Rows[0].ItemArray[0].ToString()));

                        if (CheckBoxDelTimeLog.Checked == true)
                        {
                            sql.Delete("timeStamps", String.Format("employeeID = {0}", dt.Rows[0].ItemArray[0].ToString()));
                        }
                    } catch (Exception err) {
                        MessageBox.Show(this, "There was an error while trying to remove the card.\n\n" + err.Message, "File Deletion Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }

            // notify user if card wasn't found
            if (!found)
            {
                MessageBox.Show(this, "The card you entered wasn't found. Are you sure you typed it in correctly?", "Card Not Found!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // reset text box
            TextBoxCardID.Clear();
            TextBoxCardID.Focus();
        }
        private void TextBoxCardID_KeyDown(object sender, KeyEventArgs e)
        {
            // vars
            bool found = false;

            // check for user or scanner 'pressing' enter
            if (e.KeyData.ToString().Equals("Return"))
            {
                // don't let the textbox handle it further
                e.SuppressKeyPress = true;

                // don't allow changing the card id
                TextBoxCardID.ReadOnly = true;

                dt = sql.GetDataTable("select * from employees where employeeID=" + TextBoxCardID.Text.Trim() + ";");

                // check if this is the card we're looking for
                if (dt.Rows.Count == 1)
                {
                    // make note of card's position
                    found = true;

                    // enable editing and saving
                    TextBoxFirstName.Enabled    = true;
                    TextBoxLastName.Enabled     = true;
                    TextBoxMI.Enabled           = true;
                    NumericUpDownHrRate.Enabled = true;
                    RadioButtonFWS.Enabled      = true;
                    RadioButtonSWS.Enabled      = true;
                    RadioButtonMST.Enabled      = true;
                    RadioButtonHED.Enabled      = true;
                    RadioButtonHelp.Enabled     = true;
                    RadioButtonTutor1.Enabled   = true;
                    RadioButtonTutor2.Enabled   = true;
                    RadioButtonTANF.Enabled     = true;
                    ButtonSave.Enabled          = true;

                    try {
                        // first name
                        TextBoxFirstName.Text = dt.Rows[0].ItemArray[1].ToString();

                        // last name
                        TextBoxLastName.Text = dt.Rows[0].ItemArray[2].ToString();

                        // middle initial
                        TextBoxMI.Text = dt.Rows[0].ItemArray[3].ToString();

                        // hourly rate
                        NumericUpDownHrRate.Value = Decimal.Parse(dt.Rows[0].ItemArray[4].ToString());

                        // position type
                        switch (dt.Rows[0].ItemArray[5].ToString())
                        {
                        case "FWS":
                            RadioButtonFWS.Checked = true;
                            break;

                        case "SWS":
                            RadioButtonSWS.Checked = true;
                            break;

                        case "MST":
                            RadioButtonMST.Checked = true;
                            break;

                        case "HED":
                            RadioButtonHED.Checked = true;
                            break;

                        case "Help":
                            RadioButtonHelp.Checked = true;
                            break;

                        case "Tutor1":
                            RadioButtonTutor1.Checked = true;
                            break;

                        case "Tutor2":
                            RadioButtonTutor2.Checked = true;
                            break;

                        case "TANF":
                            RadioButtonTANF.Checked = true;
                            break;
                        }

                        // automatically go to the next text box
                        TextBoxFirstName.Focus();
                    } catch (Exception err) {
                        MessageBox.Show(this, "There was an error while trying to load your info.\nWas someone playing with the database files?\n\n" + err.Message, "Clocked Time Calculation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                // notify user if card wasn't found
                if (!found)
                {
                    MessageBox.Show(this, "The card you entered wasn't found. Are you sure you typed it in correctly?", "Card Not Found!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TextBoxCardID.Clear();
                    TextBoxCardID.ReadOnly = false;
                    TextBoxCardID.Focus();
                }
            }
        }