private void SaveButton_Click(object sender, EventArgs e) { showRichTextBox.Clear(); customerName.Add(customerNameTextBox.Text); contactNo.Add(ContactNoTextBox.Text); address.Add(addressTextBox.Text); order.Add(orderComboBox.Text); quantity.Add(quantityTextBox.Text); if (orderComboBox.SelectedItem.Equals("Math")) { totalPrice = 120 * Convert.ToInt32(quantityTextBox.Text); } else if (orderComboBox.SelectedItem.Equals("English")) { totalPrice = 100 * Convert.ToInt32(quantityTextBox.Text); } else { totalPrice = 80 * Convert.ToInt32(quantityTextBox.Text); } price.Add(Convert.ToString(totalPrice)); int count = 1; int index = 0; foreach (string display in customerName) { showRichTextBox.SelectedText = "\n\t\tOrder " + count++ + " information"; showRichTextBox.SelectedText = "\nCustomer Name : " + display; showRichTextBox.SelectedText = "\nContact No : " + contactNo[index]; showRichTextBox.SelectedText = "\nAddress : " + address[index]; showRichTextBox.SelectedText = "\nOrder : " + order[index]; showRichTextBox.SelectedText = "\nQuantity : " + quantity[index]; showRichTextBox.SelectedText = "\nTotal price : " + price[index]; index++; } customerNameTextBox.Clear(); ContactNoTextBox.Clear(); addressTextBox.Clear(); orderComboBox.ResetText(); quantityTextBox.Clear(); }
private void AddCustomerInfo() { try { if (customerNameTextBox.Text == "" || ContactNoTextBox.Text == "" || AddressTextBox.Text == "" || orderComboBox.Text == "" || quantityTextBox.Text == "" || orderComboBox.Text == "Select") { if (customerNameTextBox.Text == "") { customerNameTextBox.Text = string.Empty; MessageBox.Show("Customer Name Required"); } else if (ContactNoTextBox.Text == "") { ContactNoTextBox.Text = string.Empty; MessageBox.Show("Contact No Required"); } else if (AddressTextBox.Text == "") { AddressTextBox.Text = string.Empty; MessageBox.Show("Address Required"); } else if (orderComboBox.Text == "" || orderComboBox.Text == "Select") { orderComboBox.Text = string.Empty; MessageBox.Show("Select Your order Item"); } else if (quantityTextBox.Text == "") { quantityTextBox.Text = string.Empty; MessageBox.Show("Quantity Required"); } else { return; } } else { Names.Add(customerNameTextBox.Text); customerNameTextBox.Clear(); if (Contacts.Contains(ContactNoTextBox.Text) == true) { MessageBox.Show("This 'Contact No' have already used!"); return; } else { Contacts.Add(ContactNoTextBox.Text); ContactNoTextBox.Clear(); } Addresses.Add(AddressTextBox.Text); AddressTextBox.Clear(); Orders.Add(orderComboBox.Text); orderComboBox.Text = string.Empty; Quantities.Add(Convert.ToInt32(quantityTextBox.Text)); quantityTextBox.Clear(); identify++; ShowSingleCustomerInfo(); } } catch (Exception ex) { MessageBox.Show("Wrong Input"); return; } }