Example #1
0
        public List <Izdavac> GetAllIzdavac()
        {
            var             result = new List <Izdavac>();
            MySqlConnection conn   = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = SELECT;
                reader          = cmd.ExecuteReader();
                while (reader.Read())
                {
                    result.Add(new Izdavac()
                    {
                        IdIzdavac = reader.GetInt32(0),
                        IdMjesto  = reader.GetInt32(1),
                        Naziv     = reader.GetString(2),
                        Adresa    = reader.GetString(3)
                    });
                }
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlIzdavac", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(result);
        }
Example #2
0
        public Izdavac GetIzdavacByID(int IdIzdavac)
        {
            var             result = new Izdavac();
            MySqlConnection conn   = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "SELECT * FROM `Izdavac` WHERE IdIzdavac=@IdIzdavac";
                cmd.Parameters.AddWithValue("@IdAutor", IdIzdavac);
                reader = cmd.ExecuteReader();
                reader.Read();
                result = new Izdavac()
                {
                    IdIzdavac = reader.GetInt32(0),
                    IdMjesto  = reader.GetInt32(1),
                    Naziv     = reader.GetString(2),
                    Adresa    = reader.GetString(3)
                };
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlIzdavac", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(result);
        }
Example #3
0
        public int GetUkupanBrojPozajmicaByKnjigaId(int IdKnjiga)
        {
            MySqlConnection conn = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;
            int             count  = 0;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "SELECT COUNT(*) FROM `Pozajmica` WHERE IdKnjiga=@IdKnjiga AND JeRazduzena=0;";
                cmd.Parameters.AddWithValue("@IdKnjiga", IdKnjiga);
                reader = cmd.ExecuteReader();
                reader.Read();
                count = reader.GetInt32(0);
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlPozajmica", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(count);
        }
Example #4
0
        public Tema GetTemaByOsobaId(int id)
        {
            var             tema = new Tema();
            MySqlConnection conn = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = SELECT;
                cmd.Parameters.AddWithValue("@IdOsoba", id);
                reader = cmd.ExecuteReader();
                reader.Read();
                tema.IdTema  = reader.GetInt32(0);
                tema.IdOsoba = reader.GetInt32(1);
                tema.Stil    = reader.GetInt32(2);
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlTema", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(tema);
        }
Example #5
0
        public int GetBrojAutora()
        {
            var             count = 0;
            MySqlConnection conn  = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "SELECT COUNT(*) FROM `Autor`";
                reader          = cmd.ExecuteReader();
                reader.Read();
                count = reader.GetInt32(0);
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlAutor", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(count);
        }
Example #6
0
        public void PozajmicaRazduzi(int id)
        {
            MySqlConnection conn = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;
            int             count  = 0;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "UPDATE Pozajmica SET JeRazduzena=1 WHERE IdPozajmica=@IdPozajmica";
                cmd.Parameters.AddWithValue("@IdPozajmica", id);
                reader = cmd.ExecuteReader();
                reader.Read();
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlPozajmica", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
        }
Example #7
0
        public Pozajmica GetPozajmicaByClanID(int IdClan)
        {
            var             result = new Pozajmica();
            MySqlConnection conn   = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "SELECT * FROM `Pozajmica` WHERE IdClan=@IdClan";
                cmd.Parameters.AddWithValue("@IdClan", IdClan);
                reader = cmd.ExecuteReader();
                reader.Read();
                result = new Pozajmica()
                {
                    IdPozajmica         = reader.GetInt32(0),
                    IdClan              = reader.GetInt32(1),
                    IdBibliotekar       = reader.GetInt32(2),
                    DatumPozajmljivanja = reader.GetDateTime(3),
                    JeRazduzena         = reader.GetBoolean(4),
                    Opis = reader.GetString(5)
                };
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlPozajmica", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(result);
        }
Example #8
0
        public int GetUkupanBrojKasnihPozajmica()
        {
            MySqlConnection conn = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;
            int             count  = 0;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "SELECT COUNT(*) FROM `Pozajmica` WHERE DATE_ADD(DatumPozajmljivanja, INTERVAL @NumberOfDays DAY) < CURDATE() AND JeRazduzena=false;";
                cmd.Parameters.AddWithValue("@NumberOfDays", DUZINA_POZAJMICE);
                reader = cmd.ExecuteReader();
                reader.Read();
                count = reader.GetInt32(0);
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlPozajmica", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(count);
        }
