private void button3_Click(object sender, EventArgs e) { string imie = "", nazwisko = "", pesel = "", adres_zam = "", adres_kor = "", t_kon = "", email = "", z_przetw = "", z_market = "", z_fak = ""; string sql = "select imie,nazwisko,pesel,adres_zam,adres_kor,telefon_kon,email,z_przetw,z_market,z_fak from klient where idklienta = @id"; MySqlCommand cmd = new MySqlCommand(sql, SqlConnectionClass.myConnection); cmd.Parameters.AddWithValue("@id", Program.ostatnioTablica[listBox1.SelectedIndex]); if (listBox1.SelectedIndex >= 0) { MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { imie = rdr[0].ToString(); nazwisko = rdr[1].ToString(); pesel = rdr[2].ToString(); adres_zam = rdr[3].ToString(); adres_kor = rdr[4].ToString(); t_kon = rdr[5].ToString(); email = rdr[6].ToString(); z_przetw = rdr[7].ToString(); z_market = rdr[8].ToString(); z_fak = rdr[9].ToString(); } rdr.Close(); KlientForm klientFormForm = new KlientForm(); klientFormForm.Show(); klientFormForm.foo(Program.ostatnioTablica[listBox1.SelectedIndex], imie, nazwisko, pesel, adres_zam, adres_kor, t_kon, email, z_przetw, z_market, z_fak); } }
//Klikniecie na tabele przenosi do klient forma private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { bool dodaj = true; if (dataGridView1.ReadOnly == true) { //idklienta,imie,nazwisko,pesel,adres_zam,adres_kor,telefon_kon,email,z_przetw,z_market,z_fak string id = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); string imie = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); string nazwisko = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); string pesel = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); string adres_zam = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(); string adres_kor = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString(); string t_kon = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString(); string email = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString(); string z_przetw = dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString(); string z_market = dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString(); string z_fak = dataGridView1.Rows[e.RowIndex].Cells[10].Value.ToString(); if (dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString() != "") { KlientForm klientFormForm = new KlientForm(); for (int i = 0; i < Program.ostatnioTablica.Length; i++) { if (Program.ostatnioTablica[i] == id.ToString()) { dodaj = false; } } if (dodaj) { SqlConnectionClass.updateLastKlient(id.ToString()); } klientFormForm.Show(); klientFormForm.foo(id, imie, nazwisko, pesel, adres_zam, adres_kor, t_kon, email, z_przetw, z_market, z_fak); } } }