コード例 #1
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                CustomerDto customerDto = new CustomerDto();
                //divisionDto.idDivision = int.Parse(tbDivisionID.Text);
                customerDto.Adress    = tbAdress.Text;
                customerDto.Info      = tbInfo.Text;
                customerDto.Name      = tbName.Text;
                customerDto.Phone     = tbPhone.Text;
                customerDto.ManagerID = int.Parse(tbManager.Text);
                ICustomerProcess cutomerProcess = ProcessFactory.GetCustomerProcess();

                if (_id == 0)
                {
                    cutomerProcess.Add(customerDto);
                }
                else
                {
                    customerDto.ID = _id;
                    cutomerProcess.Update(customerDto);
                }
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #2
0
    // This constructor requires the two original implementations, and an ICustomerContext.
    // The ICustomerContext allows requesting information about
    public CustomerProcessProxy(
        RetailCustomer retail, CommercialCustomer commercial, ICustomerContext context)
    {
        this.retail     = retail;
        this.commercial = commercial;

        // Important note: in the constructor you should ONLY store incoming dependencies,
        // but never use them. That's why we won't call context.IsRetailCustomer here.
        this.context = context;
    }
コード例 #3
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tbName.Text))
            {
                MessageBox.Show("Имя клиента не должно быть пустым", "Проверка");
                return;
            }
            if (string.IsNullOrEmpty(tbEmail.Text))
            {
                MessageBox.Show("Email не должен быть пустым", "Проверка");
                return;
            }
            if (string.IsNullOrEmpty(tbAreaCode.Text))
            {
                MessageBox.Show("Код области не должен быть пустым", "Проверка");
                return;
            }
            if (string.IsNullOrEmpty(tbStreet.Text))
            {
                MessageBox.Show("Улица не должна быть пустой", "Проверка");
                return;
            }
            if (string.IsNullOrEmpty(tbCity.Text))
            {
                MessageBox.Show("Город не должен быть пустым", "Проверка");
                return;
            }
            if (string.IsNullOrEmpty(tbRegion.Text))
            {
                MessageBox.Show("Регион не должен быть пустым", "Проверка");
                return;
            }
            if (string.IsNullOrEmpty(tbZipPostalCode.Text))
            {
                MessageBox.Show("Почтовый индекс не должен быть пустым", "Проверка");
                return;
            }
            if (string.IsNullOrEmpty(tbCountry.Text))
            {
                MessageBox.Show("Страна не должна быть пустой", "Проверка");
                return;
            }
            if (string.IsNullOrEmpty(tbPhoneNumber.Text))
            {
                MessageBox.Show("Номер телефона не должен быть пустым", "Проверка");
                return;
            }
            CustomerDto customer = new CustomerDto();

            customer.AreaCode      = tbAreaCode.Text;
            customer.City          = tbCity.Text;
            customer.Country       = tbCountry.Text;
            customer.Email         = tbEmail.Text;
            customer.HouseNumber   = tbHouseNumber.Text;
            customer.Name          = tbName.Text;
            customer.PhoneNumber   = tbPhoneNumber.Text;
            customer.Region        = tbRegion.Text;
            customer.Street        = tbStreet.Text;
            customer.ZipPostalCode = tbZipPostalCode.Text;
            ICustomerProcess customerProcess = ProcessFactory.GetCustomerProcess();

            if (_customerid == 0)
            {
                customerProcess.Add(customer);
            }
            else
            {
                customer.CustomerID = _customerid;
                customerProcess.Update(customer);
            }
            Close();
        }