示例#1
0
        internal string CheckSession(User user)
        {
            string sql = string.Format("select * from user where id= '{0}'", user.Id);
            string error = null;
            MySqlConnection conn = null;
            try
            {
                conn = new MySqlConnection(connStr_local);
                conn.Open();
                MySqlDataAdapter adapter = new MySqlDataAdapter(sql, conn);
                // 创建DataSet,用于存储数据.
                DataSet testDataSet = new DataSet();
                // 执行查询,并将数据导入DataSet.
                adapter.Fill(testDataSet, "result_data");

                if (testDataSet != null && testDataSet.Tables["result_data"] != null && testDataSet.Tables["result_data"].Rows != null && testDataSet.Tables["result_data"].Rows.Count > 0)
                {
                    if (user.Session == testDataSet.Tables["result_data"].Rows[0]["session"].ToString())
                    {
                        return "OK";
                    }
                    else
                    {
                        return "Error";
                    }

                }
                else
                {
                    return "Error";
                }
            }
            catch (Exception t)
            {
                return "Error";
            }
            finally
            {
                conn.Close();
            }
        }
示例#2
0
        internal User SearchUser(User user)
        {
            string sql = string.Format("select * from user where name = '{0}'", user.Name);
            DataSet testDataSet = null;
            MySqlConnection conn = new MySqlConnection(connStr_local);
            try
            {
                conn.Open();
                // 创建一个适配器
                MySqlDataAdapter adapter = new MySqlDataAdapter(sql, conn);
                // 创建DataSet,用于存储数据.
                testDataSet = new DataSet();
                // 执行查询,并将数据导入DataSet.
                adapter.Fill(testDataSet, "result_data");
            }
            // 关闭数据库连接.
            catch (Exception e)
            {
                //log4net.ILog log = log4net.LogManager.GetLogger("MyLogger");
                //log.Debug(e.Message);
                Console.WriteLine(e.Message);
                //Console.ReadLine();

            }
            finally
            {
                conn.Close();
            }
            if (testDataSet != null && testDataSet.Tables["result_data"] != null && testDataSet.Tables["result_data"].Rows != null&& testDataSet.Tables["result_data"].Rows.Count>0)
            {
                user.Id = testDataSet.Tables["result_data"].Rows[0]["id"].ToString();
                if (testDataSet.Tables["result_data"].Rows[0]["password"].ToString() == user.Password)
                {
                    user.Status = "Success";
                    user.Id = testDataSet.Tables["result_data"].Rows[0]["id"].ToString();
                    return user;
                }
                else
                {

                    updateLoginTime(user);
                    user.Status = "Password Error";
                    return user;
                }
            }
            else
            {
                try
                {
                    user.Status = "No this User";
                    return user;
                }
                catch (Exception t)
                {
                   user.Status = "System Error";
                    return user;
                }
            }
        }
示例#3
0
 internal string CheckServoceCode(User users)
 {
     return "true";
 }
示例#4
0
        private void updateLoginTime(User user)
        {
            string sql = string.Format("update user set login_count = login_count+1 where user.id='{0}'", user.Id);
            string error = null;
            MySqlConnection conn = null;
            try
            {
                conn = new MySqlConnection(connStr_local);
                conn.Open();
                MySqlDataAdapter adapter = new MySqlDataAdapter(sql, conn);
                // 创建DataSet,用于存储数据.
                DataSet testDataSet = new DataSet();
                // 执行查询,并将数据导入DataSet.
                adapter.Fill(testDataSet, "result_data");
            }
            catch (Exception t)
            {

            }
            finally
            {
                conn.Close();
            }
        }
示例#5
0
        internal bool UpdateTheUser(User user)
        {
            string sql = string.Format("update user set name='{0}',password='******',sign_up_date='{2}',question_id='{3}',question_answer='{4}',status=1 and real_name='{6}' where hk_id='{5}'", user.Name,user.Password, DateTime.Now.ToString("yyyy-MM-dd"),user.Question_Id,user.Question_Answer,user.Hk_Id,user.RealName);
            string error = null;
            MySqlConnection conn = null;
            try
            {
                conn = new MySqlConnection(connStr_local);
                conn.Open();
                MySqlDataAdapter adapter = new MySqlDataAdapter(sql, conn);
                // 创建DataSet,用于存储数据.
                DataSet testDataSet = new DataSet();
                // 执行查询,并将数据导入DataSet.
                adapter.Fill(testDataSet, "result_data");
                string sql_two = string.Format("select * from user where hk_id='{0}'", user.Hk_Id);

                DataSet testDataSet_2 = new DataSet();
                try
                {

                    adapter = new MySqlDataAdapter(sql_two, conn);
                    adapter.Fill(testDataSet_2, "result_data");

                }
                catch (Exception e)
                {
                    //return F
                    return false;
                }
                if (testDataSet_2 != null && testDataSet_2.Tables["result_data"] != null && testDataSet_2.Tables["result_data"].Rows != null && testDataSet_2.Tables["result_data"].Rows.Count > 0)
                {
                    if (testDataSet_2.Tables["result_data"].Rows[0]["status"].ToString() == "1")
                        //return "true";
                        return true;
                    else
                        return false;
                    //return false;

                }
                else
                //{
                //    return "dataset_2_0";
                //}
                    return false;
            }
            catch (Exception e)
            {
                error = e.Message;

                return false;
            }
            finally
            {
                conn.Close();
            }
            return false;
        }
示例#6
0
 internal string UpdatePassword(User user)
 {
     string sql = string.Format("update user set password='******' where id ='{0}'", user.New_Password);
     string error = null;
     MySqlConnection conn = null;
     try
     {
         conn = new MySqlConnection(connStr_local);
         conn.Open();
         MySqlDataAdapter adapter = new MySqlDataAdapter(sql, conn);
         // 创建DataSet,用于存储数据.
         DataSet testDataSet = new DataSet();
         // 执行查询,并将数据导入DataSet.
         adapter.Fill(testDataSet, "result_data");
         return "Success";
     }
     catch (Exception t)
     {
         return "error";
     }
     finally
     {
         conn.Close();
     }
 }
示例#7
0
        internal void UpdateLoginStatus(User user,string ip)
        {
            string sql = string.Format("update user set login_ip ='{1}' where user.id='{0}'", user.Id,ip);
            string error = null;
            MySqlConnection conn = null;
            try
            {
                conn = new MySqlConnection(connStr_local);
                conn.Open();
                MySqlDataAdapter adapter = new MySqlDataAdapter(sql, conn);
                // 创建DataSet,用于存储数据.
                DataSet testDataSet = new DataSet();
                // 执行查询,并将数据导入DataSet.
                adapter.Fill(testDataSet, "result_data");
            }
            catch (Exception t)
            {

            }
            finally
            {
                conn.Close();
            }
        }