/* * 店铺列表 * */ public JsonResult ShopListGet(string shopName, string userId, string condition, string start, string limit) { OleDbConnection mycn = buildConn(); mycn.Open(); string sqlcondition = ""; if (!string.IsNullOrEmpty(shopName)) { sqlcondition += " and s.shopname like '%" + shopName + "%'"; } if (!string.IsNullOrEmpty(condition)) { sqlcondition += " and s.shopname like '%" + condition + "%'"; } if (string.IsNullOrEmpty(start)) { start = "0"; } if (string.IsNullOrEmpty(limit)) { limit = "10"; } int curPage = (Convert.ToInt16(start) / 10); int pag = curPage * Convert.ToInt16(limit); string sql = ""; if (start == "0") { sql = "select top " + Convert.ToInt16(limit) + " s.*,u.username from shop s,sys_user u where s.userid = u.id " + sqlcondition + " order by s.shopid desc";//+ "order by shopid desc LIMIT " + start + ", " + limit + ""; } else { sql = "select top " + Convert.ToInt16(limit) + " s.*,u.username from shop s,sys_user u where s.userid = u.id " + sqlcondition + " and s.shopid not in (select top " + pag + " shopid from shop where 1=1 " + sqlcondition + " ) order by s.shopid desc";//+ "order by shopid desc LIMIT " + start + ", " + limit + ""; } //string sql = "select s.*,u.username from shop s,sys_user u where 1=1 and s.userid = u.id " + sqlcondition;// +" LIMIT " + start + ", " + limit + ""; OleDbCommand mycm = new OleDbCommand(sql, mycn); OleDbDataReader msdr = mycm.ExecuteReader(); List<Shop> list = new List<Shop>(); while (msdr.Read()) { if (msdr.HasRows) { string[] readstring = new string[msdr.FieldCount]; for (int i = 0; i < msdr.FieldCount; i++) { if (msdr.IsDBNull(i)) { continue; } } Shop u = new Shop(); u.shopId = (int)msdr["shopid"]; u.shopName = Convert.ToString(msdr["shopname"]); u.userId = (int)msdr["userid"]; u.typeId = (int)msdr["typeid"]; u.address = Convert.ToString(msdr["address"]); u.areaId = (int)msdr["areaid"]; if (!string.IsNullOrEmpty((string)msdr["addtime"])) { u.addtime = Convert.ToDateTime((string)msdr["addtime"]); } if (!string.IsNullOrEmpty((string)msdr["opentime"])) { u.opentime = Convert.ToDateTime((string)msdr["opentime"]); } if (!string.IsNullOrEmpty((string)msdr["modifytime"])) { u.modifytime = Convert.ToDateTime((string)msdr["modifytime"]); } u.introduction = Convert.ToString(msdr["introduction"]); u.status = Convert.ToString(msdr["status"]); u.username = (string)msdr["username"]; u.piclist = (string)msdr["piclist"]; u.picdetail = Convert.ToString(msdr["picdetail"]); u.piclogo = Convert.ToString(msdr["piclogo"]); u.favorabledeals1 = Convert.ToString(msdr["favorabledeals1"]); u.favorabledeals2 = Convert.ToString(msdr["favorabledeals2"]); u.favorabledeals3 = Convert.ToString(msdr["favorabledeals3"]); u.favorabledeals4 = Convert.ToString(msdr["favorabledeals4"]); u.favorabledeals5 = Convert.ToString(msdr["favorabledeals5"]); //SELECT * FROM post WHERE FIND_IN_SET('123', tags) u.typeIds = Convert.ToString(msdr["type_ids"]); list.Add(u); } } msdr.Close(); mycn.Close(); return Json(new { data = list, success = true }, JsonRequestBehavior.AllowGet); }
/* * 店铺详细 * */ public JsonResult ShopDetailsGet(string id) { OleDbConnection mycn = buildConn(); mycn.Open(); if (string.IsNullOrEmpty(id)) { return Json(new { success = false, msg = "传入的id值为空!" }, JsonRequestBehavior.AllowGet); } string sql = "select * from shop where 1=1 and shopid = " + id + ""; OleDbCommand mycm = new OleDbCommand(sql, mycn); OleDbDataReader msdr = mycm.ExecuteReader(); Shop u = new Shop(); while (msdr.Read()) { if (msdr.HasRows) { string[] readstring = new string[msdr.FieldCount]; for (int i = 0; i < msdr.FieldCount; i++) { if (msdr.IsDBNull(i)) { continue; } } u.shopId = (int)msdr["shopid"]; u.shopName = (string)msdr["shopname"]; u.userId = (int)msdr["userid"]; u.typeId = (int)msdr["typeid"]; u.address = (string)msdr["address"]; u.areaId = (int)msdr["areaid"]; if (!string.IsNullOrEmpty((string)msdr["addtime"])) { u.addtime = Convert.ToDateTime((string)msdr["addtime"]); } if (!string.IsNullOrEmpty((string)msdr["opentime"])) { u.opentime = Convert.ToDateTime((string)msdr["opentime"]); } if (!string.IsNullOrEmpty((string)msdr["modifytime"])) { u.modifytime = Convert.ToDateTime((string)msdr["modifytime"]); } u.introduction = Convert.ToString(msdr["introduction"]); u.status = Convert.ToString(msdr["status"]); u.piclist = Convert.ToString(msdr["piclist"]); u.picdetail = (string)msdr["picdetail"]; u.piclogo = (string)msdr["piclogo"]; u.favorabledeals1 = Convert.ToString(msdr["favorabledeals1"]); u.favorabledeals2 = Convert.ToString(msdr["favorabledeals2"]); u.favorabledeals3 = Convert.ToString(msdr["favorabledeals3"]); u.favorabledeals4 = Convert.ToString(msdr["favorabledeals4"]); u.favorabledeals5 = Convert.ToString(msdr["favorabledeals5"]); } } msdr.Close(); mycn.Close(); return Json(new { data = u, success = true }, JsonRequestBehavior.AllowGet); }