Exemplo n.º 1
0
        private void btnNazad_Click(object sender, EventArgs e)
        {
            FrmAdministracija frmAdministracija = new FrmAdministracija();

            frmAdministracija.Show();
            this.Hide();
        }
Exemplo n.º 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (label1.Visible == true)
            {
                string adminUsername = "******";
                string adminPassword = "******";

                if (adminUsername.Equals(textBox1.Text) && adminPassword.Equals(textBox2.Text))
                {
                    adminBrojPokusaja = 3;
                    FrmAdministracija frmAdministracija = new FrmAdministracija();
                    frmAdministracija.Show();
                    this.Hide();
                }
                else
                {
                    adminBrojPokusaja--;
                    MessageBox.Show("Pogresno unete akreditacije, preostali broj pokusaja: " + adminBrojPokusaja);
                    textBox1.Clear();
                    textBox2.Clear();
                }
                if (adminBrojPokusaja == 0)
                {
                    MessageBox.Show("Pogresno unete akreditacije, izlazak iz programa!");
                    Application.Exit();
                }
            }
            // ======================================= STUDENT LOGIN ================================================
            else if (label4.Visible == true)
            {
                if (textBox1.Text.Equals("") || textBox2.Text.Equals(""))
                {
                    MessageBox.Show("Molimo vas da unesete vas indeks za username, i password!");
                    return;
                }

                if (File.Exists(putanjaStudent) && File.Exists(putanjaPredmet))
                {
                    List <Student> listaStudenata = new List <Student>();
                    Student        upisan         = new Student();
                    fsr            = File.OpenRead(putanjaStudent);
                    listaStudenata = bfr.Deserialize(fsr) as List <Student>;
                    fsr.Dispose();
                    fsr.Close();

                    string username        = textBox1.Text.ToUpper();
                    string studentPassword = "******";
                    bool   proso           = false;
                    foreach (Student item in listaStudenata)
                    {
                        if (item.Indeks.ToString().Replace("-", "").Replace("/", "").Equals(username.Replace("-", "").Replace("/", "")) && studentPassword.Equals(textBox2.Text))
                        {
                            upisan = item;
                            proso  = true;
                        }
                    }
                    if (proso)
                    {
                        indeksStudenta      = upisan.Indeks.ToString();
                        studentBrojPokusaja = 3;
                        FrmKorisnik frmKorisnik = new FrmKorisnik();
                        frmKorisnik.Show();
                        this.Hide();
                        return;
                    }
                    else
                    {
                        studentBrojPokusaja--;
                        MessageBox.Show("Pogresno unete akreditacije, preostali broj pokusaja: " + studentBrojPokusaja);
                        textBox1.Clear();
                        textBox2.Clear();
                        textBox1.Focus();
                    }
                    if (studentBrojPokusaja == 0)
                    {
                        MessageBox.Show("Pogresno unete akreditacije, izlazak iz programa!");
                        Application.Exit();
                    }
                }
                else
                {
                    MessageBox.Show("Ne postoji nijedan student ili predmet, molimo administratore da unesu studente / predmete!");
                    button1_Click(sender, e);
                }
            }
        }