示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(textBox1.Text) ||
                String.IsNullOrEmpty(textBox2.Text))
            {
                MessageBox.Show("Sva polja su obavezna!", "Greska");
            }
            else
            {
                try
                {
                    var pass = textBox2.Text;
                    var md5  = new MD5CryptoServiceProvider();
                    var data = Encoding.ASCII.GetBytes(pass);

                    var hash_pass = md5.ComputeHash(data);

                    Korisnik korisnik = new Korisnik();

                    korisnik.lozinka        = Convert.ToBase64String(hash_pass);
                    korisnik.korisnicko_ime = textBox1.Text;

                    korisnik.proveri_korisnika();

                    if (korisnik.Uloga == "Korisnik")
                    {
                        KorisnikForma forma = new KorisnikForma();
                        forma.korisnik = korisnik;

                        forma.WindowState = FormWindowState.Maximized;
                        this.Hide();
                        forma.ShowDialog();
                        this.Show();
                    }
                    else if (korisnik.Uloga == "Admin")
                    {
                        AdminForma form = new AdminForma();
                        form.korisnik = korisnik;
                        this.Hide();
                        form.WindowState = FormWindowState.Maximized;

                        form.ShowDialog();
                        this.Show();
                    }
                    else
                    {
                        MessageBox.Show("Pogresno korisnicko ime ili lozinka", "Greska");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Greska");
                }
            }
        }
示例#2
0
        private void izmeniNalogToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AdminForma fo = new AdminForma();

            fo.Show();
        }