private void PokazWszystkie_Click(object sender, EventArgs e) { //Wyswietlenie wszystkich samochodow List <string>[] list; list = dbConnect.SelectWszystkie(); WyswietlDG1.Rows.Clear(); for (int i = 0; i < list[0].Count; i++) { int number = WyswietlDG1.Rows.Add(); WyswietlDG1.Rows[number].Cells[0].Value = list[0][i]; WyswietlDG1.Rows[number].Cells[1].Value = list[1][i]; WyswietlDG1.Rows[number].Cells[2].Value = list[2][i]; WyswietlDG1.Rows[number].Cells[3].Value = list[3][i]; WyswietlDG1.Rows[number].Cells[4].Value = list[4][i]; WyswietlDG1.Rows[number].Cells[5].Value = list[5][i]; } }
public UsunSamochody() { InitializeComponent(); dbConnect = new BazaDanychPolaczenie(); List <string>[] list; list = dbConnect.SelectWszystkie(); WyswietlDG1.Rows.Clear(); for (int i = 0; i < list[0].Count; i++) { int number = WyswietlDG1.Rows.Add();//Wyświetlenie listy wszystkich samochodów WyswietlDG1.Rows[number].Cells[0].Value = list[0][i]; WyswietlDG1.Rows[number].Cells[1].Value = list[1][i]; WyswietlDG1.Rows[number].Cells[2].Value = list[2][i]; WyswietlDG1.Rows[number].Cells[3].Value = list[3][i]; WyswietlDG1.Rows[number].Cells[4].Value = list[4][i]; WyswietlDG1.Rows[number].Cells[5].Value = list[5][i]; } }
public DodajSamochody() { InitializeComponent(); dbConnect = new BazaDanychPolaczenie(); //Stworzenie polączenia przy wejściu w formularz i wypisanie wszystkich rekordów z bazy List <string>[] list; list = dbConnect.SelectWszystkie(); WyswietlDG1.Rows.Clear(); for (int i = 0; i < list[0].Count; i++) { int number = WyswietlDG1.Rows.Add(); WyswietlDG1.Rows[number].Cells[0].Value = list[0][i]; WyswietlDG1.Rows[number].Cells[1].Value = list[1][i]; WyswietlDG1.Rows[number].Cells[2].Value = list[2][i]; WyswietlDG1.Rows[number].Cells[3].Value = list[3][i]; WyswietlDG1.Rows[number].Cells[4].Value = list[4][i]; WyswietlDG1.Rows[number].Cells[5].Value = list[5][i]; } }
private void DodajSamochod_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtMarka.Text) || String.IsNullOrEmpty(txtModel.Text) || String.IsNullOrEmpty(txtKolor.Text))//Jeśli nic nie wpisano to wyświetl kompunikat { MessageBox.Show("Podano pusty rekord!"); } else { marka = txtMarka.Text; model = txtModel.Text; kolor = txtKolor.Text; bool successfullyParsed = int.TryParse(txtRocznik.Text, out rocznik); //Sprawdzenie czy rocznik jest typu int bool successfullyParsed2 = float.TryParse(txtCena.Text, out cena); //Sprawdzenie czy cena jest typu float if (successfullyParsed && successfullyParsed2) { dbConnect.DodawanieSamochodow(marka, model, kolor, rocznik, cena);//Przekazuje zmienne do metody dodającej samochod do bazy danych MessageBox.Show("Dodano nowy samochód!"); } else { MessageBox.Show("Pole rocznik,cena musi być liczbą!"); } } //Select button is clicked List <string>[] list; list = dbConnect.SelectWszystkie(); WyswietlDG1.Rows.Clear(); for (int i = 0; i < list[0].Count; i++) { int number = WyswietlDG1.Rows.Add(); WyswietlDG1.Rows[number].Cells[0].Value = list[0][i]; WyswietlDG1.Rows[number].Cells[1].Value = list[1][i]; WyswietlDG1.Rows[number].Cells[2].Value = list[2][i]; WyswietlDG1.Rows[number].Cells[3].Value = list[3][i]; WyswietlDG1.Rows[number].Cells[4].Value = list[4][i]; WyswietlDG1.Rows[number].Cells[5].Value = list[5][i]; } }