Ejemplo n.º 1
0
        private void Bibliotekar()
        {
            SqlConnection SqlConn = Konekcija.KreirajKonekciju();

            try
            {
                SqlConn.Open();
                SqlCommand    cmd  = new SqlCommand("SELECT BibliotekarId, Ime,Prezime FROM Bibliotekar", SqlConn);
                SqlDataReader read = cmd.ExecuteReader();
                while (read.Read())
                {
                    Bibliotekar b             = new Bibliotekar();
                    int         BibliotekarId = read.GetInt32(0);
                    string      Ime           = read.GetString(1);
                    string      Prezime       = read.GetString(2);

                    b.BibliotekarId = BibliotekarId;
                    b.Ime           = Ime;
                    b.Prezime       = Prezime;

                    bibliotekar.Add(b);
                }
                listBoxListaBibliotekara.ItemsSource = null;
                listBoxListaBibliotekara.ItemsSource = bibliotekar;
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        private void buttonLogin_Click(object sender, RoutedEventArgs e)
        {
            SqlConnection SqlConn = Konekcija.KreirajKonekciju();

            try
            {
                SqlConn.Open();
                SqlCommand    cmd  = new SqlCommand("SELECT Ime, Sifra FROM Admin", SqlConn);
                SqlDataReader read = cmd.ExecuteReader();
                while (read.Read())
                {
                    Bibliotekar p       = new Bibliotekar();
                    string      Ime     = read.GetString(0);
                    string      Prezime = read.GetString(1);

                    p.Ime     = Ime;
                    p.Prezime = Prezime;
                    bibliotekar.Add(p);

                    if (textBox.Text.Trim().Contains(p.Ime) && passwordBox.Password.Contains(p.Prezime))
                    {
                        Window1 w1 = new Window1();
                        Close();
                        w1.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Pogresni podaci!");
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                SqlConn.Close();
            }
        }