Esempio n. 1
0
        internal Card CheckSavingAccount(ref Card card)
        {
            string sql = string.Format("select * from saving_account where card_num='{0}'",card.Id);
            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)
            {
                if (testDataSet.Tables["result_data"].Rows[0]["password"].ToString() ==card.Password)
                {
                    card.Status = "Success";
                    return card;
                }
                else
                {

                    updateErrorPassword(card);
                    card.Status = "Password Error";
                    return card;
                }
            }
            else
            {
                try
                {
                    card.Status = "No this user";
                    return card;
                }
                catch (Exception t)
                {
                    card.Status = "System Error";
                    return card;
                }
            }
        }
Esempio n. 2
0
        private void updateErrorPassword(Card card)
        {
            string sql = string.Format("update saving_account set error_count = error_count+1 where id='{0}'", card.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();
            }
        }