Beispiel #1
0
        public override bool Update(Model obj)
        {
            OrganizacniUroven1 ins = (OrganizacniUroven1)obj;

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = UPDATE;
                        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);
                    }
                }
            }
        }
Beispiel #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;
                            OrganizacniUroven1 organizacniUroven1 = new OrganizacniUroven1
                            {
                                Id       = 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(organizacniUroven1);
                        }
                        return(result);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(null);
                    }
                }
            }
        }
Beispiel #3
0
        public override bool Delete(Model obj)
        {
            OrganizacniUroven1 del = (OrganizacniUroven1)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);
                    }
                }
            }
        }