private void buttonSaveEmployee_Click(object sender, EventArgs e) { if ((textBoxISBN.Text == "") || (textBoxTitle.Text == "") || (textBoxAuthor.Text == "") || (textBoxYearPublished.Text == "") || (textBoxQOH.Text == "") || (textBoxUnitPrice.Text == "")) { MessageBox.Show("You have to fill out all the boxes, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { Books book = new Books(); book.ISBN = Convert.ToInt32(textBoxISBN.Text); book.Title = textBoxTitle.Text; book.BookAuthor = textBoxAuthor.Text; book.BookYearPublished = textBoxYearPublished.Text; book.BookQOH = Convert.ToInt32(textBoxQOH.Text); book.BookUnitePrice = Convert.ToInt32(textBoxUnitPrice.Text); BooksDA.Save(book); ClearAll2(); } }
private void buttonBooSave_Click(object sender, EventArgs e) { //BOOK ISBN Validators if (!Validator.IsEmpty(textBoxBooISBN)) { MessageBox.Show("The Book have to have a ISBN code.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxBooISBN.Clear(); textBoxBooISBN.Focus(); return; } if (!Validator.IsEmpty(textBoxBooQOH)) { MessageBox.Show("The Book must have a quantity!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxBooQOH.Clear(); textBoxBooQOH.Focus(); return; } if (!Validator.IsValidId(textBoxBooISBN.Text, 4)) { MessageBox.Show("Book must have a 4 digits ISBN Code.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxBooISBN.Clear(); textBoxBooISBN.Focus(); return; } if (!Validator.IsValidQOH(textBoxBooQOH.Text)) { MessageBox.Show("Quantity must be a integer number.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxBooQOH.Clear(); textBoxBooQOH.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 Books aBook = new Books(); aBook.ISBN = Convert.ToInt32(textBoxBooISBN.Text); aBook.title = textBoxBooTitle.Text; aBook.author = comboBoxBooAuthor.Text; aBook.yearPublished = textBoxBooYPublished.Text; aBook.unitPrice = Convert.ToDecimal(textBoxBooPrice.Text); aBook.QOH = Convert.ToInt32(textBoxBooQOH.Text); aBook.publisher = comboBoxBooSuplier.Text; BooksDA.Save(aBook); ClearAllBoo(); UpdateComboBoxes(); buttonBooList.PerformClick(); }