Ejemplo n.º 1
0
        public override List <Model> SelectAll()
        {
            List <Model> result = new List <Model>();

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = SELECT_ALL;
                        OracleDataReader reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            int   i     = -1;
                            Dilec oddec = new Dilec
                            {
                                Id         = reader.GetString(++i),
                                IdOddeleni = reader.GetString(++i),
                                Kod        = reader.GetString(++i),
                            };
                            result.Add(oddec);
                        }
                        return(result);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(null);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override bool Update(Model obj)
        {
            Dilec ins = (Dilec)obj;

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = UPDATE;
                        cmd.Parameters.Add(":id_odd", ins.IdOddeleni);
                        cmd.Parameters.Add(":kod", ins.Kod);
                        cmd.Parameters.Add(":id", ins.Id);
                        cmd.ExecuteNonQuery();
                        return(true);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(false);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public override bool Delete(Model obj)
        {
            Dilec del = (Dilec)obj;

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = DELETE;
                        cmd.Parameters.Add(":id", del.Id);
                        cmd.ExecuteNonQuery();
                        return(true);
                    }

                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(false);
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public List <Porost> LoadPorosty(Dilec dil)
 {
     return(db.PorostTableGateway.SelectByDilec(dil).Cast <Porost>().ToList());
 }