private void deleteButton_Click(object sender, EventArgs e) { // Check for entry if (deleteTextBox.Text == "") { MessageBox.Show("Please enter a number."); } else { CheckDigitClass checkDigit = new CheckDigitClass(); bool digit = checkDigit.digitOnly(deleteTextBox.Text); if (digit == true) { try { int deleteItem = int.Parse(deleteTextBox.Text); string query = "delete from Chromebook_Information where ID=" + deleteItem + ""; SQLDatabaseCommands(query); MessageBox.Show("All data was deleted for Chromebook #" + deleteTextBox.Text + "."); deleteTextBox.Text = ""; } catch (Exception ex) { // Gather information to send to bug report string page = "Chromebook"; string button = "Delete"; string exception = ex.ToString(); BugSplatForm bugSplat = new BugSplatForm(page, button, exception); bugSplat.ShowDialog(); this.Close(); } } else { MessageBox.Show("Please input numbers only."); } } }
// Delete all data of an item with entered tag number private void removeButton_Click(object sender, EventArgs e) { if (removeTextBox.Text == "") { MessageBox.Show("Please input a tag number."); } else { CheckDigitClass checkDigit = new CheckDigitClass(); bool removeDigit = checkDigit.digitOnly(removeTextBox.Text); if (removeDigit == true) { try { int removeItem = int.Parse(removeTextBox.Text); string query = "delete from Main_Inventory where Tag=" + removeItem + ""; ModifySQLData(query); MessageBox.Show("All data was deleted for item tag #" + removeTextBox.Text + "."); } catch (Exception ex) { // Get and send information to bug report string page = "Search"; string button = "Remove"; string exception = ex.ToString(); BugSplatForm bugSplat = new BugSplatForm(page, button, exception); bugSplat.ShowDialog(); this.Close(); } } else { MessageBox.Show("Tag number must be numbers only."); } } }
// Search for tag information private void searchButton_Click(object sender, EventArgs e) { if (searchTextBox.Text != "") { // Check to see if digit then search for tag information CheckDigitClass checkDigit = new CheckDigitClass(); bool searchDigit = checkDigit.digitOnly(searchTextBox.Text); if (searchDigit == true) { try { int search = int.Parse(searchTextBox.Text); string query = "select * from Main_Inventory where Tag=" + search + ""; SelectSQLData(query); } catch (Exception ex) { // Get and send information to bug report string page = "Search"; string button = "Search"; string exception = ex.ToString(); BugSplatForm bugSplat = new BugSplatForm(page, button, exception); bugSplat.ShowDialog(); this.Close(); } } else { MessageBox.Show("Please input numbers only."); } } else { MessageBox.Show("Please input a tag number."); } }
private void loginButton_Click(object sender, EventArgs e) { string userName = nameTextBox.Text.ToUpper().Trim(); string privateKey = privateKeyTextBox.Text.ToUpper(); if (userName == "" || privateKey == "") { MessageBox.Show("You must enter a name and private key."); } else { try { CheckDigitClass checkKey = new CheckDigitClass(); bool privateKeyIsDigit = checkKey.digitOnly(privateKey); if (!privateKeyIsDigit) { MessageBox.Show("Your private key must be a four digit number."); return; } bool correctName = CheckUsername(userName); bool correctKey = CheckPrivateKey(privateKey); if (correctName != true && correctKey != true) { MessageBox.Show("Full name or key does not exist. Please try again."); return; } else { bool registeredUser = ConfirmUser(userName, privateKey); if (registeredUser == false) { MessageBox.Show("Name and key does not match. Please try again."); return; } else { this.Hide(); string user = userLabel.Text; MasterKeyPasswordPage passwordPage = new MasterKeyPasswordPage(user, userName, privateKey); passwordPage.ShowDialog(); this.Close(); } } } catch (Exception ex) { MessageBox.Show("Login is disabled due to an unknown error. Please try again later or contact your administrator if the problem persists."); // Send bug report string page = "Master Key"; string button = "Login"; string exception = ex.ToString(); BugSplatForm bugSplat = new BugSplatForm(page, button, exception); bugSplat.ShowDialog(); //this.Close(); } } }
private void addButton_Click(object sender, EventArgs e) { try { // Check to see if any slots are blank if (addTypeComboBox.Text != "" && addMakeTextBox.Text != "" && addModelTextBox.Text != "" && addTagTextBox.Text != "" && addLocationComboBox.Text != "" && addStatusComboBox.Text != "") { // Check to see if type matches with one that is required if (addTypeComboBox.Text == "DESKTOP" || addTypeComboBox.Text == "LAPTOP" || addTypeComboBox.Text == "MONITOR" || addTypeComboBox.Text == "PRINTER" || addTypeComboBox.Text == "SMARTBOARD" || addTypeComboBox.Text == "PROJECTOR" || addTypeComboBox.Text == "TABLET" || addTypeComboBox.Text == "ACCESSORIES" || addTypeComboBox.Text == "WEBBER") { // Hide type wrong label typeWrongLabel.Visible = false; warningLabel.Visible = false; if (addStatusComboBox.Text == "ACTIVE" || addStatusComboBox.Text == "INACTIVE" || addStatusComboBox.Text == "REPAIR" || addStatusComboBox.Text == "SURPLUS" || addStatusComboBox.Text == "UNKNOWN") { // Hide status wrong label statusWrongLabel.Visible = false; warning2Label.Visible = false; // Check tag for all digits CheckDigitClass checkDigit = new CheckDigitClass(); bool digit = checkDigit.digitOnly(addTagTextBox.Text); if (digit == true) { // Write the information into the database connection.Open(); string type = addTypeComboBox.Text.ToUpper(); string make = addMakeTextBox.Text.ToUpper(); string model = addModelTextBox.Text.ToUpper(); int tag = int.Parse(addTagTextBox.Text); string location = addLocationComboBox.Text.ToUpper(); string status = addStatusComboBox.Text.ToUpper(); string date = DateTime.Now.ToString(); SqlCommand command = connection.CreateCommand(); command.CommandType = CommandType.Text; command.CommandText = "insert into Main_Inventory (Type,Make,Model,Tag,Location,Status,TimeUpdated) values('" + type + "','" + make + "','" + model + "'," + tag + ",'" + location + "','" + status + "','" + date + "')"; command.ExecuteNonQuery(); connection.Close(); MessageBox.Show("Item was successfully added!"); // Clear some fields if (saveCheckBox.Checked) { ClearLabels(); } else { ClearLabels(); ClearTextBoxes(); } } else { MessageBox.Show("WSD tag needs to be digits only."); } } else { statusWrongLabel.Visible = true; warning2Label.Visible = true; } } else { typeWrongLabel.Visible = true; warningLabel.Visible = true; } } else { MessageBox.Show("All fields are required."); } } catch (Exception ex) { // Send information to be recorded in bug report string page = "Add"; string button = "Add"; string exception = ex.ToString(); BugSplatForm bugSplat = new BugSplatForm(page, button, exception); bugSplat.ShowDialog(); this.Close(); } }
private void addButton_Click(object sender, EventArgs e) { try { // Verify to see if all fields are entered if (studentNameTextBox.Text != "" && studentEditTextBox.Text != "" && teacherNameTextBox.Text != "" && originalAddTextBox.Text != "" && statusComboBox.Text != "") { CheckDigitClass checkDigit = new CheckDigitClass(); // Check loan tag for digits only if (loanAddTextBox.Text != "") { bool loanDigit = checkDigit.digitOnly(loanAddTextBox.Text); if (loanDigit != true) { MessageBox.Show("Please enter numbers only for loan tag."); return; } } // Check original tag for digits only bool originalDigit = checkDigit.digitOnly(originalAddTextBox.Text); bool lunchDigit = checkDigit.digitOnly(studentEditTextBox.Text); if (originalDigit == true && lunchDigit == true) { string fullName = studentNameTextBox.Text.ToUpper(); int lunchID = int.Parse(studentEditTextBox.Text); string teacherName = teacherNameTextBox.Text.ToUpper(); int originalTag = int.Parse(originalAddTextBox.Text); string status = statusComboBox.Text.ToUpper(); int loanTag = 0; string status2 = ""; string billAmount = ""; string billDate = ""; string notes = ""; if (loanAddTextBox.Text == "") { loanTag = 0; } else { loanTag = int.Parse(loanAddTextBox.Text); } if (status2ComboBox.Text == "") { status2 = ""; } else { status2 = status2ComboBox.Text.ToUpper(); } if (billAmountTextBox.Text == "") { billAmount = ""; } else { billAmount = billAmountTextBox.Text; bool billDigit = checkDigit.digitOnly(billAmount); if (billDigit == false) { MessageBox.Show("Bill must be a number."); return; } } if (billDateTextBox.Text == "") { billDate = ""; } else { billDate = billDateTextBox.Text; } // Note textbox if (textBox1.Text == "") { notes = ""; } else { notes = textBox1.Text; } // Get current date and time of add string date = DateTime.Now.ToString(); // Insert data into table string query = "insert into Chromebook_Information (FullName,LunchID,TeacherName,OriginalTag,Status,LoanTag,LoanStatus,BillAmount,BillDate,Notes,LastUpdated) values('" + fullName + "'," + lunchID + ",'" + teacherName + "'," + originalTag + ",'" + status + "'," + loanTag + ",'" + status2 + "','" + billAmount + "','" + billDate + "','" + notes + "','" + date + "')"; SQLDatabaseCommands(query); MessageBox.Show("Chromebook was successfully added!"); clearAll(); } else { MessageBox.Show("Please enter numbers only for lunch ID and/or original tag."); } } else { MessageBox.Show("Please fill out all required fields."); } } catch (Exception ex) { // Gather and send information to the bug report string page = "Chromebook"; string button = "Add"; string exception = ex.ToString(); BugSplatForm bugSplat = new BugSplatForm(page, button, exception); bugSplat.ShowDialog(); this.Close(); } }
// Quick fill button private void getInfoButton_Click(object sender, EventArgs e) { if (idTextBox.Text == "") { MessageBox.Show("Please enter a number."); } else { CheckDigitClass checkDigit = new CheckDigitClass(); bool idDigit = checkDigit.digitOnly(idTextBox.Text); if (idDigit == true) { // Convert string to int int id = int.Parse(idTextBox.Text); try { connection.Open(); SqlCommand command = connection.CreateCommand(); command.CommandType = CommandType.Text; string query = "select * from Chromebook_Information where ID=" + id + ""; command.CommandText = query; SqlDataReader reader = command.ExecuteReader(); // Fill textboxes with corresponding information while (reader.Read()) { studentNameTextBox.Text = reader["FullName"].ToString(); studentEditTextBox.Text = reader["LunchID"].ToString(); teacherNameTextBox.Text = reader["TeacherName"].ToString(); originalAddTextBox.Text = reader["OriginalTag"].ToString(); statusComboBox.Text = reader["Status"].ToString(); loanAddTextBox.Text = reader["LoanTag"].ToString(); status2ComboBox.Text = reader["LoanStatus"].ToString(); billAmountTextBox.Text = reader["BillAmount"].ToString(); billDateTextBox.Text = reader["BillDate"].ToString(); textBox1.Text = reader["Notes"].ToString(); } connection.Close(); } catch (Exception ex) { // Get information for bug report string page = "Chromebook"; string button = "Quick Fill"; string exception = ex.ToString(); BugSplatForm bugSplat = new BugSplatForm(page, button, exception); bugSplat.ShowDialog(); this.Close(); } } else { MessageBox.Show("Please enter numbers only."); } } }
private void searchChromebookButton_Click(object sender, EventArgs e) { // Check to make sure something is entered if (searchComboBox.Text == "") { MessageBox.Show("Please fill out the box."); } else { // Check for radio button selection int i = 0; if (IDradioButton.Checked || tagRadioButton.Checked || statusRadioButton.Checked || billRadioButton.Checked) { i = 1; if (i == 1) { CheckDigitClass checkDigit = new CheckDigitClass(); // String user enter string searchString = searchComboBox.Text; bool yesDigit = false; // Check input if id radio button is checked if (IDradioButton.Checked) { yesDigit = checkDigit.digitOnly(searchString); if (yesDigit == false) { MessageBox.Show("Must input numbers only."); } else { i = 2; } } // Check input if tag radio button is checked else if (tagRadioButton.Checked) { yesDigit = checkDigit.digitOnly(searchString); if (yesDigit == false) { MessageBox.Show("Must input numbers only."); } else { i = 2; } } else if (statusRadioButton.Checked || billRadioButton.Checked) { i = 2; } else { MessageBox.Show("Please start over."); } if (i == 2) { try { string query; if (IDradioButton.Checked) { int lunchID = int.Parse(searchString); query = "select * from Chromebook_Information where LunchID=" + lunchID + ""; } else if (tagRadioButton.Checked) { int originalTag = int.Parse(searchString); query = "select * from Chromebook_Information where OriginalTag=" + originalTag + ""; } else if (statusRadioButton.Checked) { string status = searchString.ToUpper(); query = "select * from Chromebook_Information where Status='" + status + "'"; } else { string bill = searchString; query = "select * from Chromebook_Information where BillAmount='" + bill + "'"; } SelectDataDisplayOnGrid(query); } catch (Exception ex) { // Get and set information to bug report string page = "Chromebook"; string button = "Search"; string exception = ex.ToString(); BugSplatForm bugSplat = new BugSplatForm(page, button, exception); bugSplat.ShowDialog(); this.Close(); } } } } else { MessageBox.Show("Please select an option to search."); } } }
private void editButton_Click(object sender, EventArgs e) { // Make sure the id field is filled with numbers only CheckDigitClass checkDigit = new CheckDigitClass(); if (idTextBox.Text == "") { MessageBox.Show("Must have an ID."); return; } else { bool idNum = checkDigit.digitOnly(idTextBox.Text); if (idNum == false) { MessageBox.Show("ID must be a number."); return; } } int id = int.Parse(idTextBox.Text); try { // Verify to see if all fields are entered if (studentEditTextBox.Text != "" && originalAddTextBox.Text != "" && statusComboBox.Text != "") { // Check loan tag for digits only if (loanAddTextBox.Text != "") { bool loanDigit = checkDigit.digitOnly(loanAddTextBox.Text); if (loanDigit != true) { MessageBox.Show("Please enter numbers only for loan tag."); return; } } // Check lunch ID and original tag for digits only bool originalDigit = checkDigit.digitOnly(originalAddTextBox.Text); bool lunchDigit = checkDigit.digitOnly(studentEditTextBox.Text); if (billAmountTextBox.Text != "") { bool billAmountCheck = checkDigit.digitOnly(billAmountTextBox.Text); if (billAmountCheck == false) { MessageBox.Show("Bill amount must be a number."); return; } } if (originalDigit == true && lunchDigit == true) { int lunchID = int.Parse(studentEditTextBox.Text); int originalTag = int.Parse(originalAddTextBox.Text); string status = statusComboBox.Text.ToUpper(); int loanTag; string status2; float billAmount; string billDate; string notes; if (loanAddTextBox.Text == "") { loanTag = 0; } else { loanTag = int.Parse(loanAddTextBox.Text); } if (status2ComboBox.Text == "") { status2 = ""; } else { status2 = status2ComboBox.Text.ToUpper(); } if (billAmountTextBox.Text == "") { billAmount = 0; } else { billAmount = float.Parse(billAmountTextBox.Text); } if (billDateTextBox.Text == "") { billDate = ""; } else { billDate = billDateTextBox.Text; } // Note textbox if (textBox1.Text == "") { notes = ""; } else { notes = textBox1.Text; } string date = DateTime.Now.ToString(); // Update data in table string query = "update Chromebook_Information set OriginalTag=" + originalTag + ",Status='" + status + "',LoanTag=" + loanTag + ",LoanStatus='" + status2 + "',BillAmount=" + billAmount + ",BillDate='" + billDate + "',Notes='" + notes + "',LastUpdated='" + date + "' where ID= " + id + ""; SQLDatabaseCommands(query); MessageBox.Show("Chromebook was successfully updated."); } else { MessageBox.Show("Original tag and/or lunch ID must be digits only."); } } else { MessageBox.Show("Fill out all required fields."); } } catch (Exception ex) { // Gather information to send to bug report string page = "Chromebook"; string button = "Update"; string exception = ex.ToString(); BugSplatForm bugSplat = new BugSplatForm(page, button, exception); bugSplat.ShowDialog(); this.Close(); } }
// Get ticket number and find the information of the ticket private void checkButton_Click(object sender, EventArgs e) { string ticketNumber = ticketNumberTextBox.Text; if (ticketNumber == "") { MessageBox.Show("Please enter your ticket number."); } else { ticketNumber = ticketNumber.Trim(); CheckDigitClass checkDigit = new CheckDigitClass(); bool digit = checkDigit.digitOnly(ticketNumber); if (digit == true) { try { connection.Open(); // Which table to search for data SqlCommand command = connection.CreateCommand(); command.CommandType = CommandType.Text; string query = "select * from Help_Ticket"; command.CommandText = query; //List<string> idCheck = new List<string>(); string[] idCheck = new string[2000]; int i = 0; bool found = false; // Read the data SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { idCheck[i] = reader["ID"].ToString(); if (idCheck[i] == ticketNumber) { string status = reader["Status"].ToString(); string plannedFix = reader["PlannedFixDate"].ToString(); found = true; if (plannedFix != "") { statusLabel.Text = "Ticket #" + ticketNumber + " is currently " + status + ". Estimated day for ticket appointment is " + plannedFix + "."; } else { statusLabel.Text = "Ticket #" + ticketNumber + " is currently " + status + ". Estimated day for ticket appointment is not yet known."; } } i++; } connection.Close(); if (found == false) { MessageBox.Show("Ticket number was not found."); } } catch (Exception ex) { // Get info for bug report string page = "Ticket"; string button = "Check"; string exception = ex.ToString(); BugSplatForm bugSplat = new BugSplatForm(page, button, exception); bugSplat.ShowDialog(); this.Close(); } } else { MessageBox.Show("Ticket number must be digits only."); } } }
// Update location or status of item private void updateButton_Click(object sender, EventArgs e) { if (locationRadioButton.Checked && updateLocationComboBox.Text == "") { MessageBox.Show("Please enter location."); return; } else if (statusRadioButton.Checked && updateStatusComboBox.Text == "") { MessageBox.Show("Please enter status."); return; } if (updateTagTextBox.Text == "") { MessageBox.Show("Please enter a tag number."); } else { CheckDigitClass checkDigit = new CheckDigitClass(); bool tagDigit = checkDigit.digitOnly(updateTagTextBox.Text); if (tagDigit == true) { string checkedButton = ""; string tag = updateTagTextBox.Text; string date = DateTime.Now.ToString(); string query = ""; if (locationRadioButton.Checked) { checkedButton = "Location"; } else { checkedButton = "Status"; } if (checkedButton == "Location") { string location = updateLocationComboBox.Text; query = "update Main_Inventory set Location='" + location + "',TimeUpdated='" + date + "' where Tag=" + tag + ""; } else { string status = updateStatusComboBox.Text; query = "update Main_Inventory set Status='" + status + "',TimeUpdated='" + date + "' where Tag=" + tag + ""; } try { ModifySQLData(query); MessageBox.Show(checkedButton + " was updated for item tag #" + tag + "."); // Clear boxes updateTagTextBox.Text = ""; updateLocationComboBox.Text = ""; updateStatusComboBox.Text = ""; } catch (Exception ex) { // Get and send information to bug report string page = "Search"; string button = "Update"; string exception = ex.ToString(); BugSplatForm bugSplat = new BugSplatForm(page, button, exception); bugSplat.ShowDialog(); this.Close(); } } else { MessageBox.Show("Tag must be all digits."); } } }