private void buttonOrdUpdate_Click(object sender, EventArgs e) { if (!Validator.IsEmpty(textBoxOrdQuantity)) { MessageBox.Show("Orders must have a valid quantity.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxAutID.Clear(); textBoxAutID.Focus(); return; } Order aorder = createOrder(); Order xorder = OrderDA.SearchByNumber(Convert.ToInt32(textBoxOrdNumber.Text)); Books abook = BooksDA.SearchByTitle(comboBoxOrdProduct.Text); Clients aclient = ClientsDA.Search(comboBoxOrdClient.Text); abook.QOH = (abook.QOH + xorder.OrdQuantity) - aorder.OrdQuantity; BooksDA.Update(abook); aclient.creditLimit = (aclient.creditLimit + aorder.OrdTotal) - aorder.OrdTotal; ClientsDA.Update(aclient); OrderDA.Update(aorder); OrderDA.ListOrder(listViewOrd); buttonOrdList.PerformClick(); UpdateComboBoxes(); }
private void buttonSearchBook_Click(object sender, EventArgs e) { int choice = comboBoxBook.SelectedIndex; switch (choice) { case -1: MessageBox.Show("Please select the search option"); break; case 0: Books book = BooksDA.Search(Convert.ToInt32(textBoxEnterInformation.Text)); if (book != null) { textBoxISBN.Text = book.ISBN.ToString(); textBoxTitle.Text = book.Title; textBoxAuthor.Text = book.BookAuthor; textBoxYearPublished.Text = (book.BookYearPublished).ToString(); textBoxQOH.Text = (book.BookQOH).ToString(); textBoxUnitPrice.Text = (book.BookUnitePrice).ToString(); textBoxISBN.Enabled = false; } else { MessageBox.Show("ISBN not Found!"); textBoxEnterInformation.Clear(); textBoxEnterInformation.Focus(); } break; case 1: Books boo = BooksDA.SearchTitle(textBoxEnterInformation.Text); if (boo != null) { textBoxISBN.Text = (boo.ISBN).ToString(); textBoxTitle.Text = boo.Title; textBoxAuthor.Text = boo.BookAuthor; textBoxYearPublished.Text = (boo.BookYearPublished).ToString(); textBoxQOH.Text = (boo.BookQOH).ToString(); textBoxUnitPrice.Text = (boo.BookUnitePrice).ToString(); textBoxISBN.Enabled = false; } else { MessageBox.Show("Title not Found!"); textBoxEnterInformation.Clear(); textBoxEnterInformation.Focus(); } break; default: break; } }
private void listViewOrd_MouseClick(object sender, MouseEventArgs e) { string OrdNumber = listViewOrd.SelectedItems[0].SubItems[0].Text; string OrdEmployee = listViewOrd.SelectedItems[0].SubItems[1].Text; string OrdClient = ClientsDA.Search(listViewOrd.SelectedItems[0].SubItems[2].Text).clientName; string OrdProduct = BooksDA.SearchByTitle(listViewOrd.SelectedItems[0].SubItems[3].Text).title; string OrdQuantity = listViewOrd.SelectedItems[0].SubItems[4].Text; string OrdTotal = listViewOrd.SelectedItems[0].SubItems[5].Text; string OrdDate = listViewOrd.SelectedItems[0].SubItems[6].Text; string OrdPhoneNumber = ClientsDA.Search(listViewOrd.SelectedItems[0].SubItems[2].Text).phoneNumber; string OrdCreditLimit = ClientsDA.Search(listViewOrd.SelectedItems[0].SubItems[2].Text).creditLimit.ToString(); string OrdAddress = (ClientsDA.Search(listViewOrd.SelectedItems[0].SubItems[2].Text).postalCode) + ", " + (ClientsDA.Search(listViewOrd.SelectedItems[0].SubItems[2].Text).street); string OrdUnitPrice = BooksDA.SearchByTitle(listViewOrd.SelectedItems[0].SubItems[3].Text).unitPrice.ToString(); textBoxOrdNumber.Text = OrdNumber; textBoxOrdClient.Text = OrdClient; comboBoxOrdProduct.Text = OrdProduct; textBoxOrdQuantity.Text = OrdQuantity; textBoxOrdTotal.Text = OrdTotal; dateTimePicker1.Text = OrdDate; textBoxOrdPhoneNumber.Text = OrdPhoneNumber; textBoxOrdCreditLimit.Text = OrdCreditLimit; textBoxOrdAdress.Text = OrdAddress; textBoxOrdUnitPrice.Text = OrdUnitPrice; buttonOrdDelete.Enabled = true; buttonOrdUpdate.Enabled = true; }
private void buttonListBook_Click(object sender, EventArgs e) { listViewBook.Items.Clear(); BooksDA.ListBook(listViewBook); }
private void buttonUpdateBook_Click(object sender, EventArgs e) { if ((textBoxTitle.Text == "") || (textBoxAuthor.Text == "") || (textBoxYearPublished.Text == "") || (textBoxQOH.Text == "") || (textBoxUnitPrice.Text == "")) { MessageBox.Show("Please fill all the fields ", "Missing Data"); textBoxISBN.Clear(); textBoxISBN.Focus(); 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); DialogResult ans = MessageBox.Show("Do you really want to update this Book information?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (ans == DialogResult.Yes) { BooksDA.Update(book); MessageBox.Show("Book record has been updated successfully", "Confirmation"); } textBoxNamePublisher.Enabled = true; ClearAll2(); } }
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { Books result = BooksDA.SearchByTitle(comboBoxOrdProduct.Text); if (result != null) { textBoxOrdUnitPrice.Text = ("$ " + result.unitPrice.ToString()); } }
private void buttonBooDelete_Click(object sender, EventArgs e) { string itemselected = textBoxBooISBN.Text; BooksDA.Delete(Convert.ToInt32(itemselected)); MessageBox.Show("Book record has been deleted successfully", "Confirmation"); ClearAllBoo(); UpdateComboBoxes(); buttonBooList.PerformClick(); }
private void buttonSaveEmployee_Click(object sender, EventArgs e) { if ((textBoxclientname.Text == "") || (textBoxbooktitle.Text == "") || (textBoxOrderQuantity.Text == "") || (textBoxUnitPrice.Text == "") || (textBoxSubtotal.Text == "") || (textBoxGST.Text == "") || (textBoxPST.Text == "") || (textBoxtotal.Text == "")) { MessageBox.Show("Please full fill all the fields", "Missing Data"); ClearAll(); return; } else { Client client = ClientsDA.SearchNM(textBoxclientname.Text); Books book = BooksDA.SearchTitle(textBoxbooktitle.Text); string qtfh = textBoxclientname.Text; string asda = textBoxbooktitle.Text; int lalala = Convert.ToInt32(textBoxOrderQuantity.Text); if (book == null) { MessageBox.Show("Wrong Information book, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (client == null) { MessageBox.Show("Wrong Information client, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (book.BookQOH < Convert.ToInt32(textBoxOrderQuantity.Text)) { MessageBox.Show("The inventory does not have that quantity of products", "Missing Product"); ClearAll(); return; } else { Order Or = new Order(); if ((client.Name == textBoxclientname.Text) && (book.Title.ToString() == textBoxbooktitle.Text) && (book.BookQOH < Convert.ToInt32(textBoxOrderQuantity.Text))) { Or.OrdernUmber = Convert.ToInt32(textBoxOrderNumber.Text); Or.OrderDate = dateTimePickerOrder.Text; Or.ShippingDate = dateTimePickerShipping.Text; Or.ClientNumber = textBoxclientname.Text; Or.BookName = textBoxbooktitle.Text; Or.Quantity = Convert.ToInt32(textBoxOrderQuantity.Text); Or.unit = Convert.ToInt32(textBoxUnitPrice.Text); Or.Subtotal = Convert.ToInt32(textBoxSubtotal.Text); Or.Gst = Convert.ToInt32(textBoxGST.Text); Or.Pst = Convert.ToInt32(textBoxPST.Text); Or.total = Convert.ToInt32(textBoxtotal.Text); OrdersDA.Save(Or); ClearAll(); } } } }
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 buttonOrdPlaceOrder_Click(object sender, EventArgs e) { //Order Validators if (!Validator.IsEmptyComboBox(comboBoxOrdClient)) { MessageBox.Show("Order must have a valid Client.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxAutID.Clear(); textBoxAutID.Focus(); return; } if (!Validator.IsEmptyComboBox(comboBoxOrdProduct)) { MessageBox.Show("Order must have a valid Product.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxAutID.Clear(); textBoxAutID.Focus(); return; } if (!Validator.IsEmpty(textBoxOrdQuantity)) { MessageBox.Show("Orders must have a valid quantity.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxAutID.Clear(); textBoxAutID.Focus(); return; } int temp = 0; if ((!int.TryParse((textBoxOrdQuantity.Text), out temp))) { MessageBox.Show("Quantity of Products must be a integer number.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxOrdQuantity.Clear(); textBoxOrdQuantity.Focus(); return; } Order aOrder = createOrder(); Books aBook = BooksDA.SearchByTitle(comboBoxOrdProduct.Text); Clients aClient = ClientsDA.Search(comboBoxOrdClient.Text); aBook.QOH = aBook.QOH - aOrder.OrdQuantity; BooksDA.Update(aBook); aClient.creditLimit = aClient.creditLimit - aOrder.OrdTotal; ClientsDA.Update(aClient); OrderDA.SaveOrder(aOrder); buttonOrdList.PerformClick(); UpdateComboBoxes(); }
private void buttonSearchBook_Click(object sender, EventArgs e) { Books book = BooksDA.Search(Convert.ToInt32(textBoxBookSearcher.Text)); if (book != null) { textBoxBookSearcher.Text = book.Title; textBoxBookSearcher.Clear(); } else { MessageBox.Show("ISBN not Found!"); textBoxBookSearcher.Clear(); textBoxBookSearcher.Focus(); } }
//________________ORDER TAB_______________________________________________________________________ private Order createOrder() { Order aOrder = new Order(); Clients aClients = new Clients(); Books aBook = new Books(); Employee aEmployee = new Employee(); aBook = BooksDA.SearchByTitle(comboBoxOrdProduct.Text); aClients = ClientsDA.Search(comboBoxOrdClient.Text); aEmployee = EmployeeDA.Search(Convert.ToInt32(textBoxOrdEmployee.Text)); aOrder.OrdNumber = OrderDA.OrderID() + 1; aOrder.OrdEmployee = null; aOrder.OrdEmployee = aEmployee; aOrder.OrdClient = aClients; aOrder.OrdProduct = aBook; aOrder.OrdQuantity = Convert.ToInt32(textBoxOrdQuantity.Text); aOrder.OrdTotal = aOrder.OrdQuantity * BooksDA.SearchByTitle(comboBoxOrdProduct.Text).unitPrice; aOrder.OrdDate = Convert.ToDateTime(dateTimePicker1.Value); return(aOrder); }
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 buttonBooUpdate_Click(object sender, EventArgs e) { 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; DialogResult ans = MessageBox.Show("Do you really want to update this Book?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (ans == DialogResult.Yes) { BooksDA.Update(aBook); MessageBox.Show("Book record has been updated successfully", "Confirmation"); ClearAllBoo(); UpdateComboBoxes(); buttonBooList.PerformClick(); } }
private void Multiply() { if (!Validator.IsEmpty(textBoxOrdQuantity)) { textBoxOrdTotal.Text = "$ "; return; } if (!Validator.IsValidQOH(textBoxOrdQuantity.Text)) { MessageBox.Show("Quantity of Products must be a integer number.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxOrdQuantity.Clear(); textBoxOrdQuantity.Focus(); textBoxOrdTotal.Text = "$ "; return; } else { textBoxOrdTotal.Text = "$ " + (Convert.ToInt32(textBoxOrdQuantity.Text) * BooksDA.SearchByTitle(comboBoxOrdProduct.Text).unitPrice).ToString(); } }
private void buttonBooSearch_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(textBoxBooSearch.Text)) { int choice = comboBoxBooSearch.SelectedIndex; switch (choice) { case -1: MessageBox.Show("Please select the search option"); break; case 0: //Search by ISBN Number Books Boo = BooksDA.Search(Convert.ToInt32(textBoxBooSearch.Text)); if (Boo != null) { textBoxBooISBN.Text = Boo.ISBN.ToString(); textBoxBooTitle.Text = Boo.title; comboBoxBooAuthor.Text = Boo.author; textBoxBooYPublished.Text = Boo.yearPublished; textBoxBooPrice.Text = Boo.unitPrice.ToString(); textBoxBooQOH.Text = Boo.QOH.ToString(); comboBoxBooSuplier.Text = Boo.publisher; buttonBooDelete.Enabled = true; buttonBooUpdate.Enabled = true; } else { MessageBox.Show("Client not Found!"); textBoxBooSearch.Clear(); textBoxBooSearch.Focus(); } break; case 1: //Search by Book Title Books BooTitle = BooksDA.SearchByTitle(textBoxBooSearch.Text); if (BooTitle != null) { textBoxBooISBN.Text = BooTitle.ISBN.ToString(); textBoxBooTitle.Text = BooTitle.title; comboBoxBooAuthor.Text = BooTitle.author; textBoxBooYPublished.Text = BooTitle.yearPublished; textBoxBooPrice.Text = BooTitle.unitPrice.ToString(); textBoxBooQOH.Text = BooTitle.QOH.ToString(); comboBoxBooSuplier.Text = BooTitle.publisher; buttonBooDelete.Enabled = true; buttonBooUpdate.Enabled = true; } else { MessageBox.Show("Client not Found!"); textBoxBooSearch.Clear(); textBoxBooSearch.Focus(); } break; case 2: //Search by Book Author Books BooAuthor = BooksDA.SearchByAuthor(textBoxBooSearch.Text); if (BooAuthor != null) { textBoxBooISBN.Text = BooAuthor.ISBN.ToString(); textBoxBooTitle.Text = BooAuthor.title; comboBoxBooAuthor.Text = BooAuthor.author; textBoxBooYPublished.Text = BooAuthor.yearPublished; textBoxBooPrice.Text = BooAuthor.unitPrice.ToString(); textBoxBooQOH.Text = BooAuthor.QOH.ToString(); comboBoxBooSuplier.Text = BooAuthor.publisher; buttonBooDelete.Enabled = true; buttonBooUpdate.Enabled = true; } else { MessageBox.Show("Client not Found!"); textBoxBooSearch.Clear(); textBoxBooSearch.Focus(); } break; default: break; } } else { MessageBox.Show("Please, enter a valid information to search!", "Serach Invalid", MessageBoxButtons.OK, MessageBoxIcon.Information); textBoxBooSearch.Clear(); textBoxBooSearch.Focus(); } }
private void buttonBooList_Click(object sender, EventArgs e) { listViewBoo.Items.Clear(); BooksDA.ListBooks(listViewBoo); }
private void buttonDeleteBook_Click(object sender, EventArgs e) { BooksDA.Delete(Convert.ToInt32(textBoxISBN.Text)); MessageBox.Show(" Book record has been deleted successfully", "Confirmation"); 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(); }