Beispiel #1
0
        private bool IsValidData()
        {
            string        userName      = tbUserName.Text;
            string        password      = MD5EncryptionFunction.Encrypt(tbPassword.Text);
            string        selectSql     = @"SELECT * FROM `user` WHERE `status`=1 AND username = @username AND password = @password";
            SqlParameters sqlParameters = new SqlParameters();

            sqlParameters.Add(new SqlParameter("username", userName));
            sqlParameters.Add(new SqlParameter("password", password));
            DataTable resultDt = MySqlFunction.GetDataTable(new SqlDetail(selectSql, sqlParameters));

            if (resultDt.Rows.Count <= 0)
            {
                fncFilter.alert(MessagesVariable.InvalidUserNameOrPasswod);
                ClearData();
                tbUserName.Select();
                return(false);
            }

            string code     = resultDt.Rows[0]["usercode"].ToString();
            string fullName = resultDt.Rows[0]["fullname"].ToString();
            string syncId   = resultDt.Rows[0]["SyncId"].ToString();

            selectSql = @"SELECT * FROM `userauth` WHERE `userid` = @userwid";
            sqlParameters.Clear();
            sqlParameters.Add(new SqlParameter("userwid", syncId));
            resultDt = MySqlFunction.GetDataTable(new SqlDetail(selectSql, sqlParameters));
            List <string> Authorizations = new List <string>();

            foreach (DataRow dr in resultDt.Rows)
            {
                Authorizations.Add(dr["authorization"].ToString());
            }
            User = new cls_user();
            User.setcls_user(code, fullName, Authorizations, Convert.ToInt32(syncId));
            return(true);
        }