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