public static int Delete(Veduci v, Database pDb)
        {
            Database db;

            if (pDb == null)
            {
                db = new Database();
                db.Connect();
            }
            else
            {
                db = pDb;
            }

            SqlCommand command = db.CreateCommand(SQL_DELETE_ID);

            PrepareCommand(command, v);
            int ret = db.ExecuteNonQuery(command);

            if (pDb == null)
            {
                db.Close();
            }

            return(ret);
        }
        public static int Insert(Veduci veduci, Database pDb)
        {
            Database db;

            if (pDb == null)
            {
                db = new Database();
                db.Connect();
            }
            else
            {
                db = pDb;
            }

            SqlCommand command = db.CreateCommand(SQL_INSERT);

            PrepareCommand(command, veduci);
            int ret = db.ExecuteNonQuery(command);

            if (pDb == null)
            {
                db.Close();
            }

            return(ret);
        }
        private static Collection <Veduci> Read(SqlDataReader reader)
        {
            Collection <Veduci> veduciCollection = new Collection <Veduci>();

            while (reader.Read())
            {
                int    i      = -1;
                Veduci veduci = new Veduci();
                veduci.id_veduci  = reader.GetInt32(++i);
                veduci.meno       = reader.GetString(++i);
                veduci.priezvisko = reader.GetString(++i);

                veduciCollection.Add(veduci);
            }
            return(veduciCollection);
        }
Пример #4
0
        public void SpustVyskum()
        {
            Veduci veduci = new Veduci("Fero");


            laboratorniPristroj1 = new Mikroskop();
            laboratorniPristroj2 = new Odstredivka();

            laboratorniPristroj1.Nazov = "mik200";
            laboratorniPristroj2.Nazov = "ods300";


            IOvladanie ovladanie = (IOvladanie)laboratorniPristroj1;

            ovladanie.Zapni();

            laboratorniPristroj1.VypisDetailneInfo();
            laboratorniPristroj2.VypisDetailneInfo();
        }
 private static void PrepareCommand(SqlCommand command, Veduci veduci)
 {
     command.Parameters.AddWithValue("@id_veduci", veduci.id_veduci);
     command.Parameters.AddWithValue("@meno", veduci.meno);
     command.Parameters.AddWithValue("@priezvisko", veduci.priezvisko);
 }