/// <summary> /// 生成旅游天数的链接 /// </summary> /// <returns></returns> protected string CreateDaysSearchLink() { string link = "<a href='{0}' class='{1}'>{2}</a>"; LineSearchInfo model = CurrentSearchInfo; StringBuilder sb = new StringBuilder(); for (int i = 0; i <= 10; i++) { string title = i + "天"; if (i == 0) { title = "不限"; } if (i == 10) { title += "以上"; } model.Days = i; string href = LineSearch.CreateQueryParas(model); string reqVal = Request.QueryString["days"]; if (reqVal.IsNullOrEmpty()) { reqVal = "0"; } string cls = reqVal == i.ToString() ? "selected" : ""; sb.AppendLine(string.Format(link, href, cls, title)); } return(sb.ToString()); }
protected void ddlSecondCat_SelectedIndexChanged(object sender, EventArgs e) { LineSearchInfo model = CurrentSearchInfo; model.SecondID = ddlSecondCat.SelectedValue.ToArrowInt(); LineSearch.GoSearch(model); }
protected void Page_Load(object sender, EventArgs e) { string type = Request.QueryString["Type"].ToArrowString(); switch (type.ToLower()) { case "line": int id = Request.QueryString["id"].ToArrowInt(); string date = Request.QueryString["date"]; DateTime dt = date.ToArrowDateTime(); List <TMS.TravelGroupInfo> groups = new TMS.TravelGroup().SelectList("IsDel=0 And LineID=" + id + " Order By GoDate"); var model = groups.Find(s => s.GoDate == dt); if (model != null) { Response.Redirect("LineDetail.aspx?ID=" + id + "&GroupID=" + model.ID); } else { Response.Redirect("Default.aspx"); } break; case "promotion": int id1 = Request.QueryString["id"].ToArrowInt(); DateTime date1 = Request.QueryString["date"].ToArrowDateTime(); int promotionID = Request.QueryString["PromotionID"].ToArrowInt(); int lineID = Request.QueryString["LineID"].ToArrowInt(); List <TMS.V_Promotion_GroupInfo> promotionGroups = new TMS.V_Promotion_Group().SelectList("IsDel=0 And PromotionID=" + promotionID + " And LineID=" + lineID); var model1 = promotionGroups.Find(s => s.GoDate == date1); if (model1 != null) { Response.Redirect("PromotionGroupDetail.aspx?ID=" + id1 + "&PromotionID=" + promotionID + "&GroupID=" + model1.GroupID + "&LineID=" + lineID); } else { Response.Redirect("Default.aspx"); } break; case "search": string keywords = Request["keywords"].ToArrowString(); if (!string.IsNullOrEmpty(keywords)) { LineSearchInfo searchModel = new LineSearchInfo(); searchModel.KeyWord = keywords; LineSearch.GoSearch(searchModel); } Response.Redirect("Line.aspx"); break; default: Response.Redirect("Default.aspx"); break; } }
protected void btnReset_Click(object sender, EventArgs e) { LineSearchInfo model = CurrentSearchInfo; model.KeyWord = ""; model.MinGoDate = GlobalSetting.MinTime; model.MaxGoDate = GlobalSetting.MinTime; model.MinCustomPrice = 0M; model.MaxCustomPrice = 0M; LineSearch.GoSearch(model); }
/// <summary> /// 将查询实体转化成url查询参数,此时分页参数为1 /// </summary> /// <param name="model"></param> /// <returns></returns> public static string CreateQueryParas(LineSearchInfo model) { string para = "?p=1"; para += "&fid=" + model.FirstID; para += "&sid=" + model.SecondID; para += "&days=" + +model.Days; para += "&pickup=" + model.IsPickup; para += "&keyword=" + HttpContext.Current.Server.UrlEncode(model.KeyWord); para += "&fprice=" + model.FixPrice; para += "&cprice1=" + model.MinCustomPrice; para += "&cprice2=" + model.MaxCustomPrice; para += "&cdate1=" + (model.MinGoDate <= GlobalSetting.MinTime ? "" : model.MinGoDate.ToDateOnlyString()); para += "&cdate2=" + (model.MaxGoDate <= GlobalSetting.MinTime ? "" : model.MaxGoDate.ToDateOnlyString()); para += "&newsort=" + model.NewSort; para += "&pricesort=" + model.PriceSort; para += "&sellsort=" + model.SellSort; return(para); }
/// <summary> /// 从url获得查找条件实体 /// </summary> /// <returns></returns> public static LineSearchInfo GetSearchInfoFromUrl() { LineSearchInfo model = new LineSearchInfo(); model.FirstID = getUrlValue("fid").ToArrowInt(); model.SecondID = getUrlValue("sid").ToArrowInt(); model.Days = getUrlValue("days").ToArrowInt(); model.IsPickup = getUrlValue("pickup").ToArrowInt(); model.KeyWord = getUrlValue("keyword").ToArrowString(); model.FixPrice = getUrlValue("fprice").ToArrowInt(); model.MinCustomPrice = getUrlValue("cprice1").ToArrowDecimal(); model.MaxCustomPrice = getUrlValue("cprice2").ToArrowDecimal(); model.MinGoDate = getUrlValue("cdate1").ToArrowDateTime(GlobalSetting.MinTime); model.MaxGoDate = getUrlValue("cdate2").ToArrowDateTime(GlobalSetting.MinTime); model.NewSort = getUrlValue("newsort").ToArrowInt(); model.PriceSort = getUrlValue("pricesort").ToArrowInt(); model.SellSort = getUrlValue("sellsort").ToArrowInt(); return(model); }
/// <summary> /// 生成单价区间的搜索链接 /// </summary> /// <param name="value"></param> /// <param name="title"></param> /// <returns></returns> protected string CreateFixPriceSearchLink(string value, string title) { string link = "<a href='{0}' class='{1}'>{2}</a>"; LineSearchInfo model = CurrentSearchInfo; model.FixPrice = value.ToArrowInt(); model.MinCustomPrice = 0M; model.MaxCustomPrice = 0M; string href = LineSearch.CreateQueryParas(model); string reqVal = Request.QueryString["fprice"]; if (reqVal.IsNullOrEmpty()) { reqVal = "0"; } string cls = reqVal == value ? "selected" : ""; link = string.Format(link, href, cls, title); return(link); }
protected void btnSearch_Click(object sender, EventArgs e) { string keyword = Request.Form["keyword"].ToArrowString().Trim(); DateTime cdate1 = Request.Form["cdate1"].ToArrowDateTime(GlobalSetting.MinTime); DateTime cdate2 = Request.Form["cdate2"].ToArrowDateTime(GlobalSetting.MinTime); decimal cprice1 = Request.Form["cprice1"].ToArrowDecimal(); decimal cprice2 = Request.Form["cprice2"].ToArrowDecimal(); LineSearchInfo model = CurrentSearchInfo; if (cprice1 > 0 || cprice2 > 0) { model.FixPrice = 0; } model.KeyWord = keyword; model.MinGoDate = cdate1; model.MaxGoDate = cdate2; model.MaxCustomPrice = cprice2; model.MinCustomPrice = cprice1; LineSearch.GoSearch(model); }
/// <summary> /// 获得orderby子句 /// </summary> /// <param name="model"></param> /// <returns></returns> public static string CreateSort(LineSearchInfo model) { string orderBy = ""; if (model.NewSort == 1) { orderBy = "ID desc"; } else if (model.NewSort == -1) { orderBy = "ID asc"; } if (model.PriceSort == 1) { orderBy = "MinPrice desc"; } else if (model.PriceSort == -1) { orderBy = "MinPrice asc"; } if (model.SellSort == 1) { orderBy = "IsHot desc"; } else if (model.SellSort == -1) { orderBy = "IsHot asc"; } if (orderBy.IsNullOrEmpty()) { orderBy = "ID desc"; } return(orderBy); }
/// <summary> /// 价格 /// </summary> /// <returns></returns> protected string CreatePriceSort() { string downArrow = "sort-category-2"; string upArrow = "sort-category-1"; string doubleArrow = "sort-category-3"; LineSearchInfo model = CurrentSearchInfo; int priceSort = Request.QueryString["pricesort"].ToArrowInt(); string css = doubleArrow; if (priceSort == 0) { css = doubleArrow; model.PriceSort = 1; model.SellSort = 0; model.NewSort = 0; } else if (priceSort == 1) { css = downArrow; model.PriceSort = -1; model.SellSort = 0; model.NewSort = 0; } else if (priceSort == -1) { css = upArrow; model.PriceSort = 1; model.SellSort = 0; model.NewSort = 0; } string href = LineSearch.CreateQueryParas(model); string link = "<a class='sort-item {0}' href='{1}'>价格</a>"; link = string.Format(link, css, href); return(link); }
/// <summary> /// 生成where字句 /// </summary> /// <param name="model"></param> /// <returns></returns> public static string CreateFilter(LineSearchInfo model) { string filter = "IsDel=0"; if (model.FirstID > 0) { filter += " And FirstCatID = " + model.FirstID; } if (model.SecondID > 0) { filter += " And SecondCatID=" + model.SecondID; } if (model.Days > 0 && model.Days < 10) { filter += " And TravelDays=" + model.Days; } else if (model.Days >= 10) { filter += " And TravelDays>10"; } if (model.IsPickup == 1) { filter += " And IsPickup=1"; } else if (model.IsPickup == -1) { filter += " And IsPickup=0"; } if (!string.IsNullOrEmpty(model.KeyWord.Trim())) { filter += " And Name like '%" + model.KeyWord + "%'"; } if (model.MinGoDate > GlobalSetting.MinTime && model.MaxGoDate > GlobalSetting.MinTime) { filter += " And ID In(Select LineID From TravelGroup Where IsDel=0 And GoDate>='" + model.MinGoDate.ToString() + "' And GoDate<'" + model.MaxGoDate.AddDays(1).ToString() + "')"; } if (model.MinCustomPrice > 0 || model.MaxCustomPrice > 0) { if (model.MinCustomPrice > 0) { filter += " And MinPrice>=" + model.MinCustomPrice; } if (model.MaxCustomPrice > 0) { filter += " And MinPrice<" + model.MaxCustomPrice; } } else { //如果自定义价格无值,则按固定价格区间 if (model.FixPrice == 1) { filter += " And MinPrice<=500"; } else if (model.FixPrice == 2) { filter += " And MinPrice>500 And MinPrice<=1000"; } else if (model.FixPrice == 3) { filter += " And MinPrice>1000 And MinPrice<=2000"; } else if (model.FixPrice == 4) { filter += " And MinPrice>2000 And MinPrice<=4000"; } else if (model.FixPrice == 5) { filter += " And MinPrice>4000 And MinPrice<=6000"; } else if (model.FixPrice == 6) { filter += " And MinPrice>6000"; } } return(filter); }
/// <summary> /// 将查询实体转化成url查询参数,此时分页参数为1,并提交查询 /// </summary> /// <param name="model"></param> /// <returns></returns> public static void GoSearch(LineSearchInfo model) { string para = CreateQueryParas(model); HttpContext.Current.Response.Redirect("Line.aspx" + para); }