Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            baza mongo = new baza();

            if (textBox1.Text == "")
            {
                MessageBox.Show("Unesite podatke", "Error");
                goto con;
            }
            if (textBox2.Text == "")
            {
                MessageBox.Show("Unesite podatke", "Error");
                goto con;
            }
            if (textBox3.Text == "")
            {
                MessageBox.Show("Unesite podatke", "Error");
                goto con;
            }
            if (textBox4.Text == "")
            {
                MessageBox.Show("Unesite podatke", "Error");
                goto con;
            }
            if (textBox5.Text == "")
            {
                MessageBox.Show("Unesite podatke", "Error");
                goto con;
            }
con:
            if (textBox4.Text != textBox5.Text)
            {
                MessageBox.Show("Lozinke nisu iste", "Error");
                this.Close();
            }

            user test = mongo.findOne <user>("users", textBox3.Text);

            user korisnik = new user {
                ime      = textBox1.Text,
                prezime  = textBox2.Text,
                username = textBox3.Text,
                password = textBox4.Text
            };


            if (test.username == "a")
            {
                mongo.insertRecord("users", korisnik);
                MessageBox.Show("Uspjesno ste sacuvali gosta");
                this.Close();
            }
            else
            {
                MessageBox.Show("Korisnik vec postoji");
            }
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            username = textBox1.Text;

            string pwd = textBox2.Text;

            var korisnik = mongo.findOne <user>("users", username);

            if (korisnik.password == pwd && korisnik.username == username)
            {
                Form home = new Form1();
                MessageBox.Show("Dobro dosli:" + korisnik.ime + " " + korisnik.prezime, "Uspjesan login!");
                home.Show();

                this.Hide();
            }
            else
            {
                MessageBox.Show("Neuspjesan login pokusajte ponovo!", "Login error");
            }
        }