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 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 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 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(); } }