Exemple #1
0
 public int IzmeniClana(Clan cl)
 {
     SqlConnection kon = new SqlConnection(Konekcija.cnnVideoKlub);
     SqlCommand sqlCom = new SqlCommand("IzmeniClana", kon);
     sqlCom.CommandType = CommandType.StoredProcedure;
     sqlCom.Parameters.Add("@clanID", SqlDbType.Int);
     sqlCom.Parameters["@clanID"].Value = cl.ClanID;
     sqlCom.Parameters.Add("@ime", SqlDbType.NVarChar);
     sqlCom.Parameters["@ime"].Value = cl.Ime;
     sqlCom.Parameters.Add("@prezime", SqlDbType.NVarChar);
     sqlCom.Parameters["@prezime"].Value = cl.Prezime;
     sqlCom.Parameters.Add("@jmbg", SqlDbType.NVarChar);
     sqlCom.Parameters["@jmbg"].Value = cl.Jmbg;
     sqlCom.Parameters.Add("@adresa", SqlDbType.NVarChar);
     sqlCom.Parameters["@adresa"].Value = cl.Adresa;
     sqlCom.Parameters.Add("@telefon", SqlDbType.NVarChar);
     sqlCom.Parameters["@telefon"].Value = cl.Telefon;
     try
     {
     kon.Open();
     sqlCom.ExecuteNonQuery();
     return 0;
     }
     catch
     {
     return -1;
     }
     finally
     {
     kon.Close();
     }
 }
Exemple #2
0
 public List<Clan> IscitajListuClanova()
 {
     SqlConnection kon  = new SqlConnection(Konekcija.cnnVideoKlub);
     List<Clan> Clanovi = new List<Clan>();
     SqlCommand sqlCom  = new SqlCommand("select * from Clan",kon);
     kon.Open();
     SqlDataReader dr   = sqlCom.ExecuteReader();
     while (dr.Read())
     {
     Clan cl            = new Clan();
     cl.ClanID          = Int32.Parse(dr["ClanID"].ToString());
     cl.Ime             = dr["Ime"].ToString();
     cl.Prezime         = dr["Prezime"].ToString();
     cl.Jmbg            = dr["Jmbg"].ToString();
     cl.Adresa          = dr["Adresa"].ToString();
     cl.Telefon         = dr["Telefon"].ToString();
     Clanovi.Add(cl);
     }
     kon.Close();
     return Clanovi;
 }
Exemple #3
0
 public int IzbrisiClana(Clan cl)
 {
     SqlConnection kon = new SqlConnection(Konekcija.cnnVideoKlub);
     SqlCommand sqlCom = new SqlCommand("IzbrisiClana", kon);
     sqlCom.CommandType = CommandType.StoredProcedure;
     sqlCom.Parameters.Add("@clanID", SqlDbType.NVarChar);
     sqlCom.Parameters["@clanID"].Value = cl.ClanID;
     try
     {
     kon.Open();
     sqlCom.ExecuteNonQuery();
     return 0;
     }
     catch
     {
     return -1;
     }
     finally
     {
     kon.Close();
     }
 }
Exemple #4
0
 private void buttonPotvrdi_Click(object sender, EventArgs e)
 {
     Clan cl = new Clan();
     cl.ClanID = Convert.ToInt32(listBox1.SelectedValue);
     cl.Ime = textBoxIme.Text;
     cl.Prezime = textBoxPrezime.Text;
     cl.Jmbg = textBoxJmbg.Text;
     cl.Adresa = textBoxAdresa.Text;
     cl.Telefon = textBoxTelefon.Text;
     int rez = cp.IzmeniClana(cl);
     if (rez == 0)
     {
         napuniListuClanova();
         listBox1.SelectedValue = cl.ClanID;
         MessageBox.Show("Uspesno ste izmenili clana", "Clan promenjen");
         Dozvoli(false);
     }
     else
     {
         MessageBox.Show("Greska pri izmeni clana", "Clan nije promenjen");
         return;
     }
 }
Exemple #5
0
 private void buttonDodaj_Click(object sender, EventArgs e)
 {
     Clan cl = new Clan();
     int rez = -1;
     try
     {
         cl.Ime = textBoxIme.Text;
         cl.Prezime = textBoxPrezime.Text;
         cl.Jmbg = textBoxJmbg.Text;
         cl.Adresa = textBoxAdresa.Text;
         cl.Telefon = textBoxTelefon.Text;
         rez = cp.UbaciClana(cl);
     }
     catch
     {
         MessageBox.Show("Greska pri unosu podataka", "Greska");
         return;
     }
     if (rez == 0)
     {
         MessageBox.Show("Uspesno ste ubacili clana", "Poruka");
     }
     this.Close();
 }