Exemplo n.º 1
0
        private void btnNoviKorak_Click(object sender, EventArgs e)
        {
            if (tbOpisKoraka.Text.Equals("") && lbKoraci.Items.Count > 0)
            {
                MessageBox.Show("Pre nego sto dodate novi korak, popunite opis ovog i sacuvajte ga!");
                return;
            }

            noviKorak = new Korak(p.Id_proizvod, p.GetKoraci().Count + 1, "");
            p.GetKoraci().Add(noviKorak);
            SetKoraci();
            lbKoraci.SetSelected(lbKoraci.Items.Count - 1, true);
        }
Exemplo n.º 2
0
        public List <Korak> GetKoraci()
        {
            using (OracleConnection connection = new OracleConnection(connectionString))
            {
                connection.Open();
                string           sql        = "select * from koraci";
                OracleCommand    command    = new OracleCommand(sql, connection);
                OracleDataReader dataReader = command.ExecuteReader();

                List <Korak> koraci = new List <Korak>();

                while (dataReader.Read())
                {
                    Korak korak = new Korak(dataReader.GetInt32(0), dataReader.GetInt32(1), dataReader.GetString(2));
                    koraci.Add(korak);
                }

                return(koraci);
            }
        }
Exemplo n.º 3
0
        public string UpdateKorak(Korak korak)
        {
            using (OracleConnection connection = new OracleConnection(ConnectionString.GetString()))
            {
                connection.Open();
                string sql = "update koraci set opis = \'" + korak.Opis +
                             "\' where id_proizvod = " + korak.Id_proizvod +
                             " and redni_broj = " + korak.Redni_broj;
                OracleCommand command = new OracleCommand(sql, connection);

                try
                {
                    command.ExecuteNonQuery();
                    return("Uspesno azuriran korak!");
                }
                catch
                {
                    return("Greska prilikom azuriranja koraka!");
                }
            }
        }
Exemplo n.º 4
0
        public string InsertKorak(Korak korak)
        {
            using (OracleConnection connection = new OracleConnection(ConnectionString.GetString()))
            {
                connection.Open();
                string sql = "insert into koraci values(" + korak.Id_proizvod +
                             "," + korak.Redni_broj +
                             ", \'" + korak.Opis +
                             "\')";
                OracleCommand command = new OracleCommand(sql, connection);

                try
                {
                    command.ExecuteNonQuery();
                    return("Uspesno unet novi korak!");
                }
                catch
                {
                    return("Greska prilikom unosenja novog koraka!");
                }
            }
        }
Exemplo n.º 5
0
        public List <Korak> GetKoraciByProizvod(int id_proizvod)
        {
            using (OracleConnection connection = new OracleConnection(ConnectionString.GetString()))
            {
                connection.Open();
                string        sql     = "select * from koraci where id_proizvod = " + id_proizvod + " order by redni_broj";
                OracleCommand command = new OracleCommand(sql, connection);

                OracleDataReader dr = command.ExecuteReader();

                List <Korak> koraci = new List <Korak>();

                while (dr.Read())
                {
                    Korak korak = new Korak(dr.GetInt32(0),
                                            dr.GetInt32(1),
                                            dr.GetString(2));
                    koraci.Add(korak);
                }

                return(koraci);
            }
        }
Exemplo n.º 6
0
        public string UpdateKorak(Korak korak)
        {
            KoraciRepository KR = new KoraciRepository();

            return(KR.UpdateKorak(korak));
        }
Exemplo n.º 7
0
        public string InsertKorak(Korak korak)
        {
            KoraciRepository KR = new KoraciRepository();

            return(KR.InsertKorak(korak));
        }