public GZScenery queryAll(long gzSceneryID) { conn.Open(); GZScenery gzScenery = new GZScenery(); string sql = "select * from gzScenery where gzSceneryID = ?gzSceneryID"; MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlParameter[] parameters = new MySqlParameter[1]; parameters[0] = new MySqlParameter("?gzSceneryID", MySqlDbType.Int64); parameters[0].Value = gzSceneryID; cmd.Parameters.AddRange(parameters); MySqlDataReader reader = cmd.ExecuteReader(); reader.Read(); gzScenery.GZSceneryLinePlay = reader[1].ToString(); gzScenery.GZSceneryIntroduce = reader[2].ToString(); gzScenery.GZSceneryName = reader[3].ToString(); gzScenery.GZSceneryCity = reader[4].ToString(); gzScenery.GZSceneryDateTime = reader[5].ToString(); gzScenery.GZSceneryTripDay = reader[6].ToString(); gzScenery.GZSceneryAdultPrice = reader[7].ToString(); gzScenery.GZSceneryChildren = reader[8].ToString(); gzScenery.GZScenerySingleRoom = reader[9].ToString(); gzScenery.GZSceneryTravelDetails = reader[10].ToString(); gzScenery.GZSceneryGridInformation = reader[11].ToString(); gzScenery.GZSceneryCost = reader[12].ToString(); return gzScenery; }
public long gzSceneryID; //旅游ID #endregion Fields #region Methods /// <summary> /// 初始化页面 /// </summary> public void initPage() { //获取旅游线路ID gzSceneryID = Convert.ToInt64(Request.QueryString["gzSceneryID"]); //通过ID查询旅游线路的信息 GZSceneryDAO gzSceneryDAO = new GZSceneryDAO(); gzScenery = gzSceneryDAO.queryAll(gzSceneryID); }
/// <summary> /// 查询 /// </summary> /// <returns></returns> public List<GZScenery> Query(string gzSceneryName) { conn.Open(); List<GZScenery> GZSceneryList = new List<GZScenery>(); string sql = "select gzSceneryLinePlay from gzScenery where gzSceneryName = ?gzSceneryName"; MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlParameter[] parameters = new MySqlParameter[1]; parameters[0] = new MySqlParameter("?gzSceneryName", MySqlDbType.VarChar); parameters[0].Value = gzSceneryName; cmd.Parameters.AddRange(parameters); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { GZScenery gzScenery = new GZScenery(); gzScenery.GZSceneryLinePlay = reader[0].ToString(); GZSceneryList.Add(gzScenery); } reader.Close(); conn.Close(); return GZSceneryList; }
/// <summary> /// 查询当前页显示的内容 /// </summary> /// <param name="page"></param> /// <returns></returns> public List<GZScenery> queryShowPage(string gzSceneryName, int page) { conn.Open(); List<GZScenery> GZSceneryList = new List<GZScenery>(); int removeCount = (page - 1) * 5; string sql = "select * FROM gzscenery " + "where gzSceneryName=?gzSceneryName" + " limit " + removeCount + "," + 5; MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlParameter[] parameters = new MySqlParameter[1]; parameters[0] = new MySqlParameter("?gzSceneryName", MySqlDbType.VarChar); parameters[0].Value = gzSceneryName; cmd.Parameters.AddRange(parameters); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { GZScenery gzScenery = new GZScenery(); gzScenery.GZSceneryID = reader[0].ToString(); gzScenery.GZSceneryLinePlay = reader[1].ToString(); gzScenery.GZSceneryIntroduce = reader[2].ToString(); gzScenery.GZSceneryName = reader[3].ToString(); gzScenery.GZSceneryCity = reader[4].ToString(); gzScenery.GZSceneryDateTime = reader[5].ToString(); gzScenery.GZSceneryTripDay = reader[6].ToString(); gzScenery.GZSceneryAdultPrice = reader[7].ToString(); gzScenery.GZSceneryChildren = reader[8].ToString(); gzScenery.GZScenerySingleRoom = reader[9].ToString(); GZSceneryList.Add(gzScenery); } reader.Close(); conn.Close(); return GZSceneryList; }