private void buttonAutSave_Click(object sender, EventArgs e) { //Author ID Validators if (!Validator.IsEmpty(textBoxAutID)) { MessageBox.Show("Author ID field must have 4 digits.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxAutID.Clear(); textBoxAutID.Focus(); return; } if (!Validator.IsValidId(textBoxAutID.Text, 4)) { MessageBox.Show("Author ID field must have 4 digits.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxAutID.Clear(); textBoxAutID.Focus(); return; } //if (Validator.IsDuplicate(ListE, Convert.ToInt32(textBoxEmpID.Text))) //{ // MessageBox.Show("Employee Id already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // textBoxEmpID.Clear(); // textBoxEmpID.Focus(); // return; //} //Employee First and Last Name Validators //if (Validator.IsValidName(textBoxEmpFName)) //{ // MessageBox.Show("Employee First Name cannot have digits or white spaces!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // textBoxEmpFName.Clear(); // textBoxEmpFName.Focus(); // return; //} //if (Validator.IsValidName(textBoxEmpLName)) //{ // MessageBox.Show("Employee Last Name cannot have digits or white spaces!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // textBoxEmpLName.Clear(); // textBoxEmpLName.Focus(); // return; //} //Saving the data into the text file Authors aAuthor = new Authors(); aAuthor.authorId = Convert.ToInt32(textBoxAutID.Text); aAuthor.authorFName = textBoxAutFName.Text; aAuthor.authorLName = textBoxAutLName.Text; aAuthor.authorEmail = textBoxAutEmail.Text; AuthorsDA.Save(aAuthor); ClearAllAut(); buttonAutList.PerformClick(); UpdateComboBoxes(); }
private void buttonAutDelete_Click(object sender, EventArgs e) { int itemselected = Convert.ToInt32(textBoxAutID.Text); AuthorsDA.Delete(itemselected); MessageBox.Show("Author record has been deleted successfully", "Confirmation"); ClearAllAut(); UpdateComboBoxes(); buttonAutList.PerformClick(); }
private void UpdateComboBoxes() { comboBoxOrdClient.Items.Clear(); comboBoxOrdProduct.Items.Clear(); comboBoxBooAuthor.Items.Clear(); comboBoxOrdClient.Items.Clear(); comboBoxOrdProduct.Items.Clear(); ClientsDA.BoxClients(comboBoxOrdClient); BooksDA.BoxProducts(comboBoxOrdProduct); AuthorsDA.BoxAuthor(comboBoxBooAuthor); //OrderDA.bookSelection(comboBoxOrdISBN); }
private void buttonAutUpdate_Click(object sender, EventArgs e) { Authors Aut = new Authors(); Aut.authorId = Convert.ToInt32(textBoxAutID.Text); Aut.authorFName = textBoxAutFName.Text; Aut.authorLName = textBoxAutLName.Text; Aut.authorEmail = textBoxAutEmail.Text; DialogResult ans = MessageBox.Show("Do you really want to update this Author?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (ans == DialogResult.Yes) { AuthorsDA.Update(Aut); MessageBox.Show("Author record has been updated successfully", "Confirmation"); ClearAllAut(); UpdateComboBoxes(); buttonAutList.PerformClick(); } }
private void button20_Click(object sender, EventArgs e) { int choice = comboBoxAutSearch.SelectedIndex; switch (choice) { case -1: MessageBox.Show("Please select the search option"); break; case 0: //Search by ID Authors Aut = AuthorsDA.Search(Convert.ToInt32(textBoxAutSearch.Text)); if (Aut != null) { textBoxAutID.Text = (Aut.authorId).ToString(); textBoxAutFName.Text = Aut.authorLName; textBoxAutLName.Text = Aut.authorLName; textBoxAutEmail.Text = Aut.authorEmail; buttonAutDelete.Enabled = true; buttonAutUpdate.Enabled = true; } else { MessageBox.Show("Author not Found!"); textBoxAutSearch.Clear(); textBoxAutSearch.Focus(); } break; case 1: //Search by First Name Authors AutFName = AuthorsDA.SearchByFName(textBoxAutSearch.Text); if (AutFName != null) { textBoxAutID.Text = (AutFName.authorId).ToString(); textBoxAutFName.Text = AutFName.authorFName; textBoxAutLName.Text = AutFName.authorLName; textBoxAutEmail.Text = AutFName.authorEmail; buttonAutDelete.Enabled = true; buttonAutUpdate.Enabled = true; } else { MessageBox.Show("Author not Found!"); textBoxAutSearch.Clear(); textBoxAutSearch.Focus(); } break; case 2: //Search by Last Name Authors AutLName = AuthorsDA.SearchByLName(textBoxAutSearch.Text); if (AutLName != null) { textBoxAutID.Text = (AutLName.authorId).ToString(); textBoxAutFName.Text = AutLName.authorFName; textBoxAutLName.Text = AutLName.authorLName; textBoxAutEmail.Text = AutLName.authorEmail; buttonAutDelete.Enabled = true; buttonAutUpdate.Enabled = true; } else { MessageBox.Show("Author not Found!"); textBoxAutSearch.Clear(); textBoxAutSearch.Focus(); } break; default: break; } }
private void buttonAutList_Click(object sender, EventArgs e) { listViewEmp.Items.Clear(); AuthorsDA.ListAuthors(listViewAut); }