Esempio n. 1
0
        private void btnSignIn_Click(object sender, EventArgs e)
        {
            btnSignIn.Enabled = false;
            if (LiveRadio.Checked == false && SandboxRadio.Checked == false)
            {
                MessageBox.Show("Please select the server to use");
                btnSignIn.Enabled = true;
                return;
            }

            if (txtUserName.Text == "" || txtPassword.Text == "")
            {
                MessageBox.Show("Please enter Phone Number and password.");
                btnSignIn.Enabled = true;
                return;
            }

            tblUsers l = new tblUsers();

            foreach (var p in dbe.tblUsers)
            {
                if (p.userName == txtUserName.Text && p.password == txtPassword.Text)
                {
                    MessageBox.Show("Successfully Logged In");

                    Form1 f1 = new Form1();

                    f1.lblHello.Text = "Logged In: " + p.userName;

                    f1.Show();
                    this.Hide();

                    return;
                }
            }
            foreach (var p in dbe.tblUsers)
            {
                if (p.userName != txtUserName.Text || p.password != txtPassword.Text)
                {
                    MessageBox.Show("Wrong Username and/or Password.");
                    btnSignIn.Enabled = true;
                    return;
                }
            }
        }
Esempio n. 2
0
        private void btnSubmitReg_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtUserNameReg.Text == "" || txtPasswordReg.Text == "")
                {
                    MessageBox.Show("Username and password must be filled out.");
                    return;
                }

                tblUsers l = new tblUsers();
                foreach (var p in dbe.tblUsers)
                {
                    if (p.userName == txtUserNameReg.Text)
                    {
                        MessageBox.Show("Username already exists, please pick another one.");
                        return;
                    }
                }
                l.userName = txtUserNameReg.Text;
                l.password = txtPasswordReg.Text;
                l.name     = txtNameReg.Text;
                l.surname  = txtSurnameReg.Text;
                l.email    = txtEmailReg.Text;

                dbe.tblUsers.Add(l);

                dbe.SaveChanges();

                MessageBox.Show("Successfully registered");

                /*
                 * Form1 f1 = new Form1();
                 *
                 * f1.lblHello.Text = "User: " + l.userName;
                 *
                 * f1.Show();
                 *
                 * this.Close();*/
            }
            catch { }
        }