Пример #1
0
 public static AdminPg getInstance() {
     if (instance == null) {
         instance = new AdminPg();
         instance.InitializeComponent();
     }
     instance.Initialize();
     instance.Show();
     return instance;
 }
Пример #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtUsername.Text))
            {
                MessageBox.Show("Please Enter Username");
                return;
            }
            else if (String.IsNullOrEmpty(txtPassword.Text))
            {
                MessageBox.Show("Please Enter Password");
                return;
            }
            bool      notFound  = true;
            UserCTRL  userctrl  = new UserCTRL();
            LoginCTRL loginctrl = new LoginCTRL();

            foreach (Login l in loginctrl.getAllLogins())
            {
                if (l.UserName == txtUsername.Text)
                {
                    if (l.Password == txtPassword.Text)
                    {
                        User user = userctrl.getUserByID(l.ID);
                        UserSingleton.Instance(user);
                        if (user.IsAdmin && SignInAsAdminBox.Checked)
                        {
                            MessageBox.Show("Login Successful");
                            notFound = false;
                            this.Hide();

                            AdminPg.getInstance();
                        }
                        else if (!user.IsAdmin && SignInAsAdminBox.Checked)
                        {
                            MessageBox.Show("User is Not an Admin");
                            notFound = false;
                            this.Hide();

                            HomePage.getInstance();
                        }
                        else
                        {
                            //MessageBox.Show(UserSingleton.GetUser().ToString());
                            MessageBox.Show("Login Successful");
                            notFound = false;
                            this.Hide();

                            HomePage.getInstance();
                        }
                    }
                }
            }
            if (notFound)
            {
                MessageBox.Show("Invalid Username or Password.");
            }
        }
Пример #3
0
        private void btnBackToAdminPg_Click(object sender, EventArgs e)
        {
            this.Hide();

            AdminPg.getInstance();
        }