Ejemplo n.º 1
0
        public List <Model> SelectByLhc(LesniHospodarskyCelek lhc)
        {
            List <Model> result = new List <Model>();

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = SELECT_LHC;
                        cmd.Parameters.Add(":id_lhc", lhc.Id);
                        OracleDataReader reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            int      i        = -1;
                            Oddeleni oddeleni = new Oddeleni
                            {
                                Id = reader.GetString(++i),
                                IdLesniHospodarskyCelek = reader.GetString(++i),
                                Kod = reader.GetString(++i),
                            };
                            result.Add(oddeleni);
                        }
                        return(result);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(null);
                    }
                }
            }
        }
Ejemplo n.º 2
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;
                            Drevina drevina = new Drevina
                            {
                                Id       = reader.GetString(++i),
                                Kod      = reader.GetString(++i),
                                Popis    = !reader.IsDBNull(++i) ? reader.GetString(i) : null,
                                Poznamka = !reader.IsDBNull(++i) ? reader.GetString(i) : null,
                                Hustota  = !reader.IsDBNull(++i) ? reader.GetDouble(i) : 0.0
                            };
                            result.Add(drevina);
                        }
                        return(result);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(null);
                    }
                }
            }
        }
        public List <Model> SelectByPorost(Model por)
        {
            List <Model> result = new List <Model>();

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = SELECT_POR;
                        cmd.Parameters.Add(":id_por", por.Id);
                        OracleDataReader reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            int             i     = -1;
                            PorostniSkupina porec = new PorostniSkupina
                            {
                                Id       = reader.GetString(++i),
                                IdPorost = reader.GetString(++i),
                                Kod      = reader.GetString(++i),
                            };
                            result.Add(porec);
                        }
                        return(result);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(null);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public override bool Update(Model obj)
        {
            Uzivatel ins = (Uzivatel)obj;

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = UPDATE;
                        cmd.Parameters.Add(":username", ins.Username);
                        cmd.Parameters.Add(":pass_sha256", ins.Password);
                        cmd.Parameters.Add(":role", ins.Role);
                        cmd.Parameters.Add(":jmeno", ins.Jmeno);
                        cmd.Parameters.Add(":email", ins.Email);
                        cmd.Parameters.Add(":id", ins.Id);
                        cmd.ExecuteNonQuery();
                        return(true);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(false);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public override bool Insert(Model obj)
        {
            Oddeleni ins = (Oddeleni)obj;

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = INSERT;
                        cmd.Parameters.Add(":id", ins.Id);
                        cmd.Parameters.Add(":id_lhc", ins.IdLesniHospodarskyCelek);
                        cmd.Parameters.Add(":kod", ins.Kod);
                        cmd.ExecuteNonQuery();
                        return(true);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(false);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public List <Model> SelectByDilec(Model dil)
        {
            List <Model> result = new List <Model>();

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = SELECT_DIL;
                        cmd.Parameters.Add(":id_dil", dil.Id);
                        OracleDataReader reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            int    i     = -1;
                            Porost dilec = new Porost
                            {
                                Id      = reader.GetString(++i),
                                IdDilec = reader.GetString(++i),
                                Kod     = reader.GetString(++i),
                            };
                            result.Add(dilec);
                        }
                        return(result);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(null);
                    }
                }
            }
        }
        public override bool Update(Model obj)
        {
            OrganizacniUroven3 ins = (OrganizacniUroven3)obj;

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = UPDATE;
                        cmd.Parameters.Add(":id_org2", ins.IdOrganizacniUroven2);
                        cmd.Parameters.Add(":kod", ins.Kod);
                        cmd.Parameters.Add(":popis", ins.Popis);
                        cmd.Parameters.Add(":poznamka", ins.Poznamka);
                        cmd.Parameters.Add(":id", ins.Id);
                        cmd.ExecuteNonQuery();
                        return(true);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(false);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public override bool Update(Model obj)
        {
            LesniHospodarskaEvidence ins = (LesniHospodarskaEvidence)obj;

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = UPDATE;
                        cmd.Parameters.Add(":id_psk", ins.IdPorostniSkupina);
                        cmd.Parameters.Add(":id_podvykon", ins.IdPodvykon);
                        cmd.Parameters.Add(":id_druzhtezby", ins.IdDruhTezby);
                        cmd.Parameters.Add(":id_drevina", ins.IdDrevina);
                        cmd.Parameters.Add(":plocha", ins.Plocha);
                        cmd.Parameters.Add(":mnozstvi", ins.Mnozstvi);
                        cmd.Parameters.Add(":datum", ins.Datum);
                        cmd.Parameters.Add(":poznamka", ins.Poznamka);
                        cmd.Parameters.Add(":id", ins.Id);
                        cmd.ExecuteNonQuery();
                        return(true);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(false);
                    }
                }
            }
        }
