Ejemplo n.º 1
0
        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];
            }
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
0
        private bool DoAdd()
        {
            bool result = false;
            string check_good = DTRequest.GetFormString("ck_good");
            if (string.IsNullOrEmpty(check_good))
            {
                JscriptMsg("请选择商品!", "", "Error");
                return false;
            }

            BLL.meal bll = new BLL.meal();
            Model.meal model = new Model.meal();

            model.title = txt_title.Text.Trim();
            model.category_id = Convert.ToInt32(ddlCategoryId.SelectedValue);
            model.img_url = txtImgUrl.Text.Trim();
            model.add_time = DateTime.Now;
            model.index_url = txtIndexUrl.Text.Trim();
            model.sort_id = int.Parse(txtSortId.Text.ToString());

            BLL.standard_price bll_standard_price = new BLL.standard_price();

            int _meal_id = bll.Add(model);

            if (_meal_id > 0)
            {
                BLL.meal_good bll_meal_good = new BLL.meal_good();

                string[] arr_str = check_good.Split(',');
                BLL.standard_group_price bll_standard_group_price = new BLL.standard_group_price();

                for (int i = 0; i < arr_str.Length; i++)
                {
                    Model.article model_good = new Model.article();
                    model_good = new BLL.article().GetModel(Convert.ToInt32(arr_str[i].Split('_')[0]));
                    if (model_good != null)
                    {
                        if (!string.IsNullOrEmpty(arr_str[i]))
                        {
                            DataTable dt_standard_group_price = bll_standard_group_price.GetList("good_id=" + arr_str[i].Split('_')[0] + " and standard_price_id=" + arr_str[i].Split('_')[1]).Tables[0];
                            if (dt_standard_group_price != null && dt_standard_group_price.Rows.Count > 0)
                            {
                                //有会员规格价格   商品ID_规格价格ID_单位ID_数量  默认sell_price   规格价格standard_price(有规格未登入)  组别价格standard_group_price(不管有没有规格已登入)
                                foreach (DataRow dr_group_price in dt_standard_group_price.Rows)
                                {
                                    Model.meal_good model_meal_good = new Model.meal_good();
                                    model_meal_good.good_id = Convert.ToInt32(arr_str[i].Split('_')[0]);
                                    model_meal_good.group_id = Convert.ToInt32(dr_group_price["group_id"]);
                                    model_meal_good.meal_id = _meal_id;
                                    model_meal_good.standard_price_id = Convert.ToDecimal(arr_str[i].Split('_')[1]);
                                    model_meal_good.unit_id = Convert.ToInt32(arr_str[i].Split('_')[2]);
                                    model_meal_good.quantity = Convert.ToInt32(arr_str[i].Split('_')[3]);
                                    model_meal_good.sell_price = Convert.ToDecimal(model_good.fields["sell_price"]);
                                    model_meal_good.standard_price = Convert.ToDecimal(model_good.fields["sell_price"]);

                                    Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(arr_str[i].Split('_')[1]));
                                    if (model_standard_price != null)
                                    {
                                        //有库存价格
                                        model_meal_good.standard_price = model_standard_price.sell_price;
                                        model_meal_good.action_price = model_standard_price.action_price;
                                    }
                                    model_meal_good.standard_group_price = Convert.ToDecimal(dr_group_price["group_price"]);
                                    model_meal_good.add_time = DateTime.Now;

                                    bll_meal_good.Add(model_meal_good);
                                }

                            }
                            else
                            {
                                if (model_good.group_price.Count > 0)
                                {
                                    foreach (Model.user_group_price model_user_group in model_good.group_price)
                                    {
                                        Model.meal_good model_meal_good = new Model.meal_good();
                                        model_meal_good.good_id = Convert.ToInt32(arr_str[i].Split('_')[0]);
                                        model_meal_good.group_id = model_user_group.group_id;
                                        model_meal_good.meal_id = _meal_id;
                                        model_meal_good.standard_price_id = Convert.ToDecimal(arr_str[i].Split('_')[1]);
                                        model_meal_good.unit_id = Convert.ToInt32(arr_str[i].Split('_')[2]);
                                        model_meal_good.quantity = Convert.ToInt32(arr_str[i].Split('_')[3]);
                                        model_meal_good.sell_price = Convert.ToDecimal(model_good.fields["sell_price"]);
                                        model_meal_good.standard_price = Convert.ToDecimal(model_good.fields["sell_price"]);

                                        Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(arr_str[i].Split('_')[1]));
                                        if (model_standard_price != null)
                                        {
                                            //有库存价格
                                            model_meal_good.standard_price = model_standard_price.sell_price;
                                            model_meal_good.action_price = model_standard_price.action_price;
                                        }
                                        model_meal_good.standard_group_price = Convert.ToDecimal(model_user_group.price);
                                        model_meal_good.add_time = DateTime.Now;
                                        bll_meal_good.Add(model_meal_good);
                                    }

                                }
                                else
                                {
                                    Model.meal_good model_meal_good = new Model.meal_good();
                                    model_meal_good.good_id = Convert.ToInt32(arr_str[i].Split('_')[0]);
                                    model_meal_good.group_id = 0;
                                    model_meal_good.meal_id = _meal_id;
                                    model_meal_good.standard_price_id = Convert.ToDecimal(arr_str[i].Split('_')[1]);
                                    model_meal_good.unit_id = Convert.ToInt32(arr_str[i].Split('_')[2]);
                                    model_meal_good.quantity = Convert.ToInt32(arr_str[i].Split('_')[3]);
                                    model_meal_good.sell_price = Convert.ToDecimal(model_good.fields["sell_price"]);
                                    model_meal_good.standard_price = Convert.ToDecimal(model_good.fields["sell_price"]);

                                    Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(arr_str[i].Split('_')[1]));
                                    if (model_standard_price != null)
                                    {
                                        //有库存价格
                                        model_meal_good.standard_price = model_standard_price.sell_price;
                                        model_meal_good.action_price = model_standard_price.action_price;
                                    }
                                    model_meal_good.standard_group_price = Convert.ToDecimal(model_good.fields["sell_price"]);
                                    model_meal_good.add_time = DateTime.Now;
                                    bll_meal_good.Add(model_meal_good);
                                }
                            }

                        }

                    }
                }

                //AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加用户:" + model.user_name); //记录日志
                result = true;
            }
            return result;
        }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
