public long nsID; //旅游ID #endregion Fields #region Methods /// <summary> /// 初始化页面 /// </summary> public void initPage() { //获取旅游线路ID nsID = Convert.ToInt64(Request.QueryString["nsID"]); //通过ID查询旅游线路的信息 NativeSceneryDAO nsDAO = new NativeSceneryDAO(); ns = nsDAO.queryAll(nsID); }
/// <summary> /// 根据景点名查询线路玩法 /// </summary> /// <returns></returns> public List<NativeScenery> Query(string nsName) { conn.Open(); List<NativeScenery> nsList = new List<NativeScenery>(); string sql = "select nsLinePlay from nativeScenery where nsName = ?nsName"; MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlParameter[] parameters = new MySqlParameter[1]; parameters[0] = new MySqlParameter("?nsName", MySqlDbType.VarChar); parameters[0].Value = nsName; cmd.Parameters.AddRange(parameters); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { NativeScenery ns = new NativeScenery(); ns.NSLinePlay = reader[0].ToString(); nsList.Add(ns); } reader.Close(); conn.Close(); return nsList; }
public NativeScenery queryAll(long nsID) { conn.Open(); NativeScenery ns = new NativeScenery(); string sql = "select * from nativeScenery where nsID = ?nsID"; MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlParameter[] parameters = new MySqlParameter[1]; parameters[0] = new MySqlParameter("?nsID", MySqlDbType.Int64); parameters[0].Value = nsID; cmd.Parameters.AddRange(parameters); MySqlDataReader reader = cmd.ExecuteReader(); reader.Read(); ns.NSID = Convert.ToInt64(reader[0]); ns.NSLinePlay = reader[1].ToString(); ns.NSIntroduce = reader[2].ToString(); ns.NSName = reader[3].ToString(); ns.NSProvince = reader[4].ToString(); ns.NSDateTime = reader[5].ToString(); ns.NSTripDay = reader[6].ToString(); ns.NSAdultPrice = reader[7].ToString(); ns.NSChildrenPrice = reader[8].ToString(); ns.NSSingleRoom = reader[9].ToString(); return ns; }
/// <summary> /// 查询当前页显示的内容 /// </summary> /// <param name="page"></param> /// <returns></returns> public List<NativeScenery> queryShowPage(string nsName, int page) { conn.Open(); List<NativeScenery> nsList = new List<NativeScenery>(); int removeCount = (page - 1) * 5; string sql = "select * FROM nativeScenery " + "where nsName=?nsName" + " limit " + removeCount + "," + 5; MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlParameter[] parameters = new MySqlParameter[1]; parameters[0] = new MySqlParameter("?nsName", MySqlDbType.VarChar); parameters[0].Value = nsName; cmd.Parameters.AddRange(parameters); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { NativeScenery ns = new NativeScenery(); ns.NSID = Convert.ToInt64(reader[0]); ns.NSLinePlay = reader[1].ToString(); ns.NSIntroduce = reader[2].ToString(); ns.NSName = reader[3].ToString(); ns.NSProvince = reader[4].ToString(); ns.NSDateTime = reader[5].ToString(); ns.NSTripDay = reader[6].ToString(); ns.NSAdultPrice = reader[7].ToString(); ns.NSChildrenPrice = reader[8].ToString(); ns.NSSingleRoom = reader[9].ToString(); nsList.Add(ns); } return nsList; }