Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            korisnik k = new korisnik();

            k.korisnickoIme = textBox5.Text;
            string allowedchar = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

            k.sifra = textBox4.Text;

            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "")
            {
                MessageBox.Show("You must fill in all the fields!");
            }
            else if (k.proveraKorisnika())
            {
                MessageBox.Show("Username already exists.");
            }
            else if (!textBox5.Text.All(allowedchar.Contains))
            {
                MessageBox.Show("Check the password.You have entered forbidden characters");
            }
            else if (!textBox4.Text.All(allowedchar.Contains))
            {
                MessageBox.Show("Check the username.You have entered forbidden characters!");
            }
            else
            {
                try
                {
                    Base.dodavanjeRadnika(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text);
                    MessageBox.Show("Successful");
                }
                catch
                {
                    MessageBox.Show("Employee already exists!");
                }
            }
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            korisnik k = new korisnik();

            k.korisnickoIme = textBox1.Text;
            k.sifra         = textBox2.Text;
            DataTable dt1         = Base.UlogujAdmina(k);
            DataTable dt          = Base.UlogujRadnika(k);
            string    allowedchar = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

            try
            {
                if (textBox1.Text == "" || textBox2.Text == "")
                {
                    MessageBox.Show("Morate popuniti sva polja");
                }
                else if (!textBox2.Text.All(allowedchar.Contains))
                {
                    MessageBox.Show("Proverite lozinku");
                }
                else
                {
                    if (k.proveraKorisnika())
                    {
                        if (k.tip == "A")
                        {
                            if (dt1.Rows.Count == 1)

                            {
                                this.Hide();
                                Admin a = new Admin();
                                a.Show();
                            }
                            else
                            {
                                MessageBox.Show("Neispravno ste uneli lozinku.");
                            }
                        }
                        else
                        {
                            if (dt.Rows.Count == 1)
                            {
                                this.Hide();
                                User f = new User();
                                f.Show();
                            }
                            else
                            {
                                MessageBox.Show("Neispravno ste uneli lozinku.");
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Ne postoji korisnik sa unesenim korisničkim imenom");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string allowedchar = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

            if (textBox1.Text == "" || textBox2.Text == "")
            {
                MessageBox.Show("You must fill in all fields");
            }
            else if (!textBox2.Text.All(allowedchar.Contains))
            {
                MessageBox.Show("Check the password");
            }
            else
            {
                korisnik k = new korisnik();
                k.korisnickoIme = textBox1.Text;
                k.sifra         = textBox2.Text;
                DataTable dt = Base.Login(k);

                try
                {
                    if (k.proveraKorisnika())
                    {
                        if (dt.Rows.Count == 1)
                        {
                            switch (dt.Rows[0][5] as string)
                            {
                            case "A":
                            {
                                k.korisnickoIme = dt.Rows[0][4].ToString();
                                this.Hide();
                                Admin a = new Admin();
                                a.Show();
                                break;
                            }

                            case "R":
                            {
                                k.korisnickoIme = dt.Rows[0][4].ToString();
                                User u = new User();
                                u.Show();
                                break;
                            }

                            default:
                            {
                                MessageBox.Show("You entered your username or password incorrectly.");
                                break;
                            }
                            }
                        }
                        else
                        {
                            MessageBox.Show("You entered your username or password incorrectly.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("There is no user with the username entered.");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }