/// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { id = DTRequest.GetQueryInt("id"); page = DTRequest.GetQueryString("page"); BLL.meal_good bll = new BLL.meal_good(); if (id > 0) //如果ID获取到,将使用ID { if (bll.GetList("meal_id='" + id + "'").Tables[0].Rows.Count <= 0) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); return; } // model = bll.GetModel(id); model_meal = new BLL.meal().GetModel(id); if (model_meal == null) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); return; } dt = bll.GetList("meal_id='"+id+"'").Tables[0]; } //跳转URL if (model.link_url != null) model.link_url = model.link_url.Trim(); if (!string.IsNullOrEmpty(model.link_url)) { HttpContext.Current.Response.Redirect(model.link_url); } }
/// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { id = DTRequest.GetQueryInt("id"); page = DTRequest.GetQueryString("page"); BLL.meal_good bll = new BLL.meal_good(); if (id > 0) //如果ID获取到,将使用ID { if (bll.GetList("meal_id='" + id + "'").Tables[0].Rows.Count <= 0) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); return; } // model = bll.GetModel(id); model_meal = new BLL.meal().GetModel(id); if (model_meal == null) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); return; } dt = bll.GetList("meal_id='" + id + "'").Tables[0]; } //跳转URL if (model.link_url != null) { model.link_url = model.link_url.Trim(); } if (!string.IsNullOrEmpty(model.link_url)) { HttpContext.Current.Response.Redirect(model.link_url); } }
protected DataTable dt_other_goods = new DataTable(); //其他商品表 /// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { id = DTRequest.GetQueryInt("id"); page = DTRequest.GetQueryString("page"); BLL.article bll = new BLL.article(); if (id > 0) //如果ID获取到,将使用ID { if (!bll.Exists(id)) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); return; } model = bll.GetModel(id); } else if (!string.IsNullOrEmpty(page)) //否则检查设置的别名 { if (!bll.Exists(page)) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); return; } model = bll.GetModel(page); } else { return; } //跳转URL if (model.link_url != null) { model.link_url = model.link_url.Trim(); } if (!string.IsNullOrEmpty(model.link_url)) { HttpContext.Current.Response.Redirect(model.link_url); } //销量 DataTable dt_order_good_count = new BLL.orders().get_order_good_count(id).Tables[0]; if (dt_order_good_count != null && dt_order_good_count.Rows.Count > 0) { order_sum = Convert.ToDecimal(dt_order_good_count.Rows[0]["quantity"]); } Model.article_category model_category = new BLL.article_category().GetModel(model.category_id); #region //规格表 BLL.standard_price bll_standard_price = new BLL.standard_price(); DataTable dt_standard_price = bll_standard_price.GetList("good_id=" + id).Tables[0]; if (dt_standard_price != null && dt_standard_price.Rows.Count > 0) { BLL.standard bll_standard = new BLL.standard(); if (model_category != null) { DataTable dt_old_standard = bll_standard.GetList("'" + model_category.class_list + "' like '%,'+convert(nvarchar(10),category_id)+',%'").Tables[0]; dt_standard.Columns.Add("id", typeof(int)); dt_standard.Columns.Add("title", typeof(string)); dt_standard.Columns.Add("value", typeof(string)); dt_standard.PrimaryKey = new DataColumn[] { dt_standard.Columns["id"] }; foreach (DataRow dr in dt_old_standard.Rows) { //if(Convert.ToInt32(dr[""])) DataRow new_dr = dt_standard.NewRow(); new_dr["id"] = dr["id"]; new_dr["title"] = dr["title"]; DataTable dt_standard_value = new BLL.standard_value().GetList("standard_id=" + dr["id"].ToString()).Tables[0]; if (dt_standard_value != null || dt_standard_value.Rows.Count > 0) { string str_value = ""; foreach (DataRow dr_value in dt_standard_value.Rows) { str_value += dr_value["id"].ToString() + "|" + dr_value["value"].ToString() + ","; } new_dr["value"] = str_value.TrimEnd(','); dt_standard.Rows.Add(new_dr); } } } } #endregion //单位表 BLL.unit bll_unit = new BLL.unit(); dt_unit = bll_unit.GetList("good_id=" + id).Tables[0]; //套餐() BLL.meal_good bll_meal_good = new BLL.meal_good(); BLL.meal bll_meal = new BLL.meal(); dt_meal = bll_meal.GetMealByGood(id, "jiejuefangan").Tables[0]; dt_meal.TableName = "dt_meal"; if (dt_meal != null && dt_meal.Rows.Count > 0) { //套餐商品 DataTable old_dt_meal_good = bll_meal_good.GetList("meal_id=" + dt_meal.Rows[0]["id"].ToString()).Tables[0]; dt_meal_good = new DataTable(); dt_meal_good.Columns.Add("meal_id"); dt_meal_good.Columns.Add("good_standard_price"); dt_meal_good.Columns.Add("title"); dt_meal_good.Columns.Add("all_title"); dt_meal_good.Columns.Add("img_url"); dt_meal_good.Columns.Add("good_id"); dt_meal_good.Columns.Add("price"); string str_meal_good_ids = ","; if (old_dt_meal_good != null && old_dt_meal_good.Rows.Count > 0) { foreach (DataRow dr in old_dt_meal_good.Rows) { if (str_meal_good_ids.IndexOf("," + dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ",") > -1) { continue; } str_meal_good_ids += dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ","; Model.article modelt = bll.GetModel(Convert.ToInt32(dr["good_id"])); if (modelt != null) { Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(dr["standard_price_id"])); string str_standard_price = ""; string str_unit = ""; if (model_standard_price != null) { for (int i = 0; i < model_standard_price.standards.Split(',').Length; i++) { if (!string.IsNullOrEmpty(model_standard_price.standards.Split(',')[i])) { str_standard_price += model_standard_price.standards.Split(',')[i]; if (i < model_standard_price.standard_values.Split(',').Length) { str_standard_price += ":" + model_standard_price.standard_values.Split(',')[i]; } } } } Model.unit model_unit = bll_unit.GetModel(Convert.ToDecimal(dr["unit_id"])); if (model_unit != null) { str_unit += "单位:" + model_unit.title + (string.IsNullOrEmpty(model_unit.content) ? "" : model_unit.content); } DataRow new_dr = dt_meal_good.NewRow(); new_dr["meal_id"] = dr["meal_id"]; new_dr["title"] = Utils.CutString(modelt.title, 10); new_dr["good_standard_price"] = dr["good_id"].ToString() + dr["standard_price_id"].ToString(); new_dr["all_title"] = modelt.title + " " + str_standard_price + str_unit; new_dr["img_url"] = modelt.img_url; new_dr["price"] = dr["sell_price"]; new_dr["good_id"] = dr["good_id"]; dt_meal_good.Rows.Add(new_dr); } } dt_meal_good.TableName = "dt_meal_good"; } } //属性表 BLL.property_good bll_property_good = new BLL.property_good(); BLL.property bll_property = new BLL.property(); BLL.property_value bll_property_value = new BLL.property_value(); DataTable dt_old_property = bll_property_good.GetList("good_id=" + id).Tables[0]; dt_property.Columns.Add("id"); dt_property.Columns.Add("title"); dt_property.Columns.Add("value"); dt_property.PrimaryKey = new DataColumn[] { dt_property.Columns["id"] }; foreach (DataRow dr in dt_old_property.Rows) { Model.property model_property = bll_property.GetModel(Convert.ToInt32(dr["property_id"])); Model.property_value model_property_value = bll_property_value.GetModel(Convert.ToDecimal(dr["property_value_id"])); if (model != null && model_property_value != null) { if (dt_property.Rows.Find(dr["property_id"]) != null) { dt_property.Rows.Find(dr["property_id"])["value"] = dt_property.Rows.Find(dr["property_id"])["value"].ToString() + "," + model_property_value.value; } else { DataRow new_dr = dt_property.NewRow(); new_dr["id"] = dr["property_id"]; new_dr["title"] = model_property.title; new_dr["value"] = model_property_value.value; dt_property.Rows.Add(new_dr); } } } //标签 BLL.tag_good bll_tag_good = new BLL.tag_good(); DataTable dt_tag_good = bll_tag_good.GetList("good_id=" + id).Tables[0]; dt_tag.Columns.Add("title"); foreach (DataRow dr in dt_tag_good.Rows) { Model.tag model_tag = new BLL.tag().GetModel(Convert.ToInt32(dr["tag_id"])); if (model_tag != null) { DataRow new_dr = dt_tag.NewRow(); new_dr["title"] = model_tag.title; dt_tag.Rows.Add(new_dr); } } //推荐搭配 dt_red = bll_meal.GetMealByGood(id, "tuijiandapei").Tables[0]; dt_red.TableName = "dt_red"; if (dt_red != null && dt_red.Rows.Count > 0) { DataTable old_dt_red_good = bll_meal_good.GetList("meal_id=" + dt_red.Rows[0]["id"].ToString()).Tables[0]; dt_red_good = new DataTable(); dt_red_good.Columns.Add("meal_id"); dt_red_good.Columns.Add("good_standard_price"); dt_red_good.Columns.Add("title"); dt_red_good.Columns.Add("all_title"); dt_red_good.Columns.Add("good_id"); dt_red_good.Columns.Add("img_url"); dt_red_good.Columns.Add("price"); string str_red_good_ids = ","; if (old_dt_red_good != null && old_dt_red_good.Rows.Count > 0) { foreach (DataRow dr in old_dt_red_good.Rows) { if (str_red_good_ids.IndexOf("," + dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ",") > -1) { continue; } str_red_good_ids += dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ","; Model.article modelt = bll.GetModel(Convert.ToInt32(dr["good_id"])); if (modelt != null) { Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(dr["standard_price_id"])); string str_standard_price = ""; string str_unit = ""; if (model_standard_price != null) { for (int i = 0; i < model_standard_price.standards.Split(',').Length; i++) { if (!string.IsNullOrEmpty(model_standard_price.standards.Split(',')[i])) { str_standard_price += model_standard_price.standards.Split(',')[i]; if (i < model_standard_price.standard_values.Split(',').Length) { str_standard_price += ":" + model_standard_price.standard_values.Split(',')[i]; } } } } Model.unit model_unit = bll_unit.GetModel(Convert.ToDecimal(dr["unit_id"])); if (model_unit != null) { str_unit += "单位:" + model_unit.title + (string.IsNullOrEmpty(model_unit.content) ? "" : model_unit.content); } DataRow new_dr = dt_red_good.NewRow(); new_dr["meal_id"] = dr["meal_id"]; new_dr["title"] = Utils.CutString(modelt.title, 10); new_dr["good_standard_price"] = dr["good_id"].ToString() + dr["standard_price_id"].ToString(); new_dr["all_title"] = modelt.title + " " + str_standard_price + str_unit; new_dr["img_url"] = modelt.img_url; new_dr["price"] = dr["sell_price"]; new_dr["good_id"] = dr["good_id"]; dt_red_good.Rows.Add(new_dr); } } dt_red_good.TableName = "dt_red_good"; } } //类别相关 if (model_category != null) { if (new BLL.article_category().GetModel(model_category.parent_id) != null) { parent_category_title = new BLL.article_category().GetModel(model_category.parent_id).title; dt_category = new BLL.article_category().GetList(model_category.parent_id, "goods"); } dt_other_goods = bll.get_order_buy_good(5, model_category.id).Tables[0]; } }
private void ShowInfo(int _id) { BLL.meal bll = new BLL.meal(); Model.meal model = bll.GetModel(_id); ddlCategoryId.SelectedValue = model.category_id.ToString(); txt_title.Text = model.title; txtImgUrl.Text = model.img_url; txtIndexUrl.Text = model.index_url; txtSortId.Text = model.sort_id.ToString(); BLL.meal_good bll_meal_good = new BLL.meal_good(); DataTable dt_meal_good = bll_meal_good.GetList("meal_id=" + _id).Tables[0]; string str_ck = ""; string str_standard_good_price_ids = ","; foreach (DataRow dr in dt_meal_good.Rows) { if (str_standard_good_price_ids.IndexOf("," + (Convert.ToInt32(dr["meal_id"]) + "-" + Convert.ToInt32(dr["good_id"]) + "-" + Convert.ToDecimal(dr["standard_price_id"]) + "-" + Convert.ToDecimal(dr["unit_id"])) + ",") > -1) { continue; } str_standard_good_price_ids += Convert.ToInt32(dr["meal_id"]) + "-" + Convert.ToInt32(dr["good_id"]) + "-" + Convert.ToDecimal(dr["standard_price_id"]) + "-" + Convert.ToDecimal(dr["unit_id"]) + ","; Model.article model_good = new BLL.article().GetModel(Convert.ToInt32(dr["good_id"])); if (model_good != null) { //单位 string unit = ""; string str_quantity = ",数量:" + Convert.ToInt32(dr["quantity"]); Model.unit model_unit = new BLL.unit().GetModel(Convert.ToInt32(dr["unit_id"])); if (model_unit != null) { unit = ",单位:" + model_unit.title; if (!string.IsNullOrEmpty(model_unit.content)) { unit += "(" + model_unit.content + ")"; } } //规格 string standard = ""; BLL.standard_price bll_standard_price = new BLL.standard_price(); Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(dr["standard_price_id"])); if (model_standard_price != null) { if (!string.IsNullOrEmpty(model_standard_price.standards)) { string[] arr_standard = model_standard_price.standards.Split(','); string[] arr_standard_value = model_standard_price.standard_values.Split(','); for (int i = 0; i < arr_standard.Length; i++) { standard += arr_standard[i] + ":"; if (i < arr_standard_value.Length) { standard += arr_standard_value[i]; } standard += ","; } } } if (!string.IsNullOrEmpty(standard)) { standard = standard.Substring(0, standard.Length - 1); } str_ck += "<span onclick='ck_goods(this)'>" + model_good.title + str_quantity + unit + " " + standard + "<input type='checkbox' name='ck_good' style='display:none;' value='" + model_good.id + "_" + Convert.ToDecimal(dr["standard_price_id"]) + "_" + Convert.ToInt32(dr["unit_id"]) + "_" + Convert.ToInt32(dr["quantity"]) + "' checked='checked'/></span><br />"; } goods.InnerHtml = str_ck; } }
/// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { id = DTRequest.GetQueryInt("id"); page = DTRequest.GetQueryString("page"); BLL.article bll = new BLL.article(); if (id > 0) //如果ID获取到,将使用ID { if (!bll.Exists(id)) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); return; } model = bll.GetModel(id); } else if (!string.IsNullOrEmpty(page)) //否则检查设置的别名 { if (!bll.Exists(page)) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); return; } model = bll.GetModel(page); } else { return; } //跳转URL if (model.link_url != null) model.link_url = model.link_url.Trim(); if (!string.IsNullOrEmpty(model.link_url)) { HttpContext.Current.Response.Redirect(model.link_url); } //销量 DataTable dt_order_good_count = new BLL.orders().get_order_good_count(id).Tables[0]; if (dt_order_good_count != null && dt_order_good_count.Rows.Count > 0) { order_sum = Convert.ToDecimal(dt_order_good_count.Rows[0]["quantity"]); } Model.article_category model_category = new BLL.article_category().GetModel(model.category_id); #region //规格表 BLL.standard_price bll_standard_price = new BLL.standard_price(); DataTable dt_standard_price = bll_standard_price.GetList("good_id=" + id).Tables[0]; if (dt_standard_price != null && dt_standard_price.Rows.Count > 0) { BLL.standard bll_standard = new BLL.standard(); if (model_category != null) { DataTable dt_old_standard = bll_standard.GetList("'" + model_category.class_list + "' like '%,'+convert(nvarchar(10),category_id)+',%'").Tables[0]; dt_standard.Columns.Add("id", typeof(int)); dt_standard.Columns.Add("title", typeof(string)); dt_standard.Columns.Add("value", typeof(string)); dt_standard.PrimaryKey = new DataColumn[] { dt_standard.Columns["id"] }; foreach (DataRow dr in dt_old_standard.Rows) { //if(Convert.ToInt32(dr[""])) DataRow new_dr = dt_standard.NewRow(); new_dr["id"] = dr["id"]; new_dr["title"] = dr["title"]; DataTable dt_standard_value = new BLL.standard_value().GetList("standard_id=" + dr["id"].ToString()).Tables[0]; if (dt_standard_value != null || dt_standard_value.Rows.Count > 0) { string str_value = ""; foreach (DataRow dr_value in dt_standard_value.Rows) { str_value += dr_value["id"].ToString() + "|" + dr_value["value"].ToString() + ","; } new_dr["value"] = str_value.TrimEnd(','); dt_standard.Rows.Add(new_dr); } } } } #endregion //单位表 BLL.unit bll_unit = new BLL.unit(); dt_unit = bll_unit.GetList("good_id=" + id).Tables[0]; //套餐() BLL.meal_good bll_meal_good = new BLL.meal_good(); BLL.meal bll_meal = new BLL.meal(); dt_meal = bll_meal.GetMealByGood(id, "jiejuefangan").Tables[0]; dt_meal.TableName = "dt_meal"; if (dt_meal != null && dt_meal.Rows.Count > 0) { //套餐商品 DataTable old_dt_meal_good = bll_meal_good.GetList("meal_id=" + dt_meal.Rows[0]["id"].ToString()).Tables[0]; dt_meal_good = new DataTable(); dt_meal_good.Columns.Add("meal_id"); dt_meal_good.Columns.Add("good_standard_price"); dt_meal_good.Columns.Add("title"); dt_meal_good.Columns.Add("all_title"); dt_meal_good.Columns.Add("img_url"); dt_meal_good.Columns.Add("good_id"); dt_meal_good.Columns.Add("price"); string str_meal_good_ids = ","; if (old_dt_meal_good != null && old_dt_meal_good.Rows.Count > 0) { foreach (DataRow dr in old_dt_meal_good.Rows) { if (str_meal_good_ids.IndexOf("," + dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ",") > -1) { continue; } str_meal_good_ids += dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ","; Model.article modelt = bll.GetModel(Convert.ToInt32(dr["good_id"])); if (modelt != null) { Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(dr["standard_price_id"])); string str_standard_price = ""; string str_unit = ""; if (model_standard_price != null) { for (int i = 0; i < model_standard_price.standards.Split(',').Length; i++) { if (!string.IsNullOrEmpty(model_standard_price.standards.Split(',')[i])) { str_standard_price += model_standard_price.standards.Split(',')[i]; if (i < model_standard_price.standard_values.Split(',').Length) { str_standard_price += ":" + model_standard_price.standard_values.Split(',')[i]; } } } } Model.unit model_unit = bll_unit.GetModel(Convert.ToDecimal(dr["unit_id"])); if (model_unit != null) { str_unit += "单位:" + model_unit.title + (string.IsNullOrEmpty(model_unit.content) ? "" : model_unit.content); } DataRow new_dr = dt_meal_good.NewRow(); new_dr["meal_id"] = dr["meal_id"]; new_dr["title"] = Utils.CutString(modelt.title, 10); new_dr["good_standard_price"] = dr["good_id"].ToString() + dr["standard_price_id"].ToString(); new_dr["all_title"] = modelt.title + " " + str_standard_price + str_unit; new_dr["img_url"] = modelt.img_url; new_dr["price"] = dr["sell_price"]; new_dr["good_id"] = dr["good_id"]; dt_meal_good.Rows.Add(new_dr); } } dt_meal_good.TableName = "dt_meal_good"; } } //属性表 BLL.property_good bll_property_good = new BLL.property_good(); BLL.property bll_property = new BLL.property(); BLL.property_value bll_property_value = new BLL.property_value(); DataTable dt_old_property = bll_property_good.GetList("good_id=" + id).Tables[0]; dt_property.Columns.Add("id"); dt_property.Columns.Add("title"); dt_property.Columns.Add("value"); dt_property.PrimaryKey = new DataColumn[] { dt_property.Columns["id"] }; foreach (DataRow dr in dt_old_property.Rows) { Model.property model_property = bll_property.GetModel(Convert.ToInt32(dr["property_id"])); Model.property_value model_property_value = bll_property_value.GetModel(Convert.ToDecimal(dr["property_value_id"])); if (model != null && model_property_value!=null) { if (dt_property.Rows.Find(dr["property_id"]) != null) { dt_property.Rows.Find(dr["property_id"])["value"] = dt_property.Rows.Find(dr["property_id"])["value"].ToString() + "," + model_property_value.value; } else { DataRow new_dr = dt_property.NewRow(); new_dr["id"] = dr["property_id"]; new_dr["title"] = model_property.title; new_dr["value"] = model_property_value.value; dt_property.Rows.Add(new_dr); } } } //标签 BLL.tag_good bll_tag_good = new BLL.tag_good(); DataTable dt_tag_good = bll_tag_good.GetList("good_id=" + id).Tables[0]; dt_tag.Columns.Add("title"); foreach (DataRow dr in dt_tag_good.Rows) { Model.tag model_tag = new BLL.tag().GetModel(Convert.ToInt32(dr["tag_id"])); if (model_tag != null) { DataRow new_dr = dt_tag.NewRow(); new_dr["title"] = model_tag.title; dt_tag.Rows.Add(new_dr); } } //推荐搭配 dt_red = bll_meal.GetMealByGood(id, "tuijiandapei").Tables[0]; dt_red.TableName = "dt_red"; if (dt_red != null && dt_red.Rows.Count > 0) { DataTable old_dt_red_good = bll_meal_good.GetList("meal_id=" + dt_red.Rows[0]["id"].ToString()).Tables[0]; dt_red_good = new DataTable(); dt_red_good.Columns.Add("meal_id"); dt_red_good.Columns.Add("good_standard_price"); dt_red_good.Columns.Add("title"); dt_red_good.Columns.Add("all_title"); dt_red_good.Columns.Add("good_id"); dt_red_good.Columns.Add("img_url"); dt_red_good.Columns.Add("price"); string str_red_good_ids = ","; if (old_dt_red_good != null && old_dt_red_good.Rows.Count > 0) { foreach (DataRow dr in old_dt_red_good.Rows) { if (str_red_good_ids.IndexOf("," + dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ",") > -1) { continue; } str_red_good_ids += dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ","; Model.article modelt = bll.GetModel(Convert.ToInt32(dr["good_id"])); if (modelt != null) { Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(dr["standard_price_id"])); string str_standard_price = ""; string str_unit = ""; if (model_standard_price != null) { for (int i = 0; i < model_standard_price.standards.Split(',').Length; i++) { if (!string.IsNullOrEmpty(model_standard_price.standards.Split(',')[i])) { str_standard_price += model_standard_price.standards.Split(',')[i]; if (i < model_standard_price.standard_values.Split(',').Length) { str_standard_price += ":" + model_standard_price.standard_values.Split(',')[i]; } } } } Model.unit model_unit = bll_unit.GetModel(Convert.ToDecimal(dr["unit_id"])); if (model_unit != null) { str_unit += "单位:" + model_unit.title + (string.IsNullOrEmpty(model_unit.content) ? "" : model_unit.content); } DataRow new_dr = dt_red_good.NewRow(); new_dr["meal_id"] = dr["meal_id"]; new_dr["title"] = Utils.CutString(modelt.title, 10); new_dr["good_standard_price"] = dr["good_id"].ToString() + dr["standard_price_id"].ToString(); new_dr["all_title"] = modelt.title + " " + str_standard_price + str_unit; new_dr["img_url"] = modelt.img_url; new_dr["price"] = dr["sell_price"]; new_dr["good_id"] = dr["good_id"]; dt_red_good.Rows.Add(new_dr); } } dt_red_good.TableName = "dt_red_good"; } } //类别相关 if (model_category != null) { if (new BLL.article_category().GetModel(model_category.parent_id) != null) { parent_category_title = new BLL.article_category().GetModel(model_category.parent_id).title; dt_category = new BLL.article_category().GetList(model_category.parent_id, "goods"); } dt_other_goods = bll.get_order_buy_good(5, model_category.id).Tables[0]; } }
private void new_meal_into_shopping(HttpContext context) { string good_info = DTRequest.GetQueryString("good_info");//套餐ID|商品ID if (string.IsNullOrEmpty(good_info)) { context.Response.Write("{\"status\":\"0\", \"msg\":\"请选择您要购买的商品!\"}"); return; } BLL.meal_good bll_meal_good = new BLL.meal_good(); BLL.standard_price bll_standard_price = new BLL.standard_price(); string[] str_meal = good_info.Substring(0, good_info.Length - 1).Split(','); foreach (string str in str_meal) { string str_standard_value = ""; int unit_id = 0; int quantity = 1; if (!string.IsNullOrEmpty(str)) { if (str.Split('|').Length == 2) { DataTable dt_meal_good = bll_meal_good.GetList(1, "meal_id=" + str.Split('|')[0] + " and good_id=" + str.Split('|')[1], "group_id asc").Tables[0]; unit_id = Convert.ToInt32(dt_meal_good.Rows[0]["unit_id"]); quantity = Convert.ToInt32(dt_meal_good.Rows[0]["quantity"]); if (dt_meal_good != null && dt_meal_good.Rows.Count > 0) { if (dt_meal_good.Rows[0]["standard_price_id"] != null && Convert.ToDecimal(dt_meal_good.Rows[0]["standard_price_id"]) != 0) { //有规格 Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(dt_meal_good.Rows[0]["standard_price_id"])); if (model_standard_price != null) { string[] arr_standard = model_standard_price.standard_ids.Split(','); string[] arr_standard_value = model_standard_price.standard_value_ids.Split(','); if (arr_standard.Length == arr_standard_value.Length) { for (int i = 0; i < arr_standard.Length; i++) { str_standard_value += arr_standard[i] + "|" + arr_standard_value[i] + ","; } if (!string.IsNullOrEmpty(str_standard_value)) { str_standard_value = str_standard_value.Substring(0, str_standard_value.Length - 1); } } else { //Error context.Response.Write("{\"status\":\"0\", \"msg\":\"参数错误加入购物车失败!\"}"); return; } } } else { //haven't standard str_standard_value = 0 + "|" + 0; } } else { //Error context.Response.Write("{\"status\":\"0\", \"msg\":\"参数错误加入购物车失败!\"}"); return; } } } //add to shopping //商品ID-规格ID|规格值ID,规格ID|规格值ID-单位ID Web.UI.ShopCart.Add(str.Split('|')[1] + "-" + str_standard_value + "-" + unit_id, quantity); } context.Response.Write("{\"status\":\"1\", \"msg\":\"加入购物车成功!\"}"); return; }
private void get_meal_good(HttpContext context) { int meal_id = DTRequest.GetQueryInt("meal_id"); //套餐() BLL.article bll = new BLL.article(); BLL.meal bll_meal = new BLL.meal(); BLL.meal_good bll_meal_good = new BLL.meal_good(); BLL.unit bll_unit = new BLL.unit(); BLL.standard_price bll_standard_price = new BLL.standard_price(); DataTable dt_meal = bll_meal.GetList("id=" + meal_id).Tables[0]; if (dt_meal != null && dt_meal.Rows.Count > 0) { //套餐商品 DataTable old_dt_meal_good = bll_meal_good.GetList("meal_id=" + dt_meal.Rows[0]["id"].ToString()).Tables[0]; DataTable dt_meal_good = new DataTable(); dt_meal_good.Columns.Add("meal_id"); dt_meal_good.Columns.Add("good_standard_price"); dt_meal_good.Columns.Add("title"); dt_meal_good.Columns.Add("all_title"); dt_meal_good.Columns.Add("img_url"); dt_meal_good.Columns.Add("price"); dt_meal_good.Columns.Add("good_id"); string str_meal_good_ids = ","; if (old_dt_meal_good != null && old_dt_meal_good.Rows.Count > 0) { foreach (DataRow dr in old_dt_meal_good.Rows) { if (str_meal_good_ids.IndexOf("," + dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ",") > -1) { continue; } str_meal_good_ids += dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ","; Model.article modelt = bll.GetModel(Convert.ToInt32(dr["good_id"])); if (modelt != null) { Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(dr["standard_price_id"])); string str_standard_price = ""; string str_unit = ""; if (model_standard_price != null) { for (int i = 0; i < model_standard_price.standards.Split(',').Length; i++) { if (!string.IsNullOrEmpty(model_standard_price.standards.Split(',')[i])) { str_standard_price += model_standard_price.standards.Split(',')[i]; if (i < model_standard_price.standard_values.Split(',').Length) { str_standard_price += ":" + model_standard_price.standard_values.Split(',')[i]; } } } } Model.unit model_unit = bll_unit.GetModel(Convert.ToDecimal(dr["unit_id"])); if (model_unit != null) { str_unit += "单位:" + model_unit.title + (string.IsNullOrEmpty(model_unit.content) ? "" : model_unit.content); } DataRow new_dr = dt_meal_good.NewRow(); new_dr["meal_id"] = dr["meal_id"]; new_dr["title"] = Utils.CutString(modelt.title, 10); new_dr["good_standard_price"] = dr["good_id"].ToString() + dr["standard_price_id"].ToString(); new_dr["all_title"] = modelt.title + " " + str_standard_price + str_unit; new_dr["img_url"] = modelt.img_url; new_dr["price"] = dr["sell_price"]; new_dr["good_id"] = dr["good_id"]; dt_meal_good.Rows.Add(new_dr); } } context.Response.Write(myJson.getJson(dt_meal_good)); return; } else { context.Response.Write("Null"); return; } } }
private void get_goods(HttpContext context) { Model.users model_user = new BasePage().GetUserInfo(); int goods_id = DTRequest.GetQueryInt("goods_id"); BLL.article bll = new BLL.article(); //商品表 DataTable dt_article = bll.GetList(0, "id=" + goods_id, "id desc").Tables[0]; if (dt_article.Rows.Count <= 0) { context.Response.Write("NotFind"); return; } dt_article.TableName = "dt_goods"; DataSet ds = new DataSet(); ds.Tables.Add(dt_article.Copy()); //销量 DataTable dt_order_good_count = new BLL.orders().get_order_good_count(goods_id).Tables[0]; if (dt_order_good_count != null && dt_order_good_count.Rows.Count > 0) { dt_order_good_count.TableName = "dt_order_good_count"; ds.Tables.Add(dt_order_good_count.Copy()); } //图片表 DataTable dt_albums = bll.GetAlbumsList(5, "article_id=" + goods_id, "add_time desc").Tables[0]; dt_albums.TableName = "dt_albums"; if (dt_albums != null && dt_albums.Rows.Count > 0) { ds.Tables.Add(dt_albums.Copy()); } //扩展字段表 DataTable dt_attribute = bll.GetAttributeList(0, "article_id=" + goods_id, "").Tables[0]; if (dt_attribute == null && dt_attribute.Rows.Count <= 0) { context.Response.Write("NotFind"); return; } dt_attribute.TableName = "dt_attribute"; ds.Tables.Add(dt_attribute.Copy()); //规格表 BLL.standard_price bll_standard_price = new BLL.standard_price(); DataTable dt_standard_price = bll_standard_price.GetList("good_id=" + goods_id).Tables[0]; if (dt_standard_price != null && dt_standard_price.Rows.Count > 0) { BLL.standard bll_standard = new BLL.standard(); Model.article_category model_category = new BLL.article_category().GetModel(Convert.ToInt32(dt_article.Rows[0]["category_id"])); if (model_category == null) { context.Response.Write("NotFind"); return; } DataTable dt_old_standard = bll_standard.GetList("'" + model_category.class_list + "' like '%,'+convert(nvarchar(10),category_id)+',%'").Tables[0]; DataTable dt_standard = new DataTable(); dt_standard.Columns.Add("id", typeof(int)); dt_standard.Columns.Add("title", typeof(string)); dt_standard.Columns.Add("value", typeof(string)); dt_standard.PrimaryKey = new DataColumn[] { dt_standard.Columns["id"] }; foreach (DataRow dr in dt_old_standard.Rows) { //if(Convert.ToInt32(dr[""])) DataRow new_dr = dt_standard.NewRow(); new_dr["id"] = dr["id"]; new_dr["title"] = dr["title"]; DataTable dt_standard_value = new BLL.standard_value().GetList("standard_id=" + dr["id"].ToString()).Tables[0]; if (dt_standard_value == null || dt_standard_value.Rows.Count <= 0) { context.Response.Write("NotFind"); return; } string str_value = ""; foreach (DataRow dr_value in dt_standard_value.Rows) { str_value += dr_value["id"].ToString() + "|" + dr_value["value"].ToString() + ","; } new_dr["value"] = str_value.TrimEnd(','); dt_standard.Rows.Add(new_dr); } dt_standard.TableName = "dt_standard"; if (dt_standard != null && dt_standard.Rows.Count > 0) { ds.Tables.Add(dt_standard.Copy()); } } //单位表 BLL.unit bll_unit = new BLL.unit(); DataTable dt_unit = bll_unit.GetList("good_id=" + goods_id).Tables[0]; dt_unit.TableName = "dt_unit"; if (dt_unit != null && dt_unit.Rows.Count > 0) { ds.Tables.Add(dt_unit.Copy()); } BLL.meal_good bll_meal_good = new BLL.meal_good(); //套餐() BLL.meal bll_meal = new BLL.meal(); DataTable dt_meal = bll_meal.GetMealByGood(goods_id, "jiejuefangan").Tables[0]; dt_meal.TableName = "dt_meal"; if (dt_meal != null && dt_meal.Rows.Count > 0) { ds.Tables.Add(dt_meal.Copy()); //套餐商品 DataTable old_dt_meal_good = bll_meal_good.GetList("meal_id=" + dt_meal.Rows[0]["id"].ToString()).Tables[0]; DataTable dt_meal_good = new DataTable(); dt_meal_good.Columns.Add("meal_id"); dt_meal_good.Columns.Add("good_standard_price"); dt_meal_good.Columns.Add("title"); dt_meal_good.Columns.Add("all_title"); dt_meal_good.Columns.Add("img_url"); dt_meal_good.Columns.Add("price"); string str_meal_good_ids = ","; if (old_dt_meal_good != null && old_dt_meal_good.Rows.Count > 0) { foreach (DataRow dr in old_dt_meal_good.Rows) { if (str_meal_good_ids.IndexOf("," + dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ",") > -1) { continue; } str_meal_good_ids += dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ","; Model.article modelt = bll.GetModel(Convert.ToInt32(dr["good_id"])); if (modelt != null) { Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(dr["standard_price_id"])); string str_standard_price = ""; string str_unit = ""; if (model_standard_price != null) { for (int i = 0; i < model_standard_price.standards.Split(',').Length; i++) { if (!string.IsNullOrEmpty(model_standard_price.standards.Split(',')[i])) { str_standard_price += model_standard_price.standards.Split(',')[i]; if (i < model_standard_price.standard_values.Split(',').Length) { str_standard_price += ":" + model_standard_price.standard_values.Split(',')[i]; } } } } Model.unit model_unit = bll_unit.GetModel(Convert.ToDecimal(dr["unit_id"])); if (model_unit != null) { str_unit += "单位:" + model_unit.title + (string.IsNullOrEmpty(model_unit.content) ? "" : model_unit.content); } DataRow new_dr = dt_meal_good.NewRow(); new_dr["meal_id"] = dr["meal_id"]; new_dr["title"] = Utils.CutString(modelt.title, 10); new_dr["good_standard_price"] = dr["good_id"].ToString() + dr["standard_price_id"].ToString(); new_dr["all_title"] = modelt.title + " " + str_standard_price + str_unit; new_dr["img_url"] = modelt.img_url; new_dr["price"] = dr["sell_price"]; dt_meal_good.Rows.Add(new_dr); } } dt_meal_good.TableName = "dt_meal_good"; ds.Tables.Add(dt_meal_good.Copy()); } } //推荐 DataTable dt_red = bll_meal.GetMealByGood(goods_id, "tuijiandapei").Tables[0]; dt_red.TableName = "dt_red"; if (dt_red != null && dt_red.Rows.Count > 0) { DataTable old_dt_red_good = bll_meal_good.GetList("meal_id=" + dt_red.Rows[0]["id"].ToString()).Tables[0]; DataTable dt_red_good = new DataTable(); dt_red_good.Columns.Add("meal_id"); dt_red_good.Columns.Add("good_standard_price"); dt_red_good.Columns.Add("title"); dt_red_good.Columns.Add("all_title"); dt_red_good.Columns.Add("img_url"); dt_red_good.Columns.Add("price"); string str_red_good_ids = ","; if (old_dt_red_good != null && old_dt_red_good.Rows.Count > 0) { foreach (DataRow dr in old_dt_red_good.Rows) { if (str_red_good_ids.IndexOf("," + dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ",") > -1) { continue; } str_red_good_ids += dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ","; Model.article modelt = bll.GetModel(Convert.ToInt32(dr["good_id"])); if (modelt != null) { Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(dr["standard_price_id"])); string str_standard_price = ""; string str_unit = ""; if (model_standard_price != null) { for (int i = 0; i < model_standard_price.standards.Split(',').Length; i++) { if (!string.IsNullOrEmpty(model_standard_price.standards.Split(',')[i])) { str_standard_price += model_standard_price.standards.Split(',')[i]; if (i < model_standard_price.standard_values.Split(',').Length) { str_standard_price += ":" + model_standard_price.standard_values.Split(',')[i]; } } } } Model.unit model_unit = bll_unit.GetModel(Convert.ToDecimal(dr["unit_id"])); if (model_unit != null) { str_unit += "单位:" + model_unit.title + (string.IsNullOrEmpty(model_unit.content) ? "" : model_unit.content); } DataRow new_dr = dt_red_good.NewRow(); new_dr["meal_id"] = dr["meal_id"]; new_dr["title"] = Utils.CutString(modelt.title, 10); new_dr["good_standard_price"] = dr["good_id"].ToString() + dr["standard_price_id"].ToString(); new_dr["all_title"] = modelt.title + " " + str_standard_price + str_unit; new_dr["img_url"] = modelt.img_url; new_dr["price"] = dr["sell_price"]; dt_red_good.Rows.Add(new_dr); } } dt_red_good.TableName = "dt_red_good"; ds.Tables.Add(dt_red_good.Copy()); } } context.Response.Write(myJson.getJson(ds)); }