private void btnLogin_Click(object sender, EventArgs e)
        {
            var sInput = medUsername.Text;
            var sPassword = medPassword.Text;

            if (sPassword.Equals("HereBeDragons") && (sInput.Equals("Admin") || sInput.Equals("admin") || sInput.Equals("Administrator") || sInput.Equals("administrator")))
            {
                Form adminShow = new Administrator.Administrator();
                adminShow.Owner = this;
                adminShow.Show();
                this.Hide();
            }
            else if (!SSS_Library.DataServices.StringHandler.CheckIfStringANumber(sInput) || !sPassword.Equals("HereBeDragons") && (sInput.Equals("Admin") || sInput.Equals("admin") || sInput.Equals("Administrator") || sInput.Equals("administrator")))
            {
                MessageBox.Show(String.Format("{0}", Resources.IncorrectLoginDetailsMessage));
                medPassword.Clear();
                medUsername.Clear();
                medUsername.Focus();
            }
            else
            {
                _userId = Convert.ToInt32(sInput);

                IS2G10_DBSSSDataSet.USERPROFILERow userProfile = userprofileTableAdapter1.GetData().FindByuser_id(_userId);

                if (userProfile == null)
                {
                    MessageBox.Show(String.Format("{0}", Resources.IncorrectLoginDetailsMessage));
                    medPassword.Clear();
                    medUsername.Clear();
                    medUsername.Focus();
                }
                else
                {
                    if (userProfile.resetPassword)
                    {
                        CreatePassword(userProfile);
                    }
                    else
                    {
                        var doILogin = CheckPassword(userProfile, sPassword);

                        if (doILogin)
                        {
                            //coordinator role = 2
                            if (userProfile.user_roles_id == 2)
                            {
                                Form coordinatorShow = new Coordinator.Coordinator(_userId);
                                coordinatorShow.Owner = this;
                                coordinatorShow.Show();
                                this.Hide();

                            }
                            //student role = 4
                            else if (userProfile.user_roles_id == 4)
                            {
                                Form studentShow = new SSS_Windows_Forms.Student(_userId);
                                studentShow.Owner = this;
                                studentShow.Show();
                                this.Hide();
                            }
                            //tutor role = 3
                            else if (userProfile.user_roles_id == 3)
                            {
                                Form tutorShow = new Tutor.Tutor(_userId);
                                tutorShow.Owner = this;
                                tutorShow.Show();
                                this.Hide();
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            var sInput    = medUsername.Text;
            var sPassword = medPassword.Text;

            if (sPassword.Equals("HereBeDragons") && (sInput.Equals("Admin") || sInput.Equals("admin") || sInput.Equals("Administrator") || sInput.Equals("administrator")))
            {
                Form adminShow = new Administrator.Administrator();
                adminShow.Owner = this;
                adminShow.Show();
                this.Hide();
            }
            else if (!SSS_Library.DataServices.StringHandler.CheckIfStringANumber(sInput) || !sPassword.Equals("HereBeDragons") && (sInput.Equals("Admin") || sInput.Equals("admin") || sInput.Equals("Administrator") || sInput.Equals("administrator")))
            {
                MessageBox.Show(String.Format("{0}", Resources.IncorrectLoginDetailsMessage));
                medPassword.Clear();
                medUsername.Clear();
                medUsername.Focus();
            }
            else
            {
                _userId = Convert.ToInt32(sInput);

                IS2G10_DBSSSDataSet.USERPROFILERow userProfile = userprofileTableAdapter1.GetData().FindByuser_id(_userId);

                if (userProfile == null)
                {
                    MessageBox.Show(String.Format("{0}", Resources.IncorrectLoginDetailsMessage));
                    medPassword.Clear();
                    medUsername.Clear();
                    medUsername.Focus();
                }
                else
                {
                    if (userProfile.resetPassword)
                    {
                        CreatePassword(userProfile);
                    }
                    else
                    {
                        var doILogin = CheckPassword(userProfile, sPassword);

                        if (doILogin)
                        {
                            //coordinator role = 2
                            if (userProfile.user_roles_id == 2)
                            {
                                Form coordinatorShow = new Coordinator.Coordinator(_userId);
                                coordinatorShow.Owner = this;
                                coordinatorShow.Show();
                                this.Hide();
                            }
                            //student role = 4
                            else if (userProfile.user_roles_id == 4)
                            {
                                Form studentShow = new SSS_Windows_Forms.Student(_userId);
                                studentShow.Owner = this;
                                studentShow.Show();
                                this.Hide();
                            }
                            //tutor role = 3
                            else if (userProfile.user_roles_id == 3)
                            {
                                Form tutorShow = new Tutor.Tutor(_userId);
                                tutorShow.Owner = this;
                                tutorShow.Show();
                                this.Hide();
                            }
                        }
                    }
                }
            }
        }