private void PrepareCommandInsert(SqlCommand command, Oddeleni Oddeleni) { command.Parameters.Add(new SqlParameter("@nazev", SqlDbType.VarChar, Oddeleni.LEN_ATTR_nazev)); command.Parameters["@nazev"].Value = Oddeleni.nazev; command.Parameters.Add(new SqlParameter("@pocet_zamestnancu", SqlDbType.Int)); command.Parameters["@pocet_zamestnancu"].Value = Oddeleni.pocet_zamestnancu; command.Parameters.Add(new SqlParameter("@poznamka", SqlDbType.VarChar, Oddeleni.LEN_ATTR_poznamka)); command.Parameters["@poznamka"].Value = Oddeleni.poznamka; }
public int update(Oddeleni Oddeleni) { SqlCommand command = db.CreateCommand(SQL_UPDATE); PrepareCommandUpdate(command, Oddeleni); return db.ExecuteNonQuery(command); }
private static Collection<Oddeleni> Read(SqlDataReader reader) { Collection<Oddeleni> oddelenis = new Collection<Oddeleni>(); while (reader.Read()) { Oddeleni o = new Oddeleni(); o.o_ID = reader.GetInt32(0); o.nazev = reader.GetString(1); o.pocet_zamestnancu = reader.GetInt32(2); if (!reader.IsDBNull(3)) { o.poznamka = reader.GetString(3); } oddelenis.Add(o); } return oddelenis; }
public int insert(Oddeleni Oddeleni) { SqlCommand command = db.CreateCommand(SQL_INSERT); PrepareCommandInsert(command, Oddeleni); return db.ExecuteNonQuery(command); }