Ejemplo n.º 9
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.º 10
0
        public override bool Insert(Model obj)
        {
            Lokalita ins = (Lokalita)obj;

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = INSERT;
                        cmd.Parameters.Add(":id", ins.Id);
                        cmd.Parameters.Add(":kod", ins.Kod);
                        cmd.Parameters.Add(":popis", ins.Popis);
                        cmd.Parameters.Add(":poznamka", ins.Poznamka);
                        cmd.ExecuteNonQuery();
                        return(true);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(false);
                    }
                }
            }
        }
Ejemplo n.º 11
0
        public override bool Update(Model obj)
        {
            Holina ins = (Holina)obj;

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = UPDATE;
                        cmd.Parameters.Add(":id_psk", ins.IdPorostniSkupina);
                        cmd.Parameters.Add(":souradnice", ins.Souradnice);
                        cmd.Parameters.Add(":rok_vzniku", ins.RokVzniku);
                        cmd.Parameters.Add(":poznamka", ins.Poznamka);
                        cmd.Parameters.Add(":plocha", ins.Plocha);
                        cmd.Parameters.Add(":id", ins.Id);
                        cmd.ExecuteNonQuery();
                        return(true);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(false);
                    }
                }
            }
        }
Ejemplo n.º 12
0
        public List <Model> SelectByUser(Uzivatel uzivatel)
        {
            List <Model> result = new List <Model>();

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = SELECT_ALL;
                        cmd.Parameters.Add(":id_uzivatel", uzivatel.Id);
                        OracleDataReader reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            int i = -1;
                            LesniHospodarskyCelek lesniHospodarskyCelek = new LesniHospodarskyCelek
                            {
                                Id  = reader.GetString(++i),
                                Kod = reader.GetString(++i),
                            };
                            result.Add(lesniHospodarskyCelek);
                        }
                        return(result);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(null);
                    }
                }
            }
        }
Ejemplo n.º 13
0
        public override bool Insert(Model obj)
        {
            Porost ins = (Porost)obj;

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = INSERT;
                        cmd.Parameters.Add(":id", ins.Id);
                        cmd.Parameters.Add(":id_dil", ins.IdDilec);
                        cmd.Parameters.Add(":kod", ins.Kod);
                        cmd.ExecuteNonQuery();
                        return(true);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(false);
                    }
                }
            }
        }
Ejemplo n.º 14
0
        public override bool Insert(Model obj)
        {
            Zalesneni ins = (Zalesneni)obj;

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = INSERT;
                        cmd.Parameters.Add(":id", ins.Id);
                        cmd.Parameters.Add(":id_psk", ins.IdPorostniSkupina);
                        cmd.Parameters.Add(":id_drevina", ins.IdDrevina);
                        cmd.Parameters.Add(":plocha", ins.Plocha);
                        cmd.Parameters.Add(":souradnice", ins.Souradnice);
                        cmd.Parameters.Add(":rok_vzniku", ins.RokVzniku);
                        cmd.Parameters.Add(":procent_pudy", ins.ProcentPudy);
                        cmd.ExecuteNonQuery();
                        return(true);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(false);
                    }
                }
            }
        }
        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;
                            OrganizacniUroven3 organizacniUroven3 = new OrganizacniUroven3
                            {
                                Id = reader.GetString(++i),
                                IdOrganizacniUroven2 = reader.GetString(++i),
                                Kod      = reader.GetString(++i),
                                Popis    = !reader.IsDBNull(++i) ? reader.GetString(i) : null,
                                Poznamka = !reader.IsDBNull(++i) ? reader.GetString(i) : null
                            };
                            result.Add(organizacniUroven3);
                        }
                        return(result);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(null);
                    }
                }
            }
        }
