コード例 #1
0
        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;
        }
コード例 #2
0
 public int update(Oddeleni Oddeleni)
 {
     SqlCommand command = db.CreateCommand(SQL_UPDATE);
     PrepareCommandUpdate(command, Oddeleni);
     return db.ExecuteNonQuery(command);
 }
コード例 #3
0
        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;
        }
コード例 #4
0
 public int insert(Oddeleni Oddeleni)
 {
     SqlCommand command = db.CreateCommand(SQL_INSERT);
     PrepareCommandInsert(command, Oddeleni);
     return db.ExecuteNonQuery(command);
 }