public int update(Zamestnanec Zamestnanec) { SqlCommand command = db.CreateCommand(SQL_UPDATE); PrepareCommandUpdate(command, Zamestnanec); return db.ExecuteNonQuery(command); }
private static void PrepareCommand2(SqlCommand command, Skupina Tym, Zamestnanec z) { command.Parameters.Add(new SqlParameter("@Zamestnanec_z_ID", SqlDbType.Int)); command.Parameters["@Zamestnanec_z_ID"].Value = z.z_ID; command.Parameters.Add(new SqlParameter("@Skupina_skup_ID", SqlDbType.Int)); command.Parameters["@Skupina_skup_ID"].Value = Tym.skup_ID; }
private static Collection<Zamestnanec> Read(SqlDataReader reader) { Collection<Zamestnanec> zams = new Collection<Zamestnanec>(); while (reader.Read()) { Zamestnanec z = new Zamestnanec(); z.z_ID = reader.GetInt32(0); z.jmeno = reader.GetString(1); z.prijmeni = reader.GetString(2); z.datum_narozeni = reader.GetDateTime(3); z.pozice = reader.GetString(4); z.platova_trida = reader.GetInt32(5); z.Oddeleni_o_ID = reader.GetInt32(6); if (!reader.IsDBNull(7)) { z.poznamka = reader.GetString(7); } zams.Add(z); } return zams; }
public int insert(Zamestnanec Zamestnanec) { SqlCommand command = db.CreateCommand(SQL_INSERT); PrepareCommandInsert(command, Zamestnanec); return db.ExecuteNonQuery(command); }
private void PrepareCommandUpdate(SqlCommand command, Zamestnanec Zamestnanec) { command.Parameters.Add(new SqlParameter("@z_ID", SqlDbType.Int)); command.Parameters["@z_ID"].Value = Zamestnanec.z_ID; command.Parameters.Add(new SqlParameter("@jmeno", SqlDbType.VarChar, Zamestnanec.LEN_ATTR_jmeno)); command.Parameters["@jmeno"].Value = Zamestnanec.jmeno; command.Parameters.Add(new SqlParameter("@prijmeni", SqlDbType.VarChar, Zamestnanec.LEN_ATTR_prijmeni)); command.Parameters["@prijmeni"].Value = Zamestnanec.prijmeni; command.Parameters.Add(new SqlParameter("@datum_narozeni", SqlDbType.DateTime)); command.Parameters["@datum_narozeni"].Value = Zamestnanec.datum_narozeni; command.Parameters.Add(new SqlParameter("@pozice", SqlDbType.VarChar, Zamestnanec.LEN_ATTR_pozice)); command.Parameters["@pozice"].Value = Zamestnanec.pozice; command.Parameters.Add(new SqlParameter("@platova_trida", SqlDbType.Int)); command.Parameters["@platova_trida"].Value = Zamestnanec.platova_trida; command.Parameters.Add(new SqlParameter("@oddeleni_o_ID", SqlDbType.Int)); command.Parameters["@oddeleni_o_ID"].Value = Zamestnanec.Oddeleni_o_ID; command.Parameters.Add(new SqlParameter("@poznamka", SqlDbType.VarChar, Zamestnanec.LEN_ATTR_poznamka)); command.Parameters["@poznamka"].Value = Zamestnanec.poznamka; }