0
        /// <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];
            }
        }
Ejemplo n.º 6
0
        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;
                }
            }
        }
Ejemplo n.º 7
0
        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));
        }
Ejemplo n.º 8
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;
            }
        }
Ejemplo n.º 9
0
        private bool DoEdit(int _id)
        {
            string check_good = DTRequest.GetFormString("ck_good");

            if (string.IsNullOrEmpty(check_good))
            {
                JscriptMsg("请选择商品!", "", "Error");
                return(false);
            }

            bool result = false;

            BLL.meal   bll   = new BLL.meal();
            Model.meal model = bll.GetModel(_id);
            model.title       = txt_title.Text.Trim();
            model.img_url     = txtImgUrl.Text.Trim();
            model.category_id = Convert.ToInt32(ddlCategoryId.SelectedValue);
            model.index_url   = txtIndexUrl.Text.Trim();
            model.sort_id     = int.Parse(txtSortId.Text.ToString());

            if (bll.Update(model))
            {
                BLL.standard_price bll_standard_price = new BLL.standard_price();

                BLL.meal_good bll_meal_good = new BLL.meal_good();

                bll_meal_good.Delete(_id);

                string[] arr_str = check_good.Split(',');
                BLL.standard_group_price bll_standard_group_price = new BLL.standard_group_price();

                for (int i = 0; i < arr_str.Length; i++)
                {
                    Model.article model_good = new Model.article();
                    model_good = new BLL.article().GetModel(Convert.ToInt32(arr_str[i].Split('_')[0]));
                    if (model_good != null)
                    {
                        if (!string.IsNullOrEmpty(arr_str[i]))
                        {
                            DataTable dt_standard_group_price = bll_standard_group_price.GetList("good_id=" + arr_str[i].Split('_')[0] + " and standard_price_id=" + arr_str[i].Split('_')[1]).Tables[0];
                            if (dt_standard_group_price != null && dt_standard_group_price.Rows.Count > 0)
                            {
                                //有会员规格价格
                                foreach (DataRow dr_group_price in dt_standard_group_price.Rows)
                                {
                                    Model.meal_good model_meal_good = new Model.meal_good();
                                    model_meal_good.good_id           = Convert.ToInt32(arr_str[i].Split('_')[0]);
                                    model_meal_good.group_id          = Convert.ToInt32(dr_group_price["group_id"]);
                                    model_meal_good.meal_id           = _id;
                                    model_meal_good.standard_price_id = Convert.ToDecimal(arr_str[i].Split('_')[1]);
                                    model_meal_good.unit_id           = Convert.ToInt32(arr_str[i].Split('_')[2]);
                                    model_meal_good.quantity          = Convert.ToInt32(arr_str[i].Split('_')[3]);
                                    model_meal_good.sell_price        = Convert.ToDecimal(model_good.fields["sell_price"]);
                                    model_meal_good.standard_price    = Convert.ToDecimal(model_good.fields["sell_price"]);

                                    Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(arr_str[i].Split('_')[1]));
                                    if (model_standard_price != null)
                                    {
                                        //有库存价格
                                        model_meal_good.standard_price = model_standard_price.sell_price;
                                        model_meal_good.action_price   = model_standard_price.action_price;
                                    }
                                    model_meal_good.standard_group_price = Convert.ToDecimal(dr_group_price["group_price"]);
                                    model_meal_good.add_time             = DateTime.Now;

                                    bll_meal_good.Add(model_meal_good);
                                }
                            }
                            else
                            {
                                if (model_good.group_price.Count > 0)
                                {
                                    foreach (Model.user_group_price model_user_group in model_good.group_price)
                                    {
                                        Model.meal_good model_meal_good = new Model.meal_good();
                                        model_meal_good.good_id           = Convert.ToInt32(arr_str[i].Split('_')[0]);
                                        model_meal_good.group_id          = model_user_group.group_id;
                                        model_meal_good.meal_id           = _id;
                                        model_meal_good.standard_price_id = Convert.ToDecimal(arr_str[i].Split('_')[1]);
                                        model_meal_good.unit_id           = Convert.ToInt32(arr_str[i].Split('_')[2]);
                                        model_meal_good.quantity          = Convert.ToInt32(arr_str[i].Split('_')[3]);
                                        model_meal_good.sell_price        = Convert.ToDecimal(model_good.fields["sell_price"]);
                                        model_meal_good.standard_price    = Convert.ToDecimal(model_good.fields["sell_price"]);

                                        Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(arr_str[i].Split('_')[1]));
                                        if (model_standard_price != null)
                                        {
                                            //有库存价格
                                            model_meal_good.standard_price = model_standard_price.sell_price;
                                            model_meal_good.action_price   = model_standard_price.action_price;
                                        }
                                        model_meal_good.standard_group_price = Convert.ToDecimal(model_user_group.price);
                                        model_meal_good.add_time             = DateTime.Now;
                                        bll_meal_good.Add(model_meal_good);
                                    }
                                }
                                else
                                {
                                    Model.meal_good model_meal_good = new Model.meal_good();
                                    model_meal_good.good_id           = Convert.ToInt32(arr_str[i].Split('_')[0]);
                                    model_meal_good.group_id          = 0;
                                    model_meal_good.meal_id           = _id;
                                    model_meal_good.standard_price_id = Convert.ToDecimal(arr_str[i].Split('_')[1]);
                                    model_meal_good.unit_id           = Convert.ToInt32(arr_str[i].Split('_')[2]);
                                    model_meal_good.quantity          = Convert.ToInt32(arr_str[i].Split('_')[3]);
                                    model_meal_good.sell_price        = Convert.ToDecimal(model_good.fields["sell_price"]);
                                    model_meal_good.standard_price    = Convert.ToDecimal(model_good.fields["sell_price"]);

                                    Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(arr_str[i].Split('_')[1]));
                                    if (model_standard_price != null)
                                    {
                                        //有库存价格
                                        model_meal_good.standard_price = model_standard_price.sell_price;
                                        model_meal_good.action_price   = model_standard_price.action_price;
                                    }
                                    model_meal_good.standard_group_price = Convert.ToDecimal(model_good.fields["sell_price"]);
                                    model_meal_good.add_time             = DateTime.Now;
                                    bll_meal_good.Add(model_meal_good);
                                }
                            }
                        }
                    }
                }
                //AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改用户信息:" + model.user_name); //记录日志
                result = true;
            }
            return(result);
        }
