public List <IOpstiDomenskiObjekat> SelectAll(IOpstiDomenskiObjekat odo) { komanda.CommandText = $"Select * from {odo.VratiImeTabele()}"; komanda.CommandType = System.Data.CommandType.Text; OleDbDataReader citac = komanda.ExecuteReader(); List <IOpstiDomenskiObjekat> lista = odo.VratiListu(citac); citac.Close(); return(lista); }
public List <IOpstiDomenskiObjekat> VratiSve(IOpstiDomenskiObjekat odo) { List <IOpstiDomenskiObjekat> lista; komanda.CommandText = $"SELECT * FROM {odo.VratiImeTabele()}"; komanda.CommandType = CommandType.Text; OleDbDataReader citac = komanda.ExecuteReader(); lista = odo.VratiListu(citac); citac.Close(); return(lista); }
public IOpstiDomenskiObjekat VratiPrvog(IOpstiDomenskiObjekat odo) { IOpstiDomenskiObjekat objekat; komanda.CommandText = $"SELECT * FROM {odo.VratiImeTabele()} WHERE {odo.VratiKljucIUslov()}"; komanda.CommandType = CommandType.Text; OleDbDataReader citac = komanda.ExecuteReader(); objekat = odo.VratiObjekat(citac); citac.Close(); return(objekat); }
public bool Azuriraj(IOpstiDomenskiObjekat odo) { try { string upit = "UPDATE " + odo.VratiImeTabele() + " SET " + odo.VratiVrednostiZaAzuriranje() + " WHERE " + odo.VratiKljucniAtribut(); OleDbCommand komanda = new OleDbCommand(upit, konekcija, transakcija); komanda.ExecuteNonQuery(); return(true); } catch (Exception) { return(false); } }
public bool Obrisi(IOpstiDomenskiObjekat odo) { try { string upit = "DELETE FROM " + odo.VratiImeTabele() + " WHERE " + odo.VratiKljucniAtribut(); komanda = new OleDbCommand(upit, konekcija, transakcija); komanda.ExecuteNonQuery(); return(true); } catch { return(false); } }
public int SelectMax(IOpstiDomenskiObjekat odo) { komanda.CommandText = $"Select max({odo.VratiKljucZaMax()}) from {odo.VratiImeTabele()}"; komanda.CommandType = System.Data.CommandType.Text; var res = komanda.ExecuteScalar(); if (res != DBNull.Value) { return(Convert.ToInt32(res) + 1); } else { return(11); } }
public List <IOpstiDomenskiObjekat> VratiSveObjektePoUslovu(IOpstiDomenskiObjekat odo) { try { string upit = "SELECT * FROM " + odo.VratiImeTabele() + " WHERE " + odo.VratiUslovZaObjekat(); komanda = new OleDbCommand(upit, konekcija, transakcija); OleDbDataReader citac = komanda.ExecuteReader(); return(odo.VratiListu(citac)); } catch (Exception ex) { throw ex; } }
public bool Unesi(IOpstiDomenskiObjekat odo) { try { // string upit = "INSERT INTO " + odo.VratiImeTabele() + " VALUES " + odo.VratiVrednostiZaInsert(); string upit = $"Insert into {odo.VratiImeTabele()} {odo.VratiKoloneZaInsert()} values {odo.VratiVrednostiZaInsert()}"; komanda = new OleDbCommand(upit, konekcija, transakcija); komanda.ExecuteNonQuery(); return(true); } catch (Exception e) { return(false); } }
public bool Obrisi(IOpstiDomenskiObjekat odo) { komanda.CommandText = $"DELETE FROM {odo.VratiImeTabele()} WHERE {odo.VratiKljucIUslov()}"; komanda.CommandType = CommandType.Text; int rezultat = komanda.ExecuteNonQuery(); if (rezultat == 1) { return(true); } else { throw new Exception(); } }
//public List<IOpstiDomenskiObjekat> VratiSveKljuc(IOpstiDomenskiObjekat odo) //{ // List<IOpstiDomenskiObjekat> lista; // komanda.CommandText = $"SELECT * FROM {odo.VratiImeTabele()} WHERE {odo.VratiKljucIUslov()}"; // komanda.CommandType = CommandType.Text; // OleDbDataReader citac = komanda.ExecuteReader(); // lista = odo.VratiListu(citac); // citac.Close(); // return lista; //} public bool Izmeni(IOpstiDomenskiObjekat odo) { komanda.CommandText = $"UPDATE {odo.VratiImeTabele()} SET {odo.VratiZaIzmenu()} " + $"WHERE {odo.VratiKljucIUslov()}"; komanda.CommandType = CommandType.Text; int rezultat = komanda.ExecuteNonQuery(); if (rezultat == 1) { return(true); } else { throw new Exception(); } }
public object Ubaci(IOpstiDomenskiObjekat odo) { komanda.CommandText = $"INSERT INTO {odo.VratiImeTabele()} ({odo.VratiKoloneZaInsert()}) " + $"VALUES ({odo.VratiVrednostiZaInsert()})"; komanda.CommandType = CommandType.Text; int rezultat = komanda.ExecuteNonQuery(); if (rezultat == 1) { komanda.CommandText = "SELECT @@IDENTITY"; object id = komanda.ExecuteScalar(); return(id); } else { throw new Exception(); } }
public object UnesiIVratiID(IOpstiDomenskiObjekat odo) { string upit = $"Insert into {odo.VratiImeTabele()} {odo.VratiKoloneZaInsert()} values {odo.VratiVrednostiZaInsert()}"; komanda = new OleDbCommand(upit, konekcija, transakcija); int rezultat = komanda.ExecuteNonQuery(); if (rezultat == 1) { komanda.CommandText = "SELECT @@IDENTITY"; object id = komanda.ExecuteScalar(); return(id); } else { throw new Exception(); } }
public void Update(IOpstiDomenskiObjekat odo) { komanda.CommandText = $"Update {odo.VratiImeTabele()} set {odo.VratiVrednostZaUpdate()} where {odo.VratiKljucIUslov()}"; komanda.CommandType = System.Data.CommandType.Text; komanda.ExecuteNonQuery(); }
public int Insert(IOpstiDomenskiObjekat odo) { komanda.CommandText = $"Insert into {odo.VratiImeTabele()} values ({odo.VratiVrednostiZaInsert()})"; komanda.CommandType = System.Data.CommandType.Text; return(komanda.ExecuteNonQuery()); }
public void Delete(IOpstiDomenskiObjekat odo) { komanda.CommandText = $"Delete from {odo.VratiImeTabele()} where {odo.VratiKljucIUslov()}"; komanda.CommandType = System.Data.CommandType.Text; komanda.ExecuteNonQuery(); }
public int vratiMaxID(IOpstiDomenskiObjekat odo) { try { string upit = "Select Max(" + odo.VratiNazivKljucnogAtributa() + ") as MaxBroj from " + odo.VratiImeTabele(); komanda = new OleDbCommand(upit, konekcija, transakcija); OleDbDataReader citac = komanda.ExecuteReader(); if (citac.Read()) { try { int rezultat = Convert.ToInt32(citac["MaxBroj"]); return(rezultat + 1); } catch { } } return(1); } catch (Exception ex) { throw ex; // return 1; } }