public User selectByName(String uName) { DataBaseDao.getConnect(); User user = null; String sqlQuare = "select * from tb_user where userName=@para1"; MySqlCommand sqlCommand = new MySqlCommand(sqlQuare, DataBaseDao.conn); MySqlDataReader reader = null; try { sqlCommand.Parameters.AddWithValue("para1", "lisi"); reader = sqlCommand.ExecuteReader(); if (reader.Read()) { user = new User(reader.GetString("userName"), reader.GetString("userPWD"), reader.GetInt32("age"), reader.GetString("phone"), reader.GetInt32("value")); } } catch (MySqlException ex) { if (reader != null) { reader.Close(); } //记录日志 } finally { if (reader != null) { reader.Close(); } DataBaseDao.closeCon(); } return(user); }
public ActionResult AdminPage() { var data = DataBaseDao.unapproved(); if (data != null) { return(View(data)); } else { return(View("NoData")); } }
public ActionResult Approve(DataBase data) { DataBaseDao.ApproveLink(data); return(View("Success")); }
public ActionResult Save(DataBase data) { DataBaseDao.NewLink(data); return(View("Success")); }
// GET: DataBase public ActionResult Index() { var data = DataBaseDao.getAll(); return(View(data)); }