Ejemplo n.º 16
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);
                    }
                }
            }
        }
        public override bool Update(Model obj)
        {
            OdvozniListek ins = (OdvozniListek)obj;

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = UPDATE;
                        cmd.Parameters.Add(":id_org3", ins.IdOrganizacniUroven3);
                        cmd.Parameters.Add(":id_sort", ins.IdSortiment);
                        cmd.Parameters.Add(":id_podvykon", ins.IdPodvykon);
                        cmd.Parameters.Add(":id_lokalita", ins.IdLokalita);
                        cmd.Parameters.Add(":id_psk", ins.IdPorostniSkupina);
                        cmd.Parameters.Add(":datum_odvozu", ins.DatumOdvozu);
                        cmd.Parameters.Add(":mnozstvi", ins.Mnozstvi);
                        cmd.Parameters.Add(":spz", ins.Spz);
                        cmd.Parameters.Add(":odberatel", ins.Odberatel);
                        cmd.Parameters.Add(":ujete_km", ins.UjeteKm);
                        cmd.Parameters.Add(":id", ins.Id);
                        cmd.ExecuteNonQuery();
                        return(true);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(false);
                    }
                }
            }
        }
        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;
                            OdvozniListek odvozniListek = new OdvozniListek
                            {
                                Id = reader.GetString(++i),
                                IdOrganizacniUroven3 = reader.GetString(++i),
                                IdSortiment          = reader.GetString(++i),
                                IdPodvykon           = reader.GetString(++i),
                                IdLokalita           = reader.GetString(++i),
                                IdPorostniSkupina    = reader.GetString(++i),
                                DatumOdvozu          = reader.GetDateTime(++i),
                                Mnozstvi             = reader.GetDouble(++i),
                                Spz       = !reader.IsDBNull(++i) ?  reader.GetString(i) : null,
                                Odberatel = !reader.IsDBNull(++i) ? reader.GetString(i) : null,
                                UjeteKm   = !reader.IsDBNull(++i) ?  reader.GetInt32(i) : -1
                            };
                            result.Add(odvozniListek);
                        }
                        return(result);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(null);
                    }
                }
            }
        }
Ejemplo n.º 19
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;
                            LesniHospodarskaEvidence lesniHospodarskaEvidence = new LesniHospodarskaEvidence
                            {
                                Id = reader.GetString(++i),
                                IdPorostniSkupina = reader.GetString(++i),
                                IdPodvykon        = reader.GetString(++i),
                                IdDruhTezby       = reader.GetString(++i),
                                IdDrevina         = reader.GetString(++i),
                                Plocha            = reader.GetDouble(++i),
                                Mnozstvi          = reader.GetDouble(++i),
                                Datum             = reader.GetDateTime(++i),
                                Poznamka          = !reader.IsDBNull(++i) ? reader.GetString(i) : null
                            };
                            result.Add(lesniHospodarskaEvidence);
                        }
                        return(result);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(null);
                    }
                }
            }
        }
Ejemplo n.º 20
0
        public Model SelectByName(string username)
        {
            List <Model> result = new List <Model>();

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = SELECT_BY_NAME;
                        cmd.Parameters.Add(":username", username);
                        OracleDataReader reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            int      i        = -1;
                            Uzivatel uzivatel = new Uzivatel
                            {
                                Id       = reader.GetString(++i),
                                Username = reader.GetString(++i),
                                Password = reader.GetString(++i),
                                Role     = reader.GetInt16(++i),
                                Jmeno    = reader.GetString(++i),
                                Email    = reader.GetString(++i)
                            };
                            result.Add(uzivatel);
                        }
                        return(result.Count > 0 ? result[0] : null);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(null);
                    }
                }
            }
        }
Ejemplo n.º 21
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;
                            Zalesneni zalesneni = new Zalesneni
                            {
                                Id = reader.GetString(++i),
                                IdPorostniSkupina = reader.GetString(++i),
                                IdDrevina         = reader.GetString(++i),
                                Plocha            = reader.GetDouble(++i),
                                Souradnice        = reader.GetString(++i),
                                RokVzniku         = reader.GetInt32(++i),
                                ProcentPudy       = reader.GetDouble(++i)
                            };
                            result.Add(zalesneni);
                        }
                        return(result);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(null);
                    }
                }
            }
        }
Ejemplo n.º 22
0
        public List <Model> SelectByVykon(Model vykon)
        {
            List <Model> result = new List <Model>();

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = SELECT_VYKON;
                        cmd.Parameters.Add(":id_vykon", vykon.Id);
                        OracleDataReader reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            int      i        = -1;
                            Podvykon podvykon = new Podvykon
                            {
                                Id       = reader.GetString(++i),
                                IdVykon  = reader.GetString(++i),
                                Kod      = reader.GetString(++i),
                                Popis    = !reader.IsDBNull(++i) ? reader.GetString(i) : null,
                                Poznamka = !reader.IsDBNull(++i) ? reader.GetString(i) : null
                            };
                            result.Add(podvykon);
                        }
                        return(result);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(null);
                    }
                }
            }
        }
Ejemplo n.º 23
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;
                            Uzivatel uzivatel = new Uzivatel
                            {
                                Id       = reader.GetString(++i),
                                Username = reader.GetString(++i),
                                Password = reader.GetString(++i),
                                Role     = reader.GetInt16(++i),
                                Jmeno    = reader.GetString(++i),
                                Email    = reader.GetString(++i)
                            };
                            result.Add(uzivatel);
                        }
                        return(result);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(null);
                    }
                }
            }
        }
Ejemplo n.º 24
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);
                    }
                }
            }
        }