Exemplo n.º 1
0
        public static void Vjezbe_Put(Vjezbe vj)
        {
            SQLiteCommand com = DB_connection.conn.CreateCommand();

            com.CommandText = String.Format(@"INSERT INTO VJEZBE (Naziv, Opis, Sutevi, Brzina, Brojac, Udaljenost, Drugo)
                                               VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}')", //insert querry
                                            vj.Naziv, vj.Opis, vj.Sutevi, vj.Brzina, vj.Brojac, vj.Udaljenost, vj.Drugo);
            com.ExecuteNonQuery();
            com.Dispose();//resource dispose
        }
Exemplo n.º 2
0
        public static List <Vjezbe> Vjezbe_Get_All()
        {
            var lista = new List <Vjezbe>();

            //command to execute from connection conn (iz DB_connection)
            SQLiteCommand com = DB_connection.conn.CreateCommand();

            //sql request
            com.CommandText = String.Format(@"SELECT * FROM VJEZBE");
            //command reader
            SQLiteDataReader reader = com.ExecuteReader();

            //read through every retrived row
            while (reader.Read())
            {
                Vjezbe v = new Vjezbe();           //instance of vjezbe for every row
                v.Id    = Convert.ToInt32(reader["ID"]);
                v.Naziv = (string)reader["Naziv"]; //casting (converting) to string
                if (reader["Opis"].GetType() != typeof(DBNull))
                {
                    v.Opis = (string)reader["Opis"];
                }//check if field is NULL (DBNull)
                v.Sutevi = (bool)reader["Sutevi"];
                if (reader["Brzina"].GetType() != typeof(DBNull))
                {
                    v.Brzina = (bool)reader["Brzina"];
                }
                v.Brojac = (bool)reader["Brojac"];
                if (reader["Udaljenost"].GetType() != typeof(DBNull))
                {
                    v.Udaljenost = (bool)reader["Udaljenost"];
                }
                if (reader["Drugo"].GetType() != typeof(DBNull))
                {
                    v.Drugo = (string)reader["Drugo"];
                }

                lista.Add(v); //add to list the new vjezba retrived from DB
            }
            com.Dispose();    //dispose of the command

            return(lista);    //return the list
        }
Exemplo n.º 3
0
        private void btnUnosVj01_Click(object sender, EventArgs e)
        {
            var vj = new Vjezbe();

            vj.Naziv = txtbUnosVj01.Text;
            vj.Opis  = txtbUnosVj02.Text;

            if (chbUnosVj05.Checked && txtbUnosVj03.Text.Length != 0)
            {
                vj.Drugo = txtbUnosVj03.Text;
            }

            if (chbUnosVj01.Checked)
            {
                vj.Sutevi = true;
            }
            if (chbUnosVj02.Checked)
            {
                vj.Brzina = true;
            }
            if (chbUnosVj03.Checked)
            {
                vj.Brojac = true;
            }
            if (chbUnosVj04.Checked)
            {
                vj.Udaljenost = true;
            }
            try
            {
                DB_connection.OpenConn();
                DB_PUT.Vjezbe_Put(vj);
                DB_connection.CloseConn();
                Change_label("Vježba " + vj.Naziv.ToString() + " unesena");
                btnUnosVjezbi02_Click(sender, e);
            }
            catch (ArgumentException err)
            {
                lblUnosResult.ForeColor = Color.Red;
                Change_label("Greška kod unosa vježbe: " + err.ToString());
            }
        }
Exemplo n.º 4
0
        public async Task LoadVjezbe()
        {
            VjezbaSearchRequest request = null;

            Vjezbe.Clear();
            if (Misic != null)
            {
                request = new VjezbaSearchRequest
                {
                    Misic = Misic.Naziv
                };
            }
            List <Model.Vjezba> _vjezbe = await _vjezbaService.Get <List <Model.Vjezba> >(request);

            if (_vjezbe.Count > 0)
            {
                foreach (var x in _vjezbe)
                {
                    Vjezbe.Add(x);
                }
            }
        }