private void buttonListauthor_Click(object sender, EventArgs e) { listViewAuthor.Items.Clear(); AuthorDA.ListAuthor(listViewAuthor); }
private void buttonUpdateauthor_Click(object sender, EventArgs e) { if ((textBoxFirstName.Text == "") || (textBoxLastName.Text == "") || (textBoxEmail.Text == "")) { MessageBox.Show("Please fill all the fields ", "Missing Data"); textBoxNamePublisher.Clear(); textBoxNamePublisher.Focus(); return; } else { Author auth = new Author(); auth.AuthorID = Convert.ToInt32(textBoxAuthorID.Text); auth.FName = textBoxFirstName.Text; auth.LName = textBoxLastName.Text; auth.Email = textBoxEmail.Text; DialogResult ans = MessageBox.Show("Do you really want to update this author?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (ans == DialogResult.Yes) { AuthorDA.Update(auth); MessageBox.Show("author record has been updated successfully", "Confirmation"); } textBoxAuthorID.Enabled = true; ClearAll3(); } }
//Change the author ISBN after choosing an Author from the Combobox private void comboBoxBkAuthor_SelectedIndexChanged(object sender, EventArgs e) { string line = comboBoxBkAuthor.Text; string[] lName = line.Split(','); textBoxBkAuthorID.Text = AuthorDA.SearchLast(lName[0]).AutID.ToString(); }
//Update private void buttonAutUpd_Click(object sender, EventArgs e) { AuthorDA.Update(createAuthor()); AuthorDA.ListAuthors(listViewAuthor); UpdateComboBoxes(); }
//Add private void buttonAutAdd_Click(object sender, EventArgs e) { Validator checker = new Validator(); if (checker.isValidID(textBoxAutID, 5) && checker.isValidName(textBoxautFName, "First") && checker.isValidName(textBoxAutLName, "Last")) { AuthorDA.Save(createAuthor()); UpdateComboBoxes(); } }
private void buttonSearcherAuthor_Click(object sender, EventArgs e) { int choice = comboBoxAuthor.SelectedIndex; switch (choice) { case -1: MessageBox.Show("Please select the search option"); break; case 0: Author autho = AuthorDA.Search(Convert.ToInt32(textBoxInformationauthor.Text)); if (autho != null) { textBoxAuthorID.Text = (autho.AuthorID).ToString(); textBoxFirstName.Text = autho.FName; textBoxLastName.Text = autho.LName; textBoxEmail.Text = autho.Email; textBoxAuthorID.Enabled = false; } else { MessageBox.Show("Author not Found!"); textBoxInformationauthor.Clear(); textBoxInformationauthor.Focus(); } break; case 1: Author auth = AuthorDA.Searchemail(textBoxInformationauthor.Text); if (auth != null) { textBoxAuthorID.Text = (auth.AuthorID).ToString(); textBoxFirstName.Text = auth.FName; textBoxLastName.Text = auth.LName; textBoxEmail.Text = auth.Email; textBoxAuthorID.Enabled = false; } else { MessageBox.Show("Email not Found!"); textBoxInformationauthor.Clear(); textBoxInformationauthor.Focus(); } break; default: break; } }
private void buttonDeleteAuthor_Click(object sender, EventArgs e) { if (IsValidAuthorData()) { DialogResult ans = MessageBox.Show("Do you really want to delete this Author?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (ans == DialogResult.Yes) { AuthorDA.Delete(Convert.ToInt32(textBoxAuthorID.Text)); MessageBox.Show("Author record has been deleted successfully", "Confirmation"); ClearAll(); textBoxAuthorID.Enabled = true; } } }
//Create object Book private Book createBook() { Book abook = new Book(); abook.BkISBN = Convert.ToInt64(textBoxBkISBN.Text); abook.BkTitle = textBoxBktitle.Text; abook.BkQOH = Convert.ToInt32(textBoxBkQOH.Text); abook.BkDate = dateTimePickerBook.Value; abook.BkAuthor = AuthorDA.SearchID(Convert.ToInt32(textBoxBkAuthorID.Text)); abook.BkCategory = textBoxBkCategory.Text; abook.BkUnitPrice = Convert.ToDecimal(textBoxBkUP.Text); abook.BkPublisher = comboBoxBkPub.Text; return(abook); }
private void buttonAddAuthor_Click(object sender, EventArgs e) { if (Validator.IsValidID(textBoxAuthorId)) { Author author = new Author(); author.AuthorId = Convert.ToInt32(textBoxAuthorId.Text); author.firstName = textBoxFirstName.Text; author.lastName = textBoxLastName.Text; listAuthor.Add(author); AuthorDA.Save(author); buttonListAuthor.Enabled = true; ClearAll(); } }
private void btn_Save_Click(object sender, EventArgs e) { if ((Validation.IsValidID(txt_AuID))) { Author auth = new Author(); auth.AuthorID = Convert.ToInt32(txt_AuID.Text); auth.FirstName = txt_fName.Text; auth.LastName = txt_lName.Text; auth.Email = txt_email.Text; AuthorDA.Save(auth); ClearAll(); } }
//Delete private void buttonAutDel_Click(object sender, EventArgs e) { DialogResult ans = MessageBox.Show("Are you sure you want to delete the Author information?", "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (ans == DialogResult.Yes) { if (BookDA.SearchAuthor(Convert.ToInt32(textBoxAutID.Text)) != null) { MessageBox.Show("This author has one or more books registered in the inventory, please be sure that there are no books by this author before deleting it!", "ALERT!"); return; } AuthorDA.Delete(Convert.ToInt32(textBoxAutID.Text)); AuthorDA.ListAuthors(listViewAuthor); UpdateComboBoxes(); } }
private void buttonSave2_Click(object sender, EventArgs e) { if ((textBoxAuthorID.Text == "") || (textBoxFirstName.Text == "") || (textBoxLastName.Text == "") || (textBoxEmail.Text == "")) { MessageBox.Show("You have to fill out all the boxes, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Author auth = new Author(); auth.AuthorID = Convert.ToInt32(textBoxAuthorID.Text); auth.FName = textBoxFirstName.Text; auth.LName = textBoxLastName.Text; auth.Email = textBoxEmail.Text; AuthorDA.Save(auth); } ClearAll3(); }
//Enable the buttons delete and update in case of a valid entered ID private void textBoxAutID_TextChanged(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxAutID.Text)) { buttonAutDel.Enabled = false; buttonAutUpd.Enabled = false; return; } if (AuthorDA.SearchID(Convert.ToInt32(textBoxAutID.Text)) != null) { buttonAutDel.Enabled = true; buttonAutUpd.Enabled = true; return; } buttonAutDel.Enabled = false; buttonAutUpd.Enabled = false; }
//Search private void buttonAutSearch_Click(object sender, EventArgs e) { Author aAuthor = new Author(); if (!string.IsNullOrEmpty(textBoxAutSearch.Text)) { switch (comboBoxAutSearch.SelectedIndex) { case -1: MessageBox.Show("Please select a valid search option!"); return; case 0: int tempId; if (!int.TryParse(textBoxAutSearch.Text, out tempId)) { MessageBox.Show("Please enter a valid term to be searched.", "No search information!"); return; } aAuthor = AuthorDA.SearchID(Convert.ToInt32(textBoxAutSearch.Text)); break; case 1: aAuthor = AuthorDA.SearchFirst(textBoxAutSearch.Text); break; case 2: aAuthor = AuthorDA.SearchLast(textBoxAutSearch.Text); break; } if (aAuthor == null) { MessageBox.Show("Author not found!", "Not found!"); textBoxAutSearch.Clear(); textBoxAutSearch.Focus(); return; } AuthorDA.ListSearchResult(aAuthor, listViewAuthor); return; } MessageBox.Show("Please enter a valid term to be searched.", "No search information!"); return; }
private void btn_Search_Click(object sender, EventArgs e) { Author cust = AuthorDA.Search(Convert.ToInt32(txt_input.Text)); if (cust != null) { txt_AuID.Text = (cust.AuthorID).ToString(); txt_fName.Text = (cust.FirstName); txt_lName.Text = cust.LastName; txt_email.Text = cust.Email; } else { MessageBox.Show("Author not Found"); txt_input.Clear(); txt_input.Focus(); } }
private void buttonUpdateAuthor_Click(object sender, EventArgs e) { if (IsValidAuthorData()) { Author author = new Author(); author.AuthorID = Convert.ToInt32(textBoxAuthorID.Text); author.FirstName = textBoxFirstNameAuthor.Text; author.LastName = textBoxLastNameAuthor.Text; DialogResult ans = MessageBox.Show("Do you really want to update this Employee?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (ans == DialogResult.Yes) { AuthorDA.Update(author); MessageBox.Show("Author record has been updated successfully", "Confirmation"); ClearAll(); textBoxAuthorID.Enabled = true; } } }
private void buttonSearchAuthor_Click(object sender, EventArgs e) { Author author = AuthorDA.Search(Convert.ToInt32(textBoxSearch.Text)); if (author != null) { textBoxAuthorId.Text = (author.AuthorId).ToString(); textBoxFirstName.Text = author.firstName; textBoxLastName.Text = author.lastName; } else { MessageBox.Show("Author not Found!"); textBoxSearch.Clear(); textBoxSearch.Focus(); } }
private void buttonSearchAuthorsoftware_Click(object sender, EventArgs e) { int choice = comboBoxsearchauthor.SelectedIndex; switch (choice) { case -1: MessageBox.Show("Please select the search option"); break; case 0: Author autho = AuthorDA.Search(Convert.ToInt32(textBoxInformationauthor.Text)); if (autho != null) { textBoxAuthor.Text = autho.FName; } else { MessageBox.Show("Author not Found!"); textBox1.Clear(); textBox1.Focus(); } break; case 1: Author auth = AuthorDA.Searchemail(textBoxInformationauthor.Text); if (auth != null) { textBoxAuthor.Text = auth.FName; } else { MessageBox.Show("Email not Found!"); textBox1.Clear(); textBox1.Focus(); } break; default: break; } }
private void buttonSearchAuthor_Click(object sender, EventArgs e) { { int choice = comboBoxAuthorInfo.SelectedIndex; switch (choice) { case -1: // The user didn't select any search option MessageBox.Show("Please select the search option"); break; case 0: if (textBoxAuthorInfo.Text == "") { MessageBox.Show("You have to enter Author ID, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (Validation.IsInteger(textBoxAuthorInfo)) { Author author = AuthorDA.Search(Convert.ToInt32(textBoxAuthorInfo.Text)); if (author != null) { textBoxAuthorID.Text = (author.AuthorID).ToString(); textBoxFirstNameAuthor.Text = author.FirstName; textBoxLastNameAuthor.Text = author.LastName; textBoxAuthorInfo.Clear(); textBoxAuthorID.Enabled = false; } else { MessageBox.Show("Author not found, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxInfoPublisher.Clear(); textBoxInfoPublisher.Focus(); } } } break; default: break; } } }
private void buttonSaveAuthor_Click(object sender, EventArgs e) { List <Author> listA = AuthorDA.ListAuthor(); if (IsValidAuthorData()) { if (!Validation.IsUniqueAuthorID(listA, Convert.ToInt32(textBoxAuthorID.Text))) { MessageBox.Show("Duplicate", "DUPLICATE Author ID"); textBoxAuthorID.Clear(); textBoxAuthorID.Focus(); return; } Author aAuthor = new Author(); aAuthor.AuthorID = Convert.ToInt32(textBoxAuthorID.Text); aAuthor.FirstName = textBoxFirstNameAuthor.Text; aAuthor.LastName = textBoxLastNameAuthor.Text; AuthorDA.Save(aAuthor); listA.Add(aAuthor); buttonListAuthor.Enabled = true; ClearAll(); } }
private void buttonDeleteAuthor_Click(object sender, EventArgs e) { AuthorDA.Delete(Convert.ToInt32(textBoxAuthorId.Text)); MessageBox.Show("Author has been deleted successfully from the database", "Confirmation"); }
//List private void buttonAutList_Click(object sender, EventArgs e) { AuthorDA.ListAuthors(listViewAuthor); }
private void btn_Delete_Click(object sender, EventArgs e) { AuthorDA.Delete(Convert.ToInt32(txt_input.Text)); MessageBox.Show("Student data has beeen deleted", "DONE"); }
private void buttonDeleteauthor_Click(object sender, EventArgs e) { AuthorDA.Delete(Convert.ToInt32(textBoxAuthorID.Text)); MessageBox.Show(" Author record has been deleted successfully", "Confirmation"); ClearAll3(); }
private void btn_List_Click(object sender, EventArgs e) { drp_Search.SelectedIndex = -1; AuthorDA.LstAuthor(View_Stud); }
private void Inventory_Control_Load(object sender, EventArgs e) { PublisherDA.Comboboxlist(comboBoxPublisherName); AuthorDA.Comboboxlist(comboBoxAuthorId); }