void popuni() { var con = Baza.konekcija(); con.Open(); string izvadi = "select * from Osoba where oib =" + oib + ""; SqlCommand izvadi_cmd = new SqlCommand(izvadi, con); SqlDataReader citac; citac = izvadi_cmd.ExecuteReader(); while (citac.Read()) { textBox1.Text = (citac["Oib"].ToString()); textBox2.Text = (citac["Ime"].ToString()); textBox3.Text = (citac["Prezime"].ToString()); } con.Close(); }
private void button1_Click(object sender, EventArgs e) { var con = Baza.konekcija(); con.Open(); string zadatak = "INSERT INTO Propusnica (oib,ime,prezime,mjesto_od,mjesto_do,razlog,odobreno,datumod,datumdo,napravio) VALUES('" + this.textBox1.Text + "' ,'" + this.textBox2.Text + "' , ' " + this.textBox3.Text + "' , '" + this.textBox4.Text + "','" + this.textBox5.Text + "','" + this.textBox6.Text + "', 1,'" + this.dateTimePicker1.Text + "','" + this.dateTimePicker2.Text + "'," + oib + ");"; SqlCommand cmd = new SqlCommand(zadatak, con); cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Propusnica napravljena"); this.Hide(); Vlasnik_poduzeca otvori = new Vlasnik_poduzeca(oib); otvori.Show(); }
private void button1_Click_1(object sender, EventArgs e) { oib = textBox1.Text; var con = Baza.konekcija(); con.Open(); SqlDataAdapter c = new SqlDataAdapter("select count(*) from Osoba where OIB=" + this.textBox1.Text + "and prava='c'", con); DataTable dt_c = new DataTable(); c.Fill(dt_c); if (dt_c.Rows[0][0].ToString() == "1") { Civil otvori = new Civil(oib); this.Hide(); otvori.Show(); } else { SqlDataAdapter prijava_v = new SqlDataAdapter("select count(*) from Osoba where oib=" + textBox1.Text + " and prava = 'v'", con); DataTable dt_v = new DataTable(); prijava_v.Fill(dt_v); if (dt_v.Rows[0][0].ToString() == "1") { Vlasnik_poduzeca otvori = new Vlasnik_poduzeca(oib); this.Hide(); otvori.Show(); } } SqlDataAdapter prijava_s = new SqlDataAdapter("select count(*) from Osoba where oib=" + textBox1.Text + " and prava= 's'", con); DataTable dt_s = new DataTable(); prijava_s.Fill(dt_s); if (dt_s.Rows[0][0].ToString() == "1") { Obradi otvori = new Obradi(); this.Hide(); otvori.Show(); } }
private void button2_Click(object sender, EventArgs e) { var con = Baza.konekcija(); con.Open(); int selectedrowindex = dataGridView1.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = dataGridView1.Rows[selectedrowindex]; string zadatak = "UPDATE Propusnica set odobreno=2 where broj =" + selectedRow.Cells["broj"].Value + ""; SqlCommand cmd = new SqlCommand(zadatak, con); cmd.ExecuteNonQuery(); this.dataGridView1.EndEdit(); this.dataGridView1.Refresh(); selectedRow.Cells["odobreno"].Value = 2; con.Close(); dataGridView1.Update(); dataGridView1.Refresh(); MessageBox.Show("Propusnica odbijena"); }