private void button2_Click(object sender, EventArgs e) { var con = Baza.conn(); con.Open(); string zadatak = "INSERT INTO Korisnik (Ime,Prezime,korisnik, lozinka) VALUES( '" + this.textBox1.Text + "' ,'" + this.textBox2.Text + "','" + this.textBox3.Text + "','" + this.textBox4.Text + "')"; SqlCommand cmdnar = new SqlCommand(zadatak, con); cmdnar.ExecuteNonQuery(); textBox2.Text = ""; textBox1.Text = ""; textBox3.Text = ""; textBox4.Text = ""; con.Close(); MessageBox.Show("Korisnik spremljen !"); }
private void button2_Click(object sender, EventArgs e) { var con = Baza.conn(); con.Open(); string zadatak = "INSERT INTO Servis_racunala(kvar,cijena,klijent,datum,Korisnik,Oznaka_potvrde) VALUES('" + this.textBox1.Text + "' , " + this.textBox2.Text + " , '" + this.textBox3.Text + "', '" + this.dateTimePicker1.Text + "' ,'" + this.prijavljeni + "','N' );"; SqlCommand cmd = new SqlCommand(zadatak, con); cmd.ExecuteNonQuery(); con.Close(); this.textBox1.Text = " "; this.textBox2.Text = " "; this.textBox3.Text = " "; MessageBox.Show("Servis spremljen!"); }
private void button2_Click(object sender, EventArgs e) { var con = Baza.conn(); con.Open(); SqlDataReader citac; string izmjeni = "UPDATE Servis_racunala set kvar = '" + this.textBox2.Text + "' where id = '" + textBox1.Text + "' ; "; SqlCommand cmd = new SqlCommand(izmjeni, con); citac = cmd.ExecuteReader(); citac.Close(); izmjeni = "UPDATE Servis_racunala set cijena = '" + this.textBox3.Text + "' where id = '" + textBox1.Text + "' ; "; cmd = new SqlCommand(izmjeni, con); citac = cmd.ExecuteReader(); citac.Close(); izmjeni = "UPDATE Servis_racunala set klijent = '" + this.textBox4.Text + "' where id = '" + textBox1.Text + "' ; "; cmd = new SqlCommand(izmjeni, con); citac = cmd.ExecuteReader(); citac.Close(); izmjeni = "UPDATE Servis_racunala set datum = '" + this.dateTimePicker1.Text + "' where id = '" + textBox1.Text + "' ; "; cmd = new SqlCommand(izmjeni, con); citac = cmd.ExecuteReader(); citac.Close(); servisi.Clear(); listView1.Items.Clear(); Ispisi(prijava); con.Close(); MessageBox.Show(" Izmjenjeno"); }
private void button1_Click(object sender, EventArgs e) { var con = Baza.conn(); prijavljeni = textBox1.Text; con.Open(); SqlDataAdapter prijava = new SqlDataAdapter("select count(*) from Korisnik where korisnik='" + textBox1.Text + "'and lozinka = '" + textBox2.Text + "'", con); DataTable dt = new DataTable(); prijava.Fill(dt); if (dt.Rows[0][0].ToString() == "1") { Izbornik otvori = new Izbornik(prijavljeni); this.Hide(); otvori.Show(); Servis_unos otvori_ = new Servis_unos(prijavljeni); MessageBox.Show(" Korisnik " + prijavljeni + " prijavljen"); } else { MessageBox.Show("Pogresno korisnicko ime ili lozinka"); } }
private void button3_Click(object sender, EventArgs e) { var con = Baza.conn(); con.Open(); string brisi = "delete from Servis_racunala where id = '" + textBox1.Text + "' ; "; SqlCommand brisi_cmd = new SqlCommand(brisi, con); SqlDataReader citac; citac = brisi_cmd.ExecuteReader(); if (citac.Read()) { con.Close(); listView1.Items.Clear(); this.textBox1.Text = ""; this.textBox2.Text = ""; this.textBox3.Text = ""; this.textBox4.Text = ""; MessageBox.Show("Obrisano"); } else { this.textBox1.Text = ""; this.textBox2.Text = ""; this.textBox3.Text = ""; this.textBox4.Text = ""; } servisi.Clear(); listView1.Items.Clear(); Ispisi(prijava); con.Close(); }
private void textBox5_TextChanged(object sender, EventArgs e) { var con = Baza.conn(); con.Open(); string izvadi = "select * from Servis_racunala where id = '" + textBox5.Text + "' ; "; SqlCommand izvadi_cmd = new SqlCommand(izvadi, con); SqlDataReader prijenos; prijenos = izvadi_cmd.ExecuteReader(); if (prijenos.Read()) { textBox3.Text = (prijenos["cijena"].ToString()); textBox2.Text = (prijenos["klijent"].ToString()); cijena = Int32.Parse(textBox3.Text); } else { textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; } con.Close(); }