Example #9
0
        public void PozajmicaProduzi(int id)
        {
            MySqlConnection conn = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;
            int             count  = 0;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "UPDATE Pozajmica SET DatumPozajmljivanja=DATE_ADD(DatumPozajmljivanja, INTERVAL @NumberOfDays DAY) WHERE IdPozajmica=@IdPozajmica";
                cmd.Parameters.AddWithValue("@NumberOfDays", PRODUZAVANJE);
                cmd.Parameters.AddWithValue("@IdPozajmica", id);
                reader = cmd.ExecuteReader();
                reader.Read();
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlPozajmica", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
        }
        public Bibliotekar GetBibliotekarById(int id)
        {
            var             result = new Bibliotekar();
            MySqlConnection conn   = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "SELECT * FROM `Bibliotekar` WHERE IdBibliotekar=@IdBibliotekar";
                cmd.Parameters.AddWithValue("@IdBibliotekar", id);
                reader = cmd.ExecuteReader();
                reader.Read();
                result = new Bibliotekar()
                {
                    IdBibliotekar = reader.GetInt32(0),
                    KorisnickoIme = reader.GetString(1),
                    Lozinka       = reader.GetString(2)
                };
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlBibliotekar", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(result);
        }
        public List <Bibliotekar> GetAllBibliotekar()
        {
            var             result = new List <Bibliotekar>();
            MySqlConnection conn   = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = SELECT;
                reader          = cmd.ExecuteReader();
                while (reader.Read())
                {
                    result.Add(new Bibliotekar()
                    {
                        IdBibliotekar = reader.GetInt32(0),
                        KorisnickoIme = reader.GetString(1),
                        Lozinka       = reader.GetString(2)
                    });
                }
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlBibliotekar", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(result);
        }
Example #12
0
        public int GetBrojKopijaById(int id)
        {
            var             count = 0;
            MySqlConnection conn  = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "SELECT SUM(UkupanBrojKopija) FROM `Knjiga` WHERE IdKnjiga=@IdKnjiga";
                cmd.Parameters.AddWithValue("@IdKnjiga", id);
                reader = cmd.ExecuteReader();
                reader.Read();
                count = reader.GetInt32(0);
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlKnjiga", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(count);
        }
Example #13
0
        public int GetUkupanBrojPozajmica()
        {
            MySqlConnection conn = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;
            int             count  = 0;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "SELECT COUNT(*) FROM `Pozajmica` WHERE JeRazduzena=false;";
                reader          = cmd.ExecuteReader();
                reader.Read();
                count = reader.GetInt32(0);
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlPozajmica", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(count);
        }
Example #14
0
        public float GetPozajmicaCijena(int id)
        {
            MySqlConnection conn = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;
            float           sum    = 0;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "SELECT SUM(DATEDIFF(CURDATE(),DATE_ADD(DatumPozajmljivanja, INTERVAL 30 DAY)))*@CijenaPoDanu AS Iznos FROM `Pozajmica` WHERE (DATE_ADD(DatumPozajmljivanja, INTERVAL 30 DAY) < CURDATE()) AND JeRazduzena=false;";
                cmd.Parameters.AddWithValue("@NumberOfDays", DUZINA_POZAJMICE);
                cmd.Parameters.AddWithValue("@CijenaPoDanu", CIJENA_PO_DANU);
                reader = cmd.ExecuteReader();
                reader.Read();
                try
                {
                    sum = reader.GetFloat(0);
                }
                catch (Exception exc)
                {
                    sum = 0;
                }
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlPozajmica", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(sum);
        }
Example #15
0
        public Autor GetAutorByID(int IdAutor)
        {
            var             result = new Autor();
            MySqlConnection conn   = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "SELECT * FROM `Autor` WHERE IdAutor=@IdAutor";
                cmd.Parameters.AddWithValue("@IdAutor", IdAutor);
                reader = cmd.ExecuteReader();
                reader.Read();
                result = new Autor()
                {
                    IdAutor       = reader.GetInt32(0),
                    IdMjesto      = reader.GetInt32(1),
                    Ime           = reader.GetString(2),
                    Prezime       = reader.GetString(3),
                    DatumRodjenja = reader.GetDateTime(4)
                };
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlAutor", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(result);
        }
Example #16
0
        public Mjesto GetMjestoByNaziv(string naziv)
        {
            var             result = new Mjesto();
            MySqlConnection conn   = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "SELECT * FROM `Mjesto` WHERE Naziv=@Naziv";
                cmd.Parameters.AddWithValue("@Naziv", naziv);
                reader = cmd.ExecuteReader();
                reader.Read();
                result = new Mjesto()
                {
                    IdMjesto      = reader.GetInt32(0),
                    Naziv         = reader.GetString(1),
                    PostanskiBroj = reader.GetString(2)
                };
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlMjesto", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(result);
        }
Example #17
0
        public List <Zanr> GetAllZanr()
        {
            List <Zanr>     result = new List <Zanr>();
            MySqlConnection conn   = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = SELECT;
                reader          = cmd.ExecuteReader();
                while (reader.Read())
                {
                    result.Add(new Zanr()
                    {
                        Naziv = reader.GetString(0),
                        Opis  = reader.GetString(1)
                    });
                }
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlZanr", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(result);
        }