Ejemplo n.º 10
0
        private void into_meal(HttpContext context)
        {
            int good_id = DTRequest.GetQueryInt("good_id");
            decimal standard_value_price_id = DTRequest.GetQueryInt("standard_value_price_id");
            int unit_id = DTRequest.GetQueryInt("unit_id");
            int quantity = DTRequest.GetQueryInt("quantity");
            BLL.article bll_good = new BLL.article();
            Model.article model_good = bll_good.GetModel(good_id);
            if (model_good == null)
            {
                context.Response.Write("Erorr");
                return;
            }
            string str_quantity = ",数量:" + quantity;
            string unit = "";
            string standard = "";
            BLL.unit bll_unit = new BLL.unit();
            DataTable dt_unit = bll_unit.GetList("id=" + unit_id).Tables[0];
            if (dt_unit != null && dt_unit.Rows.Count > 0)
            {
                unit = ",单位:" + dt_unit.Rows[0]["title"].ToString();
                if (!string.IsNullOrEmpty(dt_unit.Rows[0]["content"].ToString()))
                {
                    unit += "(" + dt_unit.Rows[0]["content"].ToString() + ")";
                }
            }
            string str_ret = "";

            BLL.standard_price bll_standard_price = new BLL.standard_price();
            Model.standard_price model_standard_price = bll_standard_price.GetModel(standard_value_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_ret = "<span onclick='ck_goods(this)'>" + model_good.title + str_quantity + unit + " " + standard + "<input type='checkbox' name='ck_good'  style='display:none;' value='" + good_id + "_" + standard_value_price_id + "_" + unit_id + "_" + quantity + "' checked='checked'/></span>";
            context.Response.Write(str_ret);
            return;
        }