public override bool Update(Model obj) { OrganizacniUroven3 ins = (OrganizacniUroven3)obj; using (var c = ConnetionFactory.GetOracleConnection()) { using (var cmd = c.CreateCommand()) { try { cmd.CommandText = UPDATE; cmd.Parameters.Add(":id_org2", ins.IdOrganizacniUroven2); cmd.Parameters.Add(":kod", ins.Kod); cmd.Parameters.Add(":popis", ins.Popis); cmd.Parameters.Add(":poznamka", ins.Poznamka); cmd.Parameters.Add(":id", ins.Id); cmd.ExecuteNonQuery(); return(true); } catch (OracleException oe) { Log(oe.Message); return(false); } } } }
public override List <Model> SelectAll() { List <Model> result = new List <Model>(); using (var c = ConnetionFactory.GetOracleConnection()) { using (var cmd = c.CreateCommand()) { try { cmd.CommandText = SELECT_ALL; OracleDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { int i = -1; OrganizacniUroven3 organizacniUroven3 = new OrganizacniUroven3 { Id = reader.GetString(++i), IdOrganizacniUroven2 = reader.GetString(++i), Kod = reader.GetString(++i), Popis = !reader.IsDBNull(++i) ? reader.GetString(i) : null, Poznamka = !reader.IsDBNull(++i) ? reader.GetString(i) : null }; result.Add(organizacniUroven3); } return(result); } catch (OracleException oe) { Log(oe.Message); return(null); } } } }
public override bool Delete(Model obj) { OrganizacniUroven3 del = (OrganizacniUroven3)obj; using (var c = ConnetionFactory.GetOracleConnection()) { using (var cmd = c.CreateCommand()) { try { cmd.CommandText = DELETE; cmd.Parameters.Add(":id", del.Id); cmd.ExecuteNonQuery(); return(true); } catch (OracleException oe) { Log(oe.Message); return(false); } } } }