Beispiel #1
0
        private void btnUReg_Click_1(object sender, EventArgs e)
        {
            if (cboUpdSuppliers.Text.Equals(""))
            {
                MessageBox.Show("No Supplier selected! Please select a Supplier!", "No Supplier selected", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                return;
            }


            else if (!IsPhoneNo(txtUpdPhoneNo.Text))
            //else if (txtUpdPhoneNo.Text.Equals(""))
            {
                MessageBox.Show("No phone number detected! This phone number must be entered!", "Supplier Confirmation", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                txtUpdPhoneNo.Focus();
                return;
            }

            else if (!ValEmail(txtUpdEmail.Text))
            {
                MessageBox.Show("No email detected! This email must be entered!", "Email Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                txtUpdEmail.Focus();
                return;
            }

            else if (txtUpdStreet.Text.Equals(""))
            {
                MessageBox.Show("No street entered! This street must be entered!", "Missing Street", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                txtUpdStreet.Focus();
                return;
            }

            else if (txtUpdTownVillage.Text.Equals(""))
            {
                MessageBox.Show("No town/village detected! This town/village must be entered!", "Missing Town/Village", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                txtUpdTownVillage.Focus();
                return;
            }
            char status = 'A';

            Supplier supp = new Supplier();

            supp.setSuppID(Convert.ToInt32(txtSuppID.Text));
            supp.setSuppName(txtName.Text);
            supp.setPhoneNo(Convert.ToInt32(txtUpdPhoneNo.Text));
            supp.setEmail(txtUpdEmail.Text);
            supp.setStreet(txtUpdStreet.Text);
            supp.setTownVillage(txtUpdTownVillage.Text);
            supp.setCounty(txtUpdCounties.Text.Substring(0, 2));
            supp.setAccBal(Convert.ToDecimal(txtAccBal.Text));
            supp.setStatus(status);

            supp.updSupp();


            //Save Data in Supplier File
            MessageBox.Show("Supplier ID: " + txtSuppID.Text + "\nSupplier: " + cboUpdSuppliers.GetItemText(cboUpdSuppliers.SelectedItem) + "\nPhone No: " +
                            txtUpdPhoneNo.Text + "\nEmail: " + txtUpdEmail.Text + "\nStreet: " + txtUpdStreet.Text + "\nTown/Village: " + txtUpdTownVillage.Text +
                            "\nCounty: " + txtUpdCounties.Text + "\nAccount Balance: " + txtAccBal.Text + "\nStatus: " + status, "Supplier Details", MessageBoxButtons.OK,
                            MessageBoxIcon.Information);

            //Display confirmation message

            MessageBox.Show("Supplier has been updated!", "Supplier Updated", MessageBoxButtons.OK,
                            MessageBoxIcon.Information);


            //Clear UI
            loadSuppItems();
            cboUpdSuppliers.SelectedIndex = -1;
            grpSupp.Visible = false;
            txtSuppID.Clear();
            txtName.Clear();
            txtUpdPhoneNo.Clear();
            txtUpdEmail.Clear();
            txtUpdStreet.Clear();
            txtUpdTownVillage.Clear();
            txtUpdCounties.Clear();
            txtAccBal.Clear();
            return;
        }