Exemple #1
0
        private void metroButton1_Click(object sender, EventArgs e)
        {
            korisnici x = null;

            try { x = ctx.korisnici.First(v => v.username == usernameInput.Text); }
            catch { MessageBox.Show("Ne postoji korisnik sa tim username."); return; }

            if (passInput.Text.Length < 8)
            {
                MessageBox.Show("Polje za šifru ne sme biti prazno i mora imati makar 8 karaktera..");
                return;
            }

            if (x != null && x.password1 == passInput.Text)
            {
                username = usernameInput.Text;
                graf     = new Grafovi(this);
                graf.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Pogresna sifra!");
                passInput.Clear();
            }
        }
Exemple #2
0
        private void RegisterBtn_Click(object sender, EventArgs e)
        {
            var x = new korisnici();

            x.username  = usernameTb.Text;
            x.name      = nameTb.Text;
            x.surname   = surnameTb.Text;
            x.email     = emailTb.Text;
            x.password1 = passwordTb.Text;

            if (!ctx.korisnici.Any(y => y.username == usernameTb.Text))
            {
                if (x.username.Length == 0 || x.name.Length == 0 || x.surname.Length == 0 || x.email.Length == 0 || x.password1.Length == 0)
                {
                    MessageBox.Show("Sva polja moraju biti popunjena!");
                    return;
                }

                if (x.password1.Length < 8)
                {
                    MessageBox.Show("Šifra mora imati makar 8 karaktera..");
                    return;
                }

                ctx.korisnici.Add(x);
                ctx.SaveChanges();
                MessageBox.Show("Uspešno registrovan korisnik!");
                this.Close();
            }
            else
            {
                MessageBox.Show("Već postoji korisnik sa datim imenom!");
                passwordTb.Clear();
                usernameTb.Clear();
                return;
            }
        }