예제 #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (txtAddress.Text.ToUpper().Contains(cbbCountries.SelectedItem.ToString().ToUpper()))
            {
                MessageBox.Show("The address must not have the country!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtAddress.Focus();
                return;
            }

            if (cbbCity.Enabled && cbbCity.SelectedIndex > 0 && txtAddress.Text.ToUpper().Contains(cbbCity.SelectedItem.ToString().ToUpper()))
            {
                MessageBox.Show("The address must not have the city!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cbbCity.Focus();
                return;
            }

            KhachHang oldCus = ListCus.Single(txtCode.Text);
            KhachHang newCus = controls_Load();

            if (oldCus.Ho.ToUpper() != newCus.Ho.ToUpper() || oldCus.Ten.ToUpper() != newCus.Ten.ToUpper())
            {
                if (!ListCus.Test(txtFirstName.Text + " " + txtName.Text, txtAddress.Text, (cbbCity.Enabled && (cbbCity.SelectedIndex > 0)) ? cbbCity.SelectedItem.ToString() : "", cbbCountries.SelectedItem.ToString()))
                {
                    MessageBox.Show("This customer had been exited!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtAddress.Focus();
                    return;
                }
            }

            if (ListCus.Update(newCus))
            {
                MessageBox.Show("Udating is success full!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                return;
            }
            MessageBox.Show("Update had been faile!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
예제 #2
0
        private bool TestData()
        {
            if (txtAddress.Text.ToUpper().Contains(cbbCountries.SelectedItem.ToString().ToUpper()))
            {
                MessageBox.Show("The address must not have the country!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtAddress.Focus();
                return(false);
            }

            if (cbbCity.Enabled && cbbCity.SelectedIndex > 0 && txtAddress.Text.ToUpper().Contains(cbbCity.SelectedItem.ToString().ToUpper()))
            {
                MessageBox.Show("The address must not have the city!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cbbCity.Focus();
                return(false);
            }

            if (!ListCus.Test(txtFirstName.Text + " " + txtName.Text, txtAddress.Text, (cbbCity.Enabled && (cbbCity.SelectedIndex > 0)) ? cbbCity.SelectedItem.ToString() : "", cbbCountries.SelectedItem.ToString()))
            {
                MessageBox.Show("This customer had been exited!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtAddress.Focus();
                return(false);
            }
            return(true);
        }