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 ResetGui()
 {
     TextBoxCardID.Enabled     = true;
     ComboBoxMonth.Enabled     = true;
     NumericUpDownYear.Enabled = true;
     ButtonGenerate.Enabled    = true;
     ButtonGenerate.Text       = "Generate Time Sheet";
     TextBoxCardID.Focus();
     TextBoxCardID.SelectAll();
 }
Exemple #3
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();
        }