private void buttonSearchCustomer_Click_1(object sender, EventArgs e) { string name = textBoxSearchName.Text; string firstName = textBoxSearchFirstName.Text; string phoneNumber = textBoxSearchPhoneNumber.Text; if (!FieldsCompleted(name, firstName, phoneNumber)) { labelSearchDisplayInfo.Text = @"Must complete mandatory fields"; } else { buttonSearchCustomer.Enabled = true; Client client = _carService.FindCustomer(name, firstName, phoneNumber); if (client == null) { labelSearchDisplayInfo.Text = @"There is no customer with these specification. Please add new customer."; } else { labelSearchDisplayInfo.Text = @"Customer cars are displayed bellow."; panelAddCustomerCar.Visible = true; string getChassis = "SELECT CodSasiu, Denumire FROM Sasiuri"; ExecuteQuery(getChassis, dataGridViewChassisOptions); string getClientCars = $"SELECT * FROM Automobile WHERE ClientId = {client.Id}"; ExecuteQuery(getClientCars, dataGridViewCustomerCars); } } }
private void buttonSearchCustomer_Click(object sender, EventArgs e) { string name = textBoxSearchName.Text; string firstName = textBoxSearchFirstName.Text; string email = textBoxSearchEmail.Text; Client client = _carService.FindCustomer(name, firstName, email); if (client == null) { labelSearchDisplayInfo.Text = "There is no customer with these specification. Please add new customer."; } else { labelSearchDisplayInfo.Text = "Customer cars are displayed bellow."; panelAddCustomerCar.Visible = true; using (SqlConnection sqlCon = new SqlConnection(connectionString)) { sqlCon.Open(); string queryString = "SELECT CodSasiu, Denumire FROM Sasiuri"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(queryString, sqlCon); DataTable dataTable = new DataTable(); sqlDataAdapter.Fill(dataTable); dataGridViewChassisOptions.DataSource = dataTable; dataGridViewChassisOptions.Visible = true; } using (SqlConnection sqlCon = new SqlConnection(connectionString)) { sqlCon.Open(); string queryString = "SELECT * FROM Automobile WHERE ClientId = " + client.Id; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(queryString, sqlCon); DataTable dataTable = new DataTable(); sqlDataAdapter.Fill(dataTable); dataGridViewCustomerCars.DataSource = dataTable; dataGridViewCustomerCars.Visible = true; } } }
public Client FindCustomer(string nume, string prenume, string phoneNumber) { return(_api.FindCustomer(nume, prenume, phoneNumber)); }