Esempio n. 1
0
        private void BtnSaveCustomer_Click(object sender, EventArgs e)
        {
            var isValidName    = ValidateCustomerName();
            var isValidMobile  = ValidateCustomerMobile();
            var isValidAddress = ValidateAddressLine1();
            var isValidCity    = ValidateCityName();
            var isValidState   = ValidateStateName();
            var isValidCountry = ValidateCountryName();

            if (isValidName && isValidMobile && isValidAddress && isValidCity && isValidState && isValidCountry)
            {
                var customer = new CreateCustomerDto
                {
                    Code         = null,
                    Name         = txtCustomerName.Text,
                    Mobile       = txtCustomerMobile.Text,
                    Telephone    = txtCustomerTelephone.Text,
                    AddressLine1 = txtAddressLine1.Text,
                    AddressLine2 = txtAddressLine2.Text,
                    City         = txtCityName.Text,
                    State        = txtStateName.Text,
                    Country      = txtCountryName.Text
                };

                if (_customerBUS.SaveCustomer(customer))
                {
                    MessageBox.Show("Customer details saved successfully");
                    ClearFormInputs();
                    this.Hide();
                    ManageCustomerForm manageCustomerForm = new ManageCustomerForm();
                }
                else
                {
                    MessageBox.Show("Details not saved");
                }
            }
            else
            {
                MessageBox.Show("Please enter required details");
            }
        }