Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="value"></param>
        /// <param name="column"></param>
        /// <param name="iduser"></param>
        /// <returns></returns>
        public int CheckValueExisted(string value, string column, string id_user)
        {
            int           result = -1;
            StringBuilder query  = new StringBuilder();

            query.Append("    SELECT * FROM TBL_UserInfo WHERE @column = '@value' AND _ID_User = '******';    ");
            query.Replace("@column", column);
            query.Replace("@value", value);
            query.Replace("@id_user", id_user);
            try
            {
                using (SqlServerMethod sql = new SqlServerMethod(ConnectionStringDB))
                {
                    DataTable data   = sql.GetDataSqlToTable(query.ToString());
                    int       icheck = data.Rows.Count;
                    if (icheck == 0)
                    {
                        result = 0; //giá trị không tồn tại
                    }
                    else if (icheck == 1)
                    {
                        result = icheck; //giá trị tồn tại
                    }
                }
            }
            catch (Exception)
            {
                result = -1;
            }
            return(result);
        }
Пример #2
0
        public bool CheckAccountExist(string user)
        {
            bool          result = false;
            StringBuilder sb     = new StringBuilder();

            sb.Append("SELECT COUNT(0) FROM TBL_UserInfo WHERE _AccountName = '@AccountName';");
            sb.Replace("@AccountName", user);
            try
            {
                using (SqlServerMethod sql = new SqlServerMethod(ConnectionStringDB))
                {
                    DataTable data  = sql.GetDataSqlToTable(sb.ToString());
                    int       count = data.Rows[0].Field <int>(0);
                    if (count >= 1)
                    {
                        result = true;
                    }
                    //_AccountName = user;
                }
            }
            catch (Exception ex)
            {
            }
            //GetStatusLogin = result;
            return(result);
        }
Пример #3
0
        public bool CheckAccountExist(string user, string pass)
        {
            bool          result = false;
            StringBuilder sb     = new StringBuilder();

            sb.Append("SELECT _HashPass FROM TBL_UserInfo WHERE _AccountName = '@AccountName';");
            sb.Replace("@AccountName", user);
            try
            {
                using (SqlServerMethod sql = new SqlServerMethod(ConnectionStringDB))
                {
                    DataTable data        = sql.GetDataSqlToTable(sb.ToString());
                    string    hashpass    = data.Rows[0].Field <string>(0);
                    string    EnCryptPass = CryptData.StringCipher.Decrypt(hashpass, user);
                    if (pass == EnCryptPass)
                    {
                        result = true;
                    }
                    //_AccountName = user;
                }
            }
            catch (Exception ex)
            {
            }
            //GetStatusLogin = result;
            return(result);
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public DataTable GetAllUserInfo()
        {
            if (GetStatusLogin)
            {
                string query = "SELECT * FROM TBL_UserInfo";

                using (SqlServerMethod sql = new SqlServerMethod(ConnectionStringDB))
                {
                    DataTable data = sql.GetDataSqlToTable(query);
                    return(data);
                }
            }
            return(null);
        }
Пример #5
0
 /// <summary>
 /// Get infomation of the user login
 /// </summary>
 /// <returns></returns>
 public DataTable GetUserInfoByLongin()
 {
     if (GetStatusLogin)
     {
         StringBuilder sb = new StringBuilder();
         sb.Append("SELECT * FROM TBL_UserInfo WHERE _AccountName = '@AccountName';");
         sb.Replace("@AccountName", _AccountName);
         using (SqlServerMethod sql = new SqlServerMethod(ConnectionStringDB))
         {
             DataTable data = sql.GetDataSqlToTable(sb.ToString());
             _Status        = "Login";
             GetStatusLogin = true;
             return(data);
         }
     }
     return(null);
 }
Пример #6
0
        public DataTable SearchUser(string infoSearch, string collum)
        {
            DataTable     result = null;
            StringBuilder query  = new StringBuilder();

            query.Append("     SELECT * FROM TBL_UserInfo WHERE @collum LIKE '%@infoSearch%';     ");
            query.Replace("@collum", collum);
            query.Replace("@infoSearch", infoSearch);
            try
            {
                using (SqlServerMethod sql = new SqlServerMethod(ConnectionStringDB))
                {
                    DataTable data = sql.GetDataSqlToTable(query.ToString());
                    result = data;
                }
            }
            catch { }
            return(result);
        }