Example #18
0
        public Administrator GetAdminrByUsername(string korisnickoIme)
        {
            var             result = new Administrator();
            MySqlConnection conn   = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "SELECT * FROM `Administrator` WHERE KorisnickoIme=@KorisnickoIme";
                cmd.Parameters.AddWithValue("@KorisnickoIme", korisnickoIme);
                reader = cmd.ExecuteReader();
                reader.Read();
                result = new Administrator()
                {
                    IdAdministrator = reader.GetInt32(0),
                    KorisnickoIme   = reader.GetString(1),
                    Lozinka         = reader.GetString(2)
                };
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlBibliotekar", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(result);
        }
Example #19
0
        public List <Autor> GetAllAutor()
        {
            var             result = new List <Autor>();
            MySqlConnection conn   = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = SELECT;
                reader          = cmd.ExecuteReader();
                while (reader.Read())
                {
                    result.Add(new Autor()
                    {
                        IdAutor       = reader.GetInt32(0),
                        IdMjesto      = reader.GetInt32(1),
                        Ime           = reader.GetString(2),
                        Prezime       = reader.GetString(3),
                        DatumRodjenja = reader.GetDateTime(4)
                    });
                }
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlAutor", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(result);
        }
Example #20
0
        public List <Clan> GetAllClan()
        {
            var             result = new List <Clan>();
            MySqlConnection conn   = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = SELECT;
                reader          = cmd.ExecuteReader();
                while (reader.Read())
                {
                    result.Add(new Clan()
                    {
                        IdClan                   = reader.GetInt32(0),
                        DatumUclanjivanja        = reader.GetDateTime(1),
                        DatumObnavljanjaClanstva = reader.GetDateTime(2)
                    });
                }
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlClan", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(result);
        }
Example #21
0
        public Clan GetClanByID(int IdClan)
        {
            var             result = new Clan();
            MySqlConnection conn   = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "SELECT * FROM `Clan` WHERE IdClan=@IdClan";
                cmd.Parameters.AddWithValue("@IdClan", IdClan);
                reader = cmd.ExecuteReader();
                reader.Read();
                result = new Clan()
                {
                    IdClan                   = reader.GetInt32(0),
                    DatumUclanjivanja        = reader.GetDateTime(1),
                    DatumObnavljanjaClanstva = reader.GetDateTime(2)
                };
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlClan", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(result);
        }
        public DataTable GetObavjestenjeJoin(int idBibliotekar)
        {
            var table = new DataTable();
            //Define columns
            var Ime           = new DataColumn("Ime", typeof(string));
            var Prezime       = new DataColumn("Prezime", typeof(string));
            var IdBibliotekar = new DataColumn("IdBibliotekar", typeof(int));
            var Naslov        = new DataColumn("Naslov", typeof(string));
            var Datum         = new DataColumn("Datum", typeof(string));
            var Tekst         = new DataColumn("Tekst", typeof(string));
            var ZaSve         = new DataColumn("ZaSve", typeof(int));

            //Add columns to a table
            table.Columns.Add(Ime);
            table.Columns.Add(Prezime);
            table.Columns.Add(IdBibliotekar);
            table.Columns.Add(Naslov);
            table.Columns.Add(Datum);
            table.Columns.Add(Tekst);
            table.Columns.Add(ZaSve);


            MySqlConnection conn = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = JOIN;
                cmd.Parameters.AddWithValue("@IdBibliotekar", idBibliotekar);
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    var row = table.NewRow();
                    row[0] = reader.GetString(0);
                    row[1] = reader.GetString(1);
                    row[2] = reader.GetInt32(2);
                    row[3] = reader.GetString(3);
                    row[4] = reader.GetDateTime(4).ToShortDateString();
                    row[5] = reader.GetString(5);
                    row[6] = reader.GetInt32(6);
                    table.Rows.Add(row);
                }
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlKnjiga", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(table);
        }
Example #23
0
        public List <Knjiga> GetAllKnjigaByNaslov(string naslov)
        {
            var             result = new List <Knjiga>();
            MySqlConnection conn   = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "SELECT * FROM `Knjiga` WHERE Naslov LIKE @Naslov ";
                cmd.Parameters.AddWithValue("@Naslov", naslov + "%");
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    result.Add(new Knjiga()
                    {
                        IdKnjiga           = reader.GetInt32(0),
                        NazivZanra         = reader.GetString(1),
                        IdIzdavac          = reader.GetInt32(2),
                        Naslov             = reader.GetString(3),
                        DatumObjavljivanja = reader.GetDateTime(4),
                        ISBN             = reader.GetString(5),
                        UkupanBrojKopija = reader.GetInt32(6),
                        BrojStranica     = reader.GetInt32(7),
                        Jezik            = reader.GetString(8),
                        Opis             = reader.GetString(9)
                    });
                }
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlKnjiga", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(result);
        }
