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 buttonDelete_Click(object sender, EventArgs e) { ClientsDA.Delete(Convert.ToInt32(textBoxclientID.Text)); MessageBox.Show(" Client record has been deleted successfully", "Confirmation"); textBoxclientID.Enabled = true; ClearAll(); }
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 buttonCliSearch_Click(object sender, EventArgs e) { int choice = comboBoxCliSearch.SelectedIndex; switch (choice) { case -1: MessageBox.Show("Please select the search option"); break; case 0: //Search by Client Name Clients Cli = ClientsDA.Search(textBoxCliSearch.Text); if (Cli != null) { textBoxCliName.Text = Cli.clientName; maskedTextBoxCliPhone.Text = Cli.phoneNumber; textBoxCliCity.Text = Cli.city; textBoxCliPostalCode.Text = Cli.postalCode; textBoxCliStreet.Text = Cli.street; textBoxCliCredit.Text = Cli.creditLimit.ToString(); buttonCliDelete.Enabled = true; buttonCliUpdate.Enabled = true; } else { MessageBox.Show("Client not Found!"); textBoxCliSearch.Clear(); textBoxCliSearch.Focus(); } break; case 1: //Search by Client City Clients CliCity = ClientsDA.SearchByCity(textBoxCliSearch.Text); if (CliCity != null) { textBoxCliName.Text = CliCity.clientName; maskedTextBoxCliPhone.Text = CliCity.phoneNumber; textBoxCliCity.Text = CliCity.city; textBoxCliPostalCode.Text = CliCity.postalCode; textBoxCliStreet.Text = CliCity.street; textBoxCliCredit.Text = CliCity.creditLimit.ToString(); buttonCliDelete.Enabled = true; buttonCliUpdate.Enabled = true; } else { MessageBox.Show("Client not Found!"); textBoxCliSearch.Clear(); textBoxCliSearch.Focus(); } break; default: break; } }
private void buttonUpdate_Click(object sender, EventArgs e) { if ((maskedTextBoxfaxnumber.Text == "") || (textBoxcreditlimit.Text == "") || (textBoxinstitutionname.Text == "") || (textBoxstreet.Text == "") || (textBoxcity.Text == "") || (maskedTextBoxPostalCode.Text == "") || (maskedTextBoxphonenumber.Text == "")) { MessageBox.Show("Please enter a valid Client", "Missing Data"); textBoxclientID.Clear(); textBoxclientID.Focus(); return; } else { Client clien = new Client(); clien.ClientID = Convert.ToInt32(textBoxclientID.Text); clien.Name = textBoxinstitutionname.Text; clien.Street = textBoxstreet.Text; clien.PostalCode = maskedTextBoxPostalCode.Text; clien.PhoneNumber = maskedTextBoxphonenumber.Text; clien.FaxNumber = maskedTextBoxfaxnumber.Text; clien.CreditLimit = Convert.ToInt32(textBoxcreditlimit); DialogResult ans = MessageBox.Show("Do you really want to update this Client information?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (ans == DialogResult.Yes) { ClientsDA.Update(clien); MessageBox.Show("Client record has been updated successfully", "Confirmation"); } textBoxclientID.Visible = true; ClearAll(); } }
private void buttonSearch_Click(object sender, EventArgs e) { Client clien = ClientsDA.SearchID(Convert.ToInt32(textBoxSearcher.Text)); if (clien != null) { textBoxclientID.Text = (clien.ClientID).ToString(); textBoxinstitutionname.Text = clien.Name; textBoxstreet.Text = clien.Street; textBoxcity.Text = clien.City; maskedTextBoxPostalCode.Text = clien.PostalCode; maskedTextBoxphonenumber.Text = clien.PhoneNumber; maskedTextBoxfaxnumber.Text = clien.FaxNumber; textBoxcreditlimit.Text = (clien.CreditLimit).ToString(); textBoxclientID.Enabled = false; textBoxSearcher.Clear(); } else { MessageBox.Show("User not Found!"); textBoxSearcher.Clear(); textBoxSearcher.Focus(); } }
private void buttonList_Click(object sender, EventArgs e) { listViewClient.Items.Clear(); ClientsDA.ListClient(listViewClient); }
private void buttonCliDelete_Click(object sender, EventArgs e) { string itemselected = textBoxCliName.Text; ClientsDA.Delete(itemselected); MessageBox.Show("Client record has been deleted successfully", "Confirmation"); ClearAllCli(); UpdateComboBoxes(); buttonCliList.PerformClick(); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { Clients result = ClientsDA.Search(comboBoxOrdClient.Text); if (result != null) { textBoxOrdClient.Text = result.clientName.ToString(); textBoxOrdPhoneNumber.Text = result.phoneNumber.ToString(); textBoxOrdCreditLimit.Text = ("$ " + result.creditLimit.ToString()); textBoxOrdAdress.Text = (result.postalCode + ", " + result.city + " - " + result.street); } }
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 buttonSearchClient_Click(object sender, EventArgs e) { Client clien = ClientsDA.SearchID(Convert.ToInt32(textBoxClientSearcher.Text)); if (clien != null) { textBoxclientname.Text = clien.Name; textBoxClientSearcher.Clear(); } else { MessageBox.Show("User not Found!"); textBoxClientSearcher.Clear(); textBoxClientSearcher.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 buttonCliUpdate_Click(object sender, EventArgs e) { Clients aClient = new Clients(); aClient.clientName = textBoxCliName.Text; aClient.phoneNumber = maskedTextBoxCliPhone.Text; aClient.city = textBoxCliCity.Text; aClient.street = textBoxCliStreet.Text; aClient.postalCode = textBoxCliPostalCode.Text; aClient.creditLimit = Convert.ToDecimal(textBoxCliCredit.Text); DialogResult ans = MessageBox.Show("Do you really want to update this Client?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (ans == DialogResult.Yes) { ClientsDA.Update(aClient); MessageBox.Show("Client record has been updated successfully", "Confirmation"); ClearAllCli(); UpdateComboBoxes(); buttonCliList.PerformClick(); } }
private void buttonSave_Click(object sender, EventArgs e) { if ((maskedTextBoxfaxnumber.Text == "") || (textBoxcreditlimit.Text == "") || (textBoxclientID.Text == "") || (textBoxinstitutionname.Text == "") || (textBoxstreet.Text == "") || (textBoxcity.Text == "") || (maskedTextBoxPostalCode.Text == "") || (maskedTextBoxphonenumber.Text == "")) { MessageBox.Show("You have to fill out all the boxes, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { Client clien = new Client(); clien.ClientID = Convert.ToInt32(textBoxclientID.Text); clien.Name = textBoxinstitutionname.Text; clien.Street = textBoxstreet.Text; clien.City = textBoxcity.Text; clien.PostalCode = maskedTextBoxPostalCode.Text; clien.PhoneNumber = maskedTextBoxphonenumber.Text; clien.FaxNumber = maskedTextBoxfaxnumber.Text; clien.CreditLimit = Convert.ToInt32(textBoxcreditlimit.Text); ClientsDA.Save(clien); } ClearAll(); }
private void buttonCliSave_Click(object sender, EventArgs e) { //Client Validators //if (!Validator.IsEmpty(textBoxCliName)) //{ // MessageBox.Show("Author ID field must have 4 digits.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // textBoxCliName.Clear(); // textBoxCliName.Focus(); // return; //} //if (!Validator.IsValidId(textBoxCliName.Text, 4)) //{ // MessageBox.Show("Author ID field must have 4 digits.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // textBoxCliName.Clear(); // textBoxCliName.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; //} if (string.IsNullOrEmpty(textBoxCliCredit.Text)) { textBoxCliCredit.Text = "0"; } //Saving the data into the text file Clients aClient = new Clients(); aClient.clientName = textBoxCliName.Text; aClient.phoneNumber = maskedTextBoxCliPhone.Text; aClient.city = textBoxCliCity.Text; aClient.street = textBoxCliStreet.Text; aClient.postalCode = textBoxCliPostalCode.Text; aClient.creditLimit = Convert.ToDecimal(textBoxCliCredit.Text); ClientsDA.Save(aClient); ClearAllCli(); UpdateComboBoxes(); buttonCliList.PerformClick(); }