internal string SetCommon(Saving saving) { string sql = string.Format("update saving_account set common_use=1 where id ='{0}'",saving.Account_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"); return "Success"; } catch (Exception t) { return "error"; } finally { conn.Close(); } }
internal List<Saving> GetAllSavingAccount(string user_id) { List<Saving> saving_list = new List<Saving>(); string sql = string.Format("select * from saving_account as s,currency as c,account_status as ast,branch as b where s.user_id ='{0}' and s.currency_id = c.id and s.branch_id=b.id and s.status= ast.id", user_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) { foreach (DataRow testRow in testDataSet.Tables["result_data"].Rows) { Saving saving = new Saving(); string Account_Id = testRow["id"].ToString(); string card_num = testRow["card_num"].ToString(); string balance = testRow["balance"].ToString(); string branch_id = testRow["branch_name"].ToString(); string expired_date = testRow["expired_date"].ToString(); string open_date = testRow["open_date"].ToString(); string currency_id = testRow["currency_name"].ToString(); string status = testRow["status_name"].ToString(); string common_use = testRow["common_use"].ToString(); saving.Account_Id = Account_Id; saving.No = card_num; saving.Balance = balance; saving.Branch = branch_id; saving.Open_Date = open_date; saving.Exp_Date = expired_date; saving.Currency_Id = currency_id; saving.Status = status; saving.Common_use = common_use; saving_list.Add(saving); } } else { return null; } return saving_list; }
public string SetCommon(Saving saving) { MysqlHelper mysqlhelper = new MysqlHelper(); var status = mysqlhelper.SetCommon(saving); return status; }