示例#1
0
        private void Login_Click(object sender, EventArgs e)
        {
            GlobalClass.userTableMapper selectedUser = ((GlobalClass.userTableMapper)LoginSelector.SelectedItem);
            string userHash = selectedUser.MD5HashPass;
            string userPass = passwdInput.Text;

            if (GlobalClass.VerifyMd5Hash(userPass, userHash))
            {
                GlobalClass.userRoleMapper SelectedRole = elementBase.roleSelectedUser(selectedUser.ID);
                if (SelectedRole.Admin)
                {
                    Admin admin = new Admin();
                    admin.setUser(selectedUser);
                    admin.Show();
                    this.Close();
                }
                else if (SelectedRole.AllowWrite)
                {
                    Teacher teacher = new Teacher();
                    teacher.Show();
                    this.Close();
                }
                else if (SelectedRole.AllowRead)
                {
                    Student student = new Student();
                    student.Show();
                    this.Close();
                }
            }
            else
            {
                this.LoginError.Text      = "Неверный пароль. Попробуйте ввести пароль заново или выберите другого пользователя";
                this.LoginError.ForeColor = Color.Red;
            }
        }
示例#2
0
        //===================================================
        // запросы по таблице пользователей и окружающих их
        public BindingList <GlobalClass.userTableMapper> SelectUsers()
        {
            string query = "select * from loginusers";
            BindingList <GlobalClass.userTableMapper> tempUserList = new BindingList <GlobalClass.userTableMapper>();

            if (this.openConnection() == true)
            {
                MySqlCommand    cmd        = new MySqlCommand(query, dbConnect);
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    int    I  = (int)((long)dataReader["ID"]);
                    string N  = (string)dataReader["Name"];
                    string S  = (string)dataReader["Surname"];
                    string P  = (string)dataReader["Patronym"];
                    string Pw = (string)dataReader["passwd"];
                    GlobalClass.userTableMapper tempUser = new GlobalClass.userTableMapper(I, N, S, P, Pw);
                    tempUserList.Add(tempUser);
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                this.CloseConnection();

                //return list to be displayed
                return(tempUserList);
            }
            else
            {
                return(tempUserList);
            }
        }
示例#3
0
 public void setUser(GlobalClass.userTableMapper sU)
 {
     this.selectedUser = sU;
     this.Text         = this.selectedUser.reprUser;
 }