private void button2_Click(object sender, EventArgs e)
        {
            Admin1stpage al = new Admin1stpage();

            this.Hide();
            al.Show();
        }
示例#2
0
        private void button3_Click(object sender, EventArgs e)
        {
            LoginService loginService = new LoginService();

            try
            {
                if (textBox1.Text == string.Empty || textBox2.Text == string.Empty)
                {
                    MessageBox.Show("Username or Password can not be empty.");
                }

                else
                {
                    Login ln = new Login();
                    ln.Username = textBox1.Text;
                    ln.Password = textBox2.Text;
                    Login result = loginService.LoginValidation(ln);
                    if (result.UserType > 0)
                    {
                        if (result.UserType == 1)
                        {
                            Admin1stpage ap = new Admin1stpage(result);
                            this.Hide();
                            ap.Show();
                        }
                        else if (result.UserType == 2)
                        {
                            Customer_Home ch = new Customer_Home(result);
                            this.Hide();
                            ch.Show();
                        }
                        else
                        {
                            MessageBox.Show("User does not exist.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Invalid Username or Password");
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Invalid Username or Password");
            }
        }