Example #24
0
        public List <Knjiga> GetAllKnjiga()
        {
            var             result = new List <Knjiga>();
            MySqlConnection conn   = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = SELECT;
                reader          = cmd.ExecuteReader();
                while (reader.Read())
                {
                    result.Add(new Knjiga()
                    {
                        IdKnjiga           = reader.GetInt32(0),
                        NazivZanra         = reader.GetString(1),
                        IdIzdavac          = reader.GetInt32(2),
                        IdAutor            = reader.GetInt32(3),
                        Naslov             = reader.GetString(4),
                        DatumObjavljivanja = reader.GetDateTime(5),
                        ISBN             = reader.GetString(6),
                        UkupanBrojKopija = reader.GetInt32(7),
                        BrojStranica     = reader.GetInt32(8),
                        Jezik            = reader.GetString(9),
                        Opis             = reader.GetString(10)
                    });
                }
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlKnjiga", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(result);
        }
Example #25
0
        public void DeleteOsobaById(int IdOsoba)
        {
            MySqlConnection conn = null;
            MySqlCommand    cmd;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = DELETE;
                cmd.Parameters.AddWithValue("@IdOsoba", IdOsoba);
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlOsoba", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(conn);
            }
        }
Example #26
0
        public List <Osoba> GetAllOsoba()
        {
            var             result = new List <Osoba>();
            MySqlConnection conn   = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = SELECT;
                reader          = cmd.ExecuteReader();
                while (reader.Read())
                {
                    result.Add(new Osoba()
                    {
                        IdOsoba       = reader.GetInt32(0),
                        NazivMjesta   = reader.GetString(1),
                        Ime           = reader.GetString(2),
                        Prezime       = reader.GetString(3),
                        Adresa        = reader.GetString(4),
                        BrojTelefona  = reader.GetString(5),
                        Email         = reader.GetString(6),
                        DatumRodjenja = reader.GetDateTime(7)
                    });
                }
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlOsoba", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(result);
        }
Example #27
0
        public void UpdateClanstvo(int id)
        {
            MySqlConnection conn = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "update Clan set DatumObnavljanjaClanstva=DATE_ADD(CURDATE(), INTERVAL 1 YEAR) where IdClan=@IdClan;";
                cmd.Parameters.AddWithValue("@IdClan", id);
                reader = cmd.ExecuteReader();
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlClan", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
        }
Example #28
0
        private void UpdateTema(Tema tema)
        {
            MySqlConnection connection = null;
            MySqlCommand    cmd;

            try
            {
                connection      = MySqlUtil.GetConnection();
                cmd             = connection.CreateCommand();
                cmd.CommandText = UPDATE;
                cmd.Parameters.AddWithValue("@IdOsoba", tema.IdOsoba);
                cmd.Parameters.AddWithValue("@Stil", tema.Stil);
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlTema", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(connection);
            }
        }
Example #29
0
        private void UpdateZanr(Zanr zanr)
        {
            MySqlConnection conn = null;
            MySqlCommand    cmd;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = UPDATE;
                cmd.Parameters.AddWithValue("@Naziv", zanr.Naziv);
                cmd.Parameters.AddWithValue("@Opis", zanr.Opis);
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlZanr", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(conn);
            }
        }
Example #30
0
        public Osoba GetOsobaByID(int IdOsoba)
        {
            var             result = new Osoba();
            MySqlConnection conn   = null;
            MySqlCommand    cmd;
            MySqlDataReader reader = null;

            try
            {
                conn            = MySqlUtil.GetConnection();
                cmd             = conn.CreateCommand();
                cmd.CommandText = "SELECT * FROM `Osoba` WHERE IdOsoba=@IdOsoba";
                cmd.Parameters.AddWithValue("@IdOsoba", IdOsoba);
                reader = cmd.ExecuteReader();
                reader.Read();
                result = new Osoba()
                {
                    IdOsoba       = reader.GetInt32(0),
                    NazivMjesta   = reader.GetString(1),
                    Ime           = reader.GetString(2),
                    Prezime       = reader.GetString(3),
                    Adresa        = reader.GetString(4),
                    BrojTelefona  = reader.GetString(5),
                    Email         = reader.GetString(6),
                    DatumRodjenja = reader.GetDateTime(7)
                };
            }
            catch (Exception ex)
            {
                throw new DataAccessException("Exception in MySqlOsoba", ex);
            }
            finally
            {
                MySqlUtil.CloseQuietly(reader, conn);
            }
            return(result);
        }