Ejemplo n.º 1
0
        private void AddCustomerCarButton_OnClick(object sender, RoutedEventArgs e)
        {
            string name        = SearchCustomerNameTextBox.Text;
            string firstName   = SearchCustomerFirstNameTextBox.Text;
            string phoneNumber = SearchCustomerPhoneNumberTextBox.Text;
            var    customer    = _client.FindCustomer(name, firstName, phoneNumber);

            DataRowView row      = (DataRowView)DisplayChassisDataGrid.SelectedItem;
            string      codSasiu = row["CodSasiu"].ToString();

            Sasiu sasiu = _client.FindChassisByCode(codSasiu);

            string autoNumber    = AddCustomerCarAutoNumberTextBox.Text;
            string chassisSeries = AddCustomerCarChassisSeriesTextBox.Text;
            Auto   auto          = new Auto()
            {
                SasiuId    = sasiu.Id,
                ClientId   = customer.Id,
                NumarAuto  = autoNumber,
                SerieSasiu = chassisSeries
            };

            _client.AddAuto(auto);

            AddCarDisplayInfoTextBlock.Text       = @"Car added.";
            AddCarDisplayInfoTextBlock.Visibility = Visibility.Visible;

            string getClientCars = $"SELECT * FROM Automobile WHERE ClientId = {customer.Id}";

            ExecuteQuery(getClientCars, SearchCustomerDataGrid);
        }