Beispiel #1
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;
            }
        }
Beispiel #2
0
        private void ShowInfo(int _id)
        {
            BLL.article bll = new BLL.article();
            Model.article model = bll.GetModel(_id);

            ddlCategoryId.SelectedValue = model.category_id.ToString();
            txtCallIndex.Text = model.call_index;
            txtTitle.Text = model.title;
            txtLinkUrl.Text = model.link_url;
            //不是相册图片就绑定
            string filename = model.img_url.Substring(model.img_url.LastIndexOf("/") + 1);
            if (!filename.StartsWith("thumb_"))
            {
                txtImgUrl.Text = model.img_url;
            }
            txtSeoTitle.Text = model.seo_title;
            txtSeoKeywords.Text = model.seo_keywords;
            txtSeoDescription.Text = model.seo_description;
            txtZhaiyao.Text = model.zhaiyao;
            txtContent.Value = model.content;
            txtSortId.Text = model.sort_id.ToString();
            txtClick.Text = model.click.ToString();
            rblStatus.SelectedValue = model.status.ToString();
            txtAddTime.Text = model.add_time.ToString("yyyy-MM-dd HH:mm:ss");
            if (model.is_msg == 1)
            {
                cblItem.Items[0].Selected = true;
            }
            if (model.is_top == 1)
            {
                cblItem.Items[1].Selected = true;
            }
            if (model.is_red == 1)
            {
                cblItem.Items[2].Selected = true;
            }
            if (model.is_hot == 1)
            {
                cblItem.Items[3].Selected = true;
            }
            if (model.is_slide == 1)
            {
                cblItem.Items[4].Selected = true;
            }

            if (model.is_put == 1)
            {
                isPut.Items[0].Selected = false;
                isPut.Items[1].Selected = true;
            }
            else
            {
                isPut.Items[1].Selected = false;
                isPut.Items[0].Selected = true;
            }
            //扩展字段赋值
            List<Model.article_attribute_field> ls1 = new BLL.article_attribute_field().GetModelList(this.channel_id, "");
            foreach (Model.article_attribute_field modelt1 in ls1)
            {
                switch (modelt1.control_type)
                {
                    case "single-text": //单行文本
                        TextBox txtControl = FindControl("field_control_" + modelt1.name) as TextBox;
                        if (txtControl != null && model.fields.ContainsKey(modelt1.name))
                        {
                            if (modelt1.is_password == 1)
                            {
                                txtControl.Attributes.Add("value", model.fields[modelt1.name]);
                            }
                            else
                            {
                                txtControl.Text = model.fields[modelt1.name];
                            }
                        }
                        break;
                    case "multi-text": //多行文本
                        goto case "single-text";
                    case "editor": //编辑器
                        HtmlTextArea txtAreaControl = FindControl("field_control_" + modelt1.name) as HtmlTextArea;
                        if (txtAreaControl != null && model.fields.ContainsKey(modelt1.name))
                        {
                            txtAreaControl.Value = model.fields[modelt1.name];
                        }
                        break;
                    case "images": //图片上传
                        goto case "single-text";
                    case "number": //数字
                        goto case "single-text";
                    case "checkbox": //复选框
                        CheckBox cbControl = FindControl("field_control_" + modelt1.name) as CheckBox;
                        if (cbControl != null && model.fields.ContainsKey(modelt1.name))
                        {
                            if (model.fields[modelt1.name] == "1")
                            {
                                cbControl.Checked = true;
                            }
                            else
                            {
                                cbControl.Checked = false;
                            }
                        }
                        break;
                    case "multi-radio": //多项单选
                        RadioButtonList rblControl = FindControl("field_control_" + modelt1.name) as RadioButtonList;
                        if (rblControl != null && model.fields.ContainsKey(modelt1.name))
                        {
                            rblControl.SelectedValue = model.fields[modelt1.name];
                        }
                        break;
                    case "multi-checkbox": //多项多选
                        CheckBoxList cblControl = FindControl("field_control_" + modelt1.name) as CheckBoxList;
                        if (cblControl != null && model.fields.ContainsKey(modelt1.name))
                        {
                            string[] valArr = model.fields[modelt1.name].Split(',');
                            for (int i = 0; i < cblControl.Items.Count; i++)
                            {
                                cblControl.Items[i].Selected = false; //先取消默认的选中
                                foreach (string str in valArr)
                                {
                                    if (cblControl.Items[i].Value == str)
                                    {
                                        cblControl.Items[i].Selected = true;
                                    }
                                }
                            }
                        }
                        break;
                }
            }
            //绑定图片相册
            if (filename.StartsWith("thumb_"))
            {
                hidFocusPhoto.Value = model.img_url; //封面图片
            }
            rptAlbumList.DataSource = model.albums;
            rptAlbumList.DataBind();
            //绑定内容附件
            rptAttachList.DataSource = model.attach;
            rptAttachList.DataBind();
            //赋值用户组价格
            if (model.group_price != null)
            {
                for (int i = 0; i < this.rptPrice.Items.Count; i++)
                {
                    int hideId = Convert.ToInt32(((HiddenField)this.rptPrice.Items[i].FindControl("hideGroupId")).Value);
                    foreach (Model.user_group_price modelt in model.group_price)
                    {
                        if (hideId == modelt.group_id)
                        {
                            ((HiddenField)this.rptPrice.Items[i].FindControl("hidePriceId")).Value = modelt.id.ToString();
                            ((TextBox)this.rptPrice.Items[i].FindControl("txtGroupPrice")).Text = modelt.price.ToString();
                        }
                    }
                }
            }

            #region  商品相关
            if (channel_name == "goods")
            {
                //规格价格
                BLL.standard bll_standard = new BLL.standard();
                BLL.standard_price bll_price = new BLL.standard_price();
                Model.article_category model_category = new BLL.article_category().GetModel(model.category_id);
                string str1 = "";
                if (model_category != null)
                {
                    DataTable dt = bll_standard.GetList(0, "'" + model_category.class_list + "' like '%,'+convert(varchar(50),category_id)+',%'", "id asc").Tables[0];

                    if (dt != null)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            string is_checked = "";
                            DataTable dt_price1 = bll_price.GetList(0, "good_id=" + _id, "id asc").Tables[0];
                            if (dt_price1 != null && dt_price1.Rows.Count > 0)
                            {
                                foreach (DataRow dr1 in dt_price1.Rows)
                                {
                                    string[] standard_ids = dr1["standard_ids"].ToString().Trim().Split(',');
                                    foreach (string str in standard_ids)
                                    {
                                        if (!string.IsNullOrEmpty(str))
                                        {
                                            if (Convert.ToInt32(dr["id"]) == Convert.ToInt32(str))
                                            {
                                                is_checked = " checked=\"checked\" ";
                                            }
                                        }
                                    }
                                }

                            }

                            str1 += "<label><input type=\"checkbox\" value=\"" + dr["id"].ToString() + "\" name=\"ck_standard\" " + is_checked + " onclick=\"change_standard('ck_standard')\" />" + dr["title"].ToString() + "</label>&nbsp;&nbsp;&nbsp;";

                        }
                        dd_standard_title.InnerHtml = str1;
                    }
                }

                DataTable dt_price = bll_price.GetList(0, "good_id=" + _id, "id asc").Tables[0];
                if (dt_price != null && dt_price.Rows.Count > 0)
                {
                    //规格
                    //string str_standard = "";
                    //string[] str_standardid_arr = dt_price.Rows[0]["standard_ids"].ToString().Split(',');
                    string[] str_standardtitle_arr = dt_price.Rows[0]["standards"].ToString().Split(',');
                    //for (int i = 0; i < str_standardid_arr.Length; i++)
                    //{
                    //    str_standard += "<label><input type=\"checkbox\" checked=\"checked\" value=\"" + str_standardid_arr[i].ToString() + "\" name=\"ck_standard\" onclick=\"change_standard('ck_standard')\" />" + str_standardtitle_arr[i].ToString() + "</label>&nbsp;&nbsp;&nbsp;";
                    //}
                    //dd_standard_title.InnerHtml = str_standard;

                    //规格值  规格价格
                    //头部

                    //会员组
                    BLL.user_groups bll_groups = new BLL.user_groups();
                    DataTable dt_groups = bll_groups.GetList(0, "", "grade asc,id desc").Tables[0];

                    string str_groups_header = "";

                    if (dt_groups != null && dt_groups.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt_groups.Rows.Count; i++)
                        {
                            str_groups_header += "<td style='font-weight:bold;color:#33B5E5;padding-right:10px;'>" + dt_groups.Rows[i]["title"].ToString() + "</td>";
                        }

                    }
                    string rest_header = "";
                    rest_header += "<tr><td style='font-weight:bold;color:#33B5E5;text-align:left;padding-right:10px;'>商品编号</td>";
                    for (int i = 0; i < str_standardtitle_arr.Length; i++)
                    {
                        rest_header += "<td  style='font-weight:bold;color:#33B5E5; padding-right:10px;'>" + str_standardtitle_arr[i] + "</td>";
                    }
                    rest_header += "<td style='font-weight:bold;color:#33B5E5;text-align:left;padding-right:10px;'>库存</td>"
                        + "<td style='font-weight:bold;color:#33B5E5;text-align:left;padding-right:10px;'>市场价</td>"
                    + "<td style='font-weight:bold;color:#33B5E5;text-align:left;padding-right:10px;'>销售价</td>"
                    + "<td style='font-weight:bold;color:#33B5E5;text-align:left;padding-right:10px;'>活动价</td>"
                    + str_groups_header + "</tr>";

                    string rest_body = "";

                    foreach (DataRow dr in dt_price.Rows)
                    {
                        string[] str_arr_value = dr["standard_values"].ToString().Split(',');
                        rest_body += "<tr><td style='padding-right: 20px;'><input style='border: 1px solid #d8d8d8;margin: 10px 18px 12px 0;width: 100px;' type='text' class='input normal small' name='good_no_" + dr["standard_value_ids"].ToString().Replace(',', '_') + "' value='" + dr["good_no"].ToString() + "'/></td>";
                        foreach (string str in str_arr_value)
                        {
                            rest_body += "<td style='padding-right: 20px;'>" + str + "</td>";
                        }
                        rest_body += "<td style='padding-right: 20px;'><input type='checkbox' value='" + dr["standard_value_ids"].ToString().Replace(',', '_') + "'  name='ck_standard_value' checked='checked' style='display:none;'/>";
                        rest_body += "<input style='border: 1px solid #d8d8d8;margin: 10px 18px 12px 0;' type='text' class='input normal small' name='stock_quantity_" + dr["standard_value_ids"].ToString().Replace(',', '_') + "' value='" + dr["stock_quantity"].ToString() + "'/></td>";
                        rest_body += "<td style='padding-right: 20px;'><input style='border: 1px solid #d8d8d8;margin: 10px 18px 12px 0;' type='text' class='input normal small' name='market_price_" + dr["standard_value_ids"].ToString().Replace(',', '_') + "' value='" + dr["market_price"].ToString() + "'/></td>";
                        rest_body += "<td style='padding-right: 20px;'><input style='border: 1px solid #d8d8d8;margin: 10px 18px 12px 0;' type='text' class='input normal small' name='sell_price_" + dr["standard_value_ids"].ToString().Replace(',', '_') + "' value='" + dr["sell_price"].ToString() + "'/></td>";
                        rest_body += "<td style='padding-right: 20px;'><input style='border: 1px solid #d8d8d8;margin: 10px 18px 12px 0;' type='text' class='input normal small' name='action_price_" + dr["standard_value_ids"].ToString().Replace(',', '_') + "' value='" + dr["action_price"].ToString() + "'/></td>";
                        for (int i = 0; i < dt_groups.Rows.Count; i++)
                        {
                            BLL.standard_group_price bll_standard_group_price = new BLL.standard_group_price();
                            Model.standard_group_price model_standard_group_price = bll_standard_group_price.GetModel(_id, Convert.ToInt32(dt_groups.Rows[i]["id"]), Convert.ToDecimal(dr["id"]));
                            if (model_standard_group_price != null)
                            {
                                rest_body += "<td style='padding-right: 20px;'><input style='border: 1px solid #d8d8d8;margin: 10px 18px 12px 0;' type='text' class='input normal small' name='user_price_" + dt_groups.Rows[i]["id"].ToString() + "_" + dr["standard_value_ids"].ToString().Replace(',', '_') + "' value='" + model_standard_group_price.group_price + "'/></td>";
                            }
                            else
                            {
                                foreach (Model.user_group_price modelt in model.group_price)
                                {
                                    if (Convert.ToInt32(dt_groups.Rows[i]["id"]) == modelt.group_id)
                                    {
                                        rest_body += "<td style='padding-right: 20px;'><input style='border: 1px solid #d8d8d8;margin: 10px 18px 12px 0;' type='text' class='input normal small' name='user_price_" + dt_groups.Rows[i]["id"].ToString() + "_" + dr["standard_value_ids"].ToString().Replace(',', '_') + "' value='" + modelt.price + "'/></td>";
                                    }
                                }

                            }
                        }

                        rest_body += "</tr>";
                    }

                    dd_standard_value.InnerHtml = "<table>" + rest_header + rest_body + "</table>";

                }

                //单位
                BLL.unit bll_unit = new BLL.unit();
                DataTable dt_unit = bll_unit.GetList("good_id=" + _id).Tables[0];
                string str_unit = "";
                if (dt_unit != null && dt_unit.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt_unit.Rows)
                    {
                        string unit = dr["title"].ToString() + "_" + Convert.ToInt32(dr["quantity"]) + "_" + Convert.ToDecimal(dr["rate"]) + "_" + dr["content"].ToString();
                        str_unit += "<tr>";
                        str_unit += "<td style='padding-right: 20px;'>" + dr["title"].ToString() + "<input type=\"checkbox\" name=\"ck_unit\" value=\"" + unit + "\" checked=\"checked\" style=\"display:none;\">" + "</td>";
                        str_unit += "<td style='padding-right: 20px;'>" + Convert.ToInt32(dr["quantity"]) + "</td>";
                        str_unit += "<td style='padding-right: 20px;'>" + Convert.ToDecimal(dr["rate"]) + "</td>";
                        str_unit += "<td style='padding-right: 20px;'>" + dr["content"].ToString() + "</td>";
                        str_unit += "<td style='padding-right: 20px;'><a href=\"javascript:;\" onclick=\"del_unit(this)\">删除</a></td>";
                        str_unit += "</tr>";
                    }
                }
                tb_unit_value.InnerHtml = str_unit;

                //别名
                BLL.alias bll_alias = new BLL.alias();
                DataTable dt_alias = bll_alias.GetList(" category_id in(select id from dt_article_category where (select class_list from dt_article_category where id=" + model.category_id + ") like '%,'+CONVERT(varchar(20),id)+',%')").Tables[0];
                if (dt_alias != null && dt_alias.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt_alias.Rows)
                    {
                        ck_alias.Items.Add(new ListItem(dr["title"].ToString(), dr["id"].ToString()));
                    }
                }

                BLL.alias_good bll_alias_good = new BLL.alias_good();
                for (int i = 0; i < ck_alias.Items.Count; i++)
                {
                    DataTable dt_have = bll_alias_good.GetList("alias_id=" + ck_alias.Items[i].Value + " and good_id=" + _id).Tables[0];
                    if (dt_have != null && dt_have.Rows.Count > 0)
                    {
                        ck_alias.Items[i].Selected = true;
                    }
                }

                //属性
                BLL.property bll_property = new BLL.property();
                DataTable dt_property = bll_property.GetList(" category_id in(select id from dt_article_category where (select class_list from dt_article_category where id=" + model.category_id + ") like '%,'+CONVERT(varchar(20),id)+',%')").Tables[0];
                string str_result = "";
                foreach (DataRow dr in dt_property.Rows)
                {
                    str_result += "<dl>";
                    str_result += "<dt>" + dr["title"].ToString() + ":</dt>";
                    BLL.property_value bll_value = new BLL.property_value();
                    DataTable dt_property_value = bll_value.GetList("property_id=" + dr["id"].ToString()).Tables[0];
                    str_result += "<dd>";
                    if (dt_property_value != null && dt_property_value.Rows.Count > 0)
                    {
                        foreach (DataRow dr1 in dt_property_value.Rows)
                        {
                            BLL.property_good bll_property_good = new BLL.property_good();
                            DataTable dt_property_good = bll_property_good.GetList("good_id=" + model.id + " and property_value_id=" + dr1["id"].ToString()).Tables[0];
                            if (dt_property_good != null && dt_property_good.Rows.Count > 0)
                            {
                                str_result += "<label><input type=\"checkbox\" name=\"ck_property_value\" checked=\"checked\" value=\"" + dr1["id"].ToString() + "\" />" + dr1["value"].ToString() + "</label>&nbsp;&nbsp;&nbsp;";
                            }
                            else
                            {
                                str_result += "<label><input type=\"checkbox\" name=\"ck_property_value\" value=\"" + dr1["id"].ToString() + "\" />" + dr1["value"].ToString() + "</label>&nbsp;&nbsp;&nbsp;";
                            }
                        }

                    }
                    str_result += "</dd>";
                    str_result += "</dl>";
                }

                div_property.InnerHtml = str_result;

                //标签
                BLL.tag bll_tag = new BLL.tag();
                DataTable dt_tag = bll_tag.GetList(" category_id in(select id from dt_article_category where (select class_list from dt_article_category where id=" + model.category_id + ") like '%,'+CONVERT(varchar(20),id)+',%')").Tables[0];
                if (dt_tag != null && dt_tag.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt_tag.Rows)
                    {
                        ck_tag.Items.Add(new ListItem(dr["title"].ToString(), dr["id"].ToString()));
                    }
                }

                BLL.tag_good bll_tag_good = new BLL.tag_good();
                for (int i = 0; i < ck_tag.Items.Count; i++)
                {
                    DataTable dt_have = bll_tag_good.GetList("tag_id=" + ck_tag.Items[i].Value + " and good_id=" + _id).Tables[0];
                    if (dt_have != null && dt_have.Rows.Count > 0)
                    {
                        ck_tag.Items[i].Selected = true;
                    }
                }
            }
            #endregion
        }
Beispiel #3
0
        private bool DoEdit(int _id)
        {
            bool result = false;
            BLL.article bll = new BLL.article();
            Model.article model = bll.GetModel(_id);

            decimal sell_price = 0;
            decimal standard_price = 0;
            decimal standard_group_price = 0;
            decimal action_price = 0;

            model.channel_id = this.channel_id;
            model.category_id = Utils.StrToInt(ddlCategoryId.SelectedValue, 0);
            model.call_index = txtCallIndex.Text.Trim();
            model.title = txtTitle.Text.Trim();
            model.link_url = txtLinkUrl.Text.Trim();
            model.img_url = txtImgUrl.Text;
            model.seo_title = txtSeoTitle.Text.Trim();
            model.seo_keywords = txtSeoKeywords.Text.Trim();
            model.seo_description = txtSeoDescription.Text.Trim();
            //内容摘要提取内容前255个字符
            if (string.IsNullOrEmpty(txtZhaiyao.Text.Trim()))
            {
                model.zhaiyao = Utils.DropHTML(txtContent.Value, 255);
            }
            else
            {
                model.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 255);
            }
            model.content = txtContent.Value;
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);
            model.click = int.Parse(txtClick.Text.Trim());
            model.status = Utils.StrToInt(rblStatus.SelectedValue, 0);
            model.is_msg = 0;
            model.is_top = 0;
            model.is_red = 0;
            model.is_hot = 0;
            model.is_slide = 0;
            model.is_put = 1;
            if (isPut.Items[0].Selected)
            {
                model.is_put = 0;
            }
            if (cblItem.Items[0].Selected == true)
            {
                model.is_msg = 1;
            }
            if (cblItem.Items[1].Selected == true)
            {
                model.is_top = 1;
            }
            if (cblItem.Items[2].Selected == true)
            {
                model.is_red = 1;
            }
            if (cblItem.Items[3].Selected == true)
            {
                model.is_hot = 1;
            }
            if (cblItem.Items[4].Selected == true)
            {
                model.is_slide = 1;
            }
            model.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim());
            model.update_time = DateTime.Now;
            model.fields = SetFieldValues(this.channel_id); //扩展字段赋值
            sell_price = Convert.ToDecimal(model.fields["sell_price"]);

            #region 保存相册====================
            //检查是否有自定义图片
            if (txtImgUrl.Text.Trim() == "")
            {
                model.img_url = hidFocusPhoto.Value;
            }
            if (model.albums != null)
            {
                model.albums.Clear();
            }
            string[] albumArr = Request.Form.GetValues("hid_photo_name");
            string[] remarkArr = Request.Form.GetValues("hid_photo_remark");
            if (albumArr != null)
            {
                List<Model.article_albums> ls = new List<Model.article_albums>();
                for (int i = 0; i < albumArr.Length; i++)
                {
                    string[] imgArr = albumArr[i].Split('|');
                    int img_id = Utils.StrToInt(imgArr[0], 0);
                    if (imgArr.Length == 3)
                    {
                        if (!string.IsNullOrEmpty(remarkArr[i]))
                        {
                            ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2], remark = remarkArr[i] });
                        }
                        else
                        {
                            ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2] });
                        }
                    }
                }
                model.albums = ls;
            }
            #endregion

            #region 保存附件====================
            if (model.attach != null)
            {
                model.attach.Clear();
            }
            string[] attachIdArr = Request.Form.GetValues("hid_attach_id");
            string[] attachFileNameArr = Request.Form.GetValues("hid_attach_filename");
            string[] attachFilePathArr = Request.Form.GetValues("hid_attach_filepath");
            string[] attachFileSizeArr = Request.Form.GetValues("hid_attach_filesize");
            string[] attachPointArr = Request.Form.GetValues("txt_attach_point");
            if (attachIdArr != null && attachFileNameArr != null && attachFilePathArr != null && attachFileSizeArr != null && attachPointArr != null
                && attachIdArr.Length > 0 && attachFileNameArr.Length > 0 && attachFilePathArr.Length > 0 && attachFileSizeArr.Length > 0 && attachPointArr.Length > 0)
            {
                List<Model.article_attach> ls = new List<Model.article_attach>();
                for (int i = 0; i < attachFileNameArr.Length; i++)
                {
                    int attachId = Utils.StrToInt(attachIdArr[i], 0);
                    int fileSize = Utils.StrToInt(attachFileSizeArr[i], 0);
                    string fileExt = Utils.GetFileExt(attachFilePathArr[i]);
                    int _point = Utils.StrToInt(attachPointArr[i], 0);
                    ls.Add(new Model.article_attach { id = attachId, article_id = _id, file_name = attachFileNameArr[i], file_path = attachFilePathArr[i], file_size = fileSize, file_ext = fileExt, point = _point, });
                }
                model.attach = ls;
            }
            #endregion

            #region 保存会员组价格==============
            List<Model.user_group_price> priceList = new List<Model.user_group_price>();
            for (int i = 0; i < rptPrice.Items.Count; i++)
            {
                int hidPriceId = 0;
                if (!string.IsNullOrEmpty(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value))
                {
                    hidPriceId = Convert.ToInt32(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value);
                }
                int hidGroupId = Convert.ToInt32(((HiddenField)rptPrice.Items[i].FindControl("hideGroupId")).Value);
                decimal _price = Convert.ToDecimal(((TextBox)rptPrice.Items[i].FindControl("txtGroupPrice")).Text.Trim());
                priceList.Add(new Model.user_group_price { id = hidPriceId, article_id = _id, group_id = hidGroupId, price = _price });
            }
            model.group_price = priceList;
            #endregion

            if (bll.Update(model))
            {
                #region  商品相关

                if (channel_name == "goods")
                {
                    //规格价格
                    BLL.standard_price bll_price = new BLL.standard_price();
                    DataTable dt = bll_price.GetList(0, "good_id=" + _id, "id asc").Tables[0];
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        if (!bll_price.Delete("good_id=" + _id))
                        {
                            JscriptMsg("价格信息清除失败!", "", "Error");
                            return false;
                        }
                    }
                    string standard_ids = DTRequest.GetFormString("ck_standard");
                    string standard_value_ids = DTRequest.GetFormString("ck_standard_value");

                    string str_standards = "";
                    BLL.standard bll_standard = new BLL.standard();
                    string[] str_standard_arr = standard_ids.Split(',');
                    foreach (string str in str_standard_arr)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            Model.standard model_standard = bll_standard.GetModel(Convert.ToInt32(str));
                            if (model_standard != null)
                            {
                                str_standards += model_standard.title + ",";
                            }
                        }
                    }

                    BLL.standard_value bll_value = new BLL.standard_value();
                    string[] str_standard_value_arr = standard_value_ids.Split(',');

                    BLL.standard_group_price bll_standard_group_price = new BLL.standard_group_price();
                    DataTable dt_standard_group_price = bll_standard_group_price.GetList("good_id=" + _id).Tables[0];
                    if (dt_standard_group_price != null && dt_standard_group_price.Rows.Count > 0)
                    {
                        if (!bll_standard_group_price.Delete(_id))
                        {
                            JscriptMsg("清除商品规格会员价格失败!", "", "Error");
                            return false;
                        }
                    }

                    foreach (string str in str_standard_value_arr)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            string str_title = "";
                            string[] str_arr = str.Split('_');
                            foreach (string s in str_arr)
                            {
                                if (!string.IsNullOrEmpty(s))
                                {
                                    Model.standard_value model_value = bll_value.GetModel(Convert.ToInt32(s));
                                    if (model_value != null)
                                    {
                                        str_title += model_value.value + ",";
                                    }
                                }
                            }

                            Model.standard_price model_price = new Model.standard_price();

                            model_price.good_id = _id;
                            model_price.standard_ids = standard_ids;
                            model_price.good_no = DTRequest.GetFormString("good_no_" + str);
                            model_price.standards = str_standards.Substring(0, str_standards.Length - 1);
                            model_price.standard_value_ids = str.Replace('_', ',');
                            model_price.standard_values = str_title.Substring(0, str_title.Length - 1);
                            model_price.stock_quantity = DTRequest.GetFormInt("stock_quantity_" + str, 0);
                            model_price.market_price = DTRequest.GetFormDecimal("market_price_" + str, 0);
                            model_price.sell_price=sell_price=standard_price = DTRequest.GetFormDecimal("sell_price_" + str, 0);
                            model_price.action_price=action_price = DTRequest.GetFormDecimal("action_price_" + str, 0);
                            model_price.user_price = DTRequest.GetFormDecimal("user_price_" + str, 0);
                            model_price.add_time = DateTime.Now;

                            decimal _standard_price_id = bll_price.Add(model_price);
                            if (_standard_price_id <= 0)
                            {
                                JscriptMsg("更新价格信息失败!", "", "Error");
                                return false;
                            }

                            //规格会员组价格

                            BLL.user_groups bll_user_group = new BLL.user_groups();

                            DataTable dt_user_group = bll_user_group.GetList(0, "", "grade asc,id desc").Tables[0];
                            foreach (DataRow dr_user_group in dt_user_group.Rows)
                            {
                                Model.standard_group_price model_standard_group_price = new Model.standard_group_price();
                                model_standard_group_price.good_id = _id;
                                model_standard_group_price.group_id = Convert.ToInt32(dr_user_group["id"]);
                                model_standard_group_price.standard_price_id = _standard_price_id;
                                model_standard_group_price.group_price=standard_group_price = DTRequest.GetFormDecimal("user_price_" + dr_user_group["id"] + "_" + str, 0);
                                model_standard_group_price.add_time = DateTime.Now;
                                if (bll_standard_group_price.Add(model_standard_group_price) <= 0)
                                {
                                    JscriptMsg("规格会员价格更新失败!", "", "Error");
                                    return false;
                                }
                            }
                        }
                    }
                    //BLL.meal_good bll_meal_good = new BLL.meal_good();
                    //if (!bll_meal_good.UpdateMealGoodPrice(_id, sell_price, standard_price, standard_group_price, action_price))
                    //{
                    //    JscriptMsg("套餐商品价格更新失败!", "", "Error");
                    //    return false;
                    //}
                    //单位

                    BLL.unit bll_unit = new BLL.unit();
                    bll_unit.Delete(_id);
                    string str_unit = DTRequest.GetFormString("ck_unit");
                    if (!string.IsNullOrEmpty(str_unit))
                    {

                        string[] arr_unit = str_unit.Split(',');
                        foreach (string s_unit in arr_unit)
                        {
                            if (!string.IsNullOrEmpty(s_unit))
                            {
                                string[] unit = s_unit.Split('_');
                                Model.unit model_unit = new Model.unit();
                                model_unit.good_id = _id;
                                model_unit.title = unit[0];
                                model_unit.quantity = Convert.ToInt32(unit[1]);
                                model_unit.rate = Convert.ToDecimal(unit[2]);
                                model_unit.content = unit[3];
                                model_unit.add_time = DateTime.Now;

                                if (bll_unit.Add(model_unit) <= 0)
                                {
                                    JscriptMsg("更新单位失败!", "", "Error");
                                    return false;
                                }
                            }
                        }
                    }

                    //别名

                    BLL.alias_good bll_alias_good = new BLL.alias_good();
                    //删除
                    bll_alias_good.Delete(_id);

                    for (int i = 0; i < ck_alias.Items.Count; i++)
                    {
                        if (ck_alias.Items[i].Selected)
                        {
                            Model.alias_good model_alias_good = new Model.alias_good();
                            model_alias_good.alias_id = Convert.ToInt32(ck_alias.Items[i].Value);
                            model_alias_good.good_id = _id;

                            bll_alias_good.Add(model_alias_good);
                        }
                    }

                    //属性

                    BLL.property_value bll_property_value = new BLL.property_value();
                    BLL.property_good bll_property_good = new BLL.property_good();

                    bll_property_good.Delete(_id);

                    string str_property_value = DTRequest.GetFormString("ck_property_value");
                    if (!string.IsNullOrEmpty(str_property_value))
                    {
                        string[] arr_property_value = str_property_value.Split(',');
                        foreach (string str_1 in arr_property_value)
                        {
                            Model.property_good model_property_good = new Model.property_good();
                            model_property_good.good_id = _id;
                            model_property_good.property_value_id = Convert.ToInt32(str_1);
                            Model.property_value model_property_value = bll_property_value.GetModel(Convert.ToInt32(str_1));
                            if (model_property_value != null)
                            {
                                model_property_good.property_id = model_property_value.property_id;
                            }

                            bll_property_good.Add(model_property_good);
                        }
                    }

                    //标签
                    BLL.tag_good bll_tag_good = new BLL.tag_good();

                    bll_tag_good.Delete(_id);

                    for (int i = 0; i < ck_tag.Items.Count; i++)
                    {
                        if (ck_tag.Items[i].Selected)
                        {
                            Model.tag_good model_tag_good = new Model.tag_good();
                            model_tag_good.tag_id = Convert.ToInt32(ck_tag.Items[i].Value);
                            model_tag_good.good_id = _id;

                            bll_tag_good.Add(model_tag_good);
                        }
                    }
                }
                #endregion

                AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改" + this.channel_name + "频道内容:" + model.title); //记录日志
                result = true;
            }
            return result;
        }
Beispiel #4
0
        private void check_standard_unit_price(HttpContext context)
        {
            int goods_id = DTRequest.GetQueryInt("goods_id");
            string standard_value_id = DTRequest.GetQueryString("standard_value_id");
            decimal unit_id = DTRequest.GetQueryDecimal("unit_id", 0);

            if (goods_id <= 0)
            {
                context.Response.Write("{\"status\":\"0\", \"msg\":\"参数错误!\"}");
                return;
            }
            Model.article model_article = new BLL.article().GetModel(goods_id);
            if (model_article == null)
            {
                context.Response.Write("{\"status\":\"0\", \"msg\":\"商品不存在或已删除!\"}");
                return;
            }

            BLL.unit bll_unit = new BLL.unit();
            Model.unit model_unit = bll_unit.GetModel(unit_id);

            string real_standard_value_id = "";
            if (!string.IsNullOrEmpty(standard_value_id))
            {
                string[] str = standard_value_id.Split(',');
                foreach (string s in str)
                {
                    if (!string.IsNullOrEmpty(s))
                    {
                        real_standard_value_id += s.Split('|')[1] + ",";
                    }
                }
            }
            if (!string.IsNullOrEmpty(real_standard_value_id))
            {
                real_standard_value_id = real_standard_value_id.Substring(0, real_standard_value_id.Length - 1);
            }
            BLL.standard_price bll_standard_price = new BLL.standard_price();
            DataTable dt_standard_price = bll_standard_price.GetList("good_id=" + goods_id + " and standard_value_ids='" + real_standard_value_id + "'").Tables[0];
            if (dt_standard_price != null && dt_standard_price.Rows.Count > 0)
            {
                decimal sell_price = Convert.ToDecimal(dt_standard_price.Rows[0]["sell_price"]);//原价

                Model.users model_user = new BasePage().GetUserInfo();

                if (model_user != null)
                {
                    //会员价
                    BLL.standard_group_price bll_standard_group_price = new BLL.standard_group_price();
                    DataTable dt_standard_group_price = bll_standard_group_price.GetList("good_id=" + goods_id + " and group_id=" + model_user.group_id + " and standard_price_id='" + dt_standard_price.Rows[0]["id"].ToString().Trim() + "'").Tables[0];
                    if (dt_standard_group_price != null && dt_standard_group_price.Rows.Count > 0)
                    {
                        sell_price = Convert.ToDecimal(dt_standard_group_price.Rows[0]["group_price"]);
                    }

                    if (model_unit != null)
                    {
                        sell_price = sell_price * model_unit.quantity * (model_unit.rate / 100);
                    }
                }
                else
                {
                    //非会员价

                    if (model_unit != null)
                    {
                        sell_price = sell_price * model_unit.quantity * (model_unit.rate / 100);
                    }
                }
                //if (sell_price <= 0)
                //{
                //    context.Response.Write("{\"status\":\"0\", \"msg\":\"库存不足!\"}");
                //    return;
                //}
                context.Response.Write("{\"status\":\"1\", \"msg\":\"" + sell_price + "\"}");
                return;
            }
            else
            {
                //没规格价格
                //if (Convert.ToInt32(model_article.fields["stock_quantity"]) <= 0 || Convert.ToDecimal(model_article.fields["sell_price"]) <= 0)
                //{
                //    context.Response.Write("{\"status\":\"0\", \"msg\":\"库存不足!\"}");
                //    return;
                //}
                //else
                //{
                decimal sell_price = Convert.ToDecimal(model_article.fields["sell_price"]) * model_unit.quantity * (model_unit.rate / 100);
                context.Response.Write("{\"status\":\"1\", \"msg\":\"" + sell_price + "\"}");
                return;
                //}

            }
        }
Beispiel #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];
            }
        }
Beispiel #6
0
        private void get_good_unit(HttpContext context)
        {
            int good_id = DTRequest.GetQueryInt("good_id");
            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;
            }

            BLL.unit bll_unit = new BLL.unit();
            DataTable dt_unit = bll_unit.GetList("good_id=" + model_good.id).Tables[0];
            if (dt_unit != null && dt_unit.Rows.Count > 0)
            {
                context.Response.Write(myJson.getJson(dt_unit));
                return;
            }
            else
            {
                context.Response.Write("Null");
                return;
            }
        }
Beispiel #7
0
        private void batch_to_shopping(HttpContext context)
        {
            string id_quantitys = DTRequest.GetQueryString("ids");
            if (string.IsNullOrEmpty(id_quantitys))
            {
                context.Response.Write("{\"status\":\"0\", \"msg\":\"请选择您要购买的商品!\"}");
                return;
            }
            int group_id = 0;

            Model.users model_user = new BasePage().GetUserInfo();
            if (model_user != null)
            {
                group_id = model_user.group_id;
            }

            //商品ID-规格ID|规格值ID,规格ID|规格值ID-单位ID
            string[] arr_id_quantity = id_quantitys.Split(',');
            BLL.standard_price bll_standard_price = new BLL.standard_price();
            int flag = 0;

            BLL.unit bll_unit = new BLL.unit();

            Dictionary<string, int> dn = new Dictionary<string, int>();

            foreach (string str in arr_id_quantity)
            {

                if (!string.IsNullOrEmpty(str))
                {
                    if (new BLL.article().Exists(Convert.ToInt32(str.Split('_')[0])))
                    {
                        DataTable dt = bll_standard_price.GetList("good_id=" + str.Split('_')[0]).Tables[0];
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            //有规格
                            flag++;
                        }
                        else
                        {
                            //无规格  127--198
                            string car_id = str.Split('_')[0] + "--";
                            DataTable dt_unit = bll_unit.GetList(1, "good_id=" + str.Split('_')[0], "quantity asc").Tables[0];
                            if (dt_unit != null && dt_unit.Rows.Count > 0)
                            {
                                car_id += dt_unit.Rows[0]["id"].ToString();
                            }
                            else
                            {
                                car_id += "0";
                            }

                            //Web.UI.ShopCart.Add(car_id, Convert.ToInt32(str.Split('_')[1]));
                            dn.Add(car_id, Convert.ToInt32(str.Split('_')[1]));
                        }
                    }
                    else
                    {
                        context.Response.Write("{\"status\":\"0\", \"msg\":\"对不起,您购买的商品中有些不存在或已下架,请重新选择!\"}");
                        return;
                    }
                }
            }

            foreach (var item in dn)
            {
                Web.UI.ShopCart.Add(item.Key, item.Value);
            }

            Model.cart_total cartModel = Web.UI.ShopCart.GetTotal(group_id);
            if (flag > 0)
            {
                context.Response.Write("{\"status\":1, \"msg\":\"商品成功加入购物车,还有部分商品需要选择规格!\", \"quantity\":" + cartModel.total_quantity + ", \"amount\":" + cartModel.real_amount + "}");
            }
            else
            {
                context.Response.Write("{\"status\":1, \"msg\":\"商品成功加入购物车!\", \"quantity\":" + cartModel.total_quantity + ", \"amount\":" + cartModel.real_amount + "}");
            }
            return;
        }
Beispiel #8
0
        private void meal_into_shopping(HttpContext context)
        {
            int meal_id = DTRequest.GetQueryInt("meal_id");
            BLL.meal bll_meal = new BLL.meal();
            Model.meal model_meal = bll_meal.GetModel(meal_id);
            if (model_meal == null)
            {
                context.Response.Write("{\"status\":\"0\", \"msg\":\"该套餐不存在或已删除!\"}");
                return;
            }
            List<string> shopping_key = new List<string>();
            bool quantity_ture = true;
            bool good_true = true;

            //查找会员组

            decimal unit_id = 0;

            int group_id = 0;
            Model.users user_model = new Web.UI.BasePage().GetUserInfo();
            if (user_model != null)
            {
                group_id = user_model.group_id;
            }
            string str_standard_good_price_ids = ",";
            DataTable dt_meal_good = new BLL.meal_good().GetList("meal_id=" + meal_id).Tables[0];
            foreach (DataRow dr_meal_good in dt_meal_good.Rows)
            {
                if (str_standard_good_price_ids.IndexOf("," + (Convert.ToInt32(dr_meal_good["meal_id"]) + "-" + Convert.ToInt32(dr_meal_good["good_id"]) + "-" + Convert.ToDecimal(dr_meal_good["standard_price_id"]) + "-" + Convert.ToDecimal(dr_meal_good["unit_id"])) + ",") > -1)
                {
                    continue;
                }
                str_standard_good_price_ids += Convert.ToInt32(dr_meal_good["meal_id"]) + "-" + Convert.ToInt32(dr_meal_good["good_id"]) + "-" + Convert.ToDecimal(dr_meal_good["standard_price_id"]) + "-" + Convert.ToDecimal(dr_meal_good["unit_id"]) + ",";

                int goods_id = Convert.ToInt32(dr_meal_good["good_id"]);
                Model.article model_good = new BLL.article().GetModel(goods_id);
                if (model_good != null)
                {

                    //商品ID-规格ID|规格值ID,规格ID|规格值ID-单位ID
                    string standard = "";
                    DataTable dt_standard_price = new BLL.standard_price().GetList("id=" + Convert.ToDecimal(dr_meal_good["standard_price_id"])).Tables[0];
                    foreach (DataRow dr_standard_price in dt_standard_price.Rows)
                    {
                        if (!string.IsNullOrEmpty(dr_standard_price["standard_ids"].ToString()))
                        {
                            string[] arr_standard = dr_standard_price["standard_ids"].ToString().Split(',');
                            string[] arr_standard_value = dr_standard_price["standard_value_ids"].ToString().Split(',');
                            for (int i = 0; i < arr_standard.Length; i++)
                            {
                                if (!string.IsNullOrEmpty(arr_standard[i]))
                                {
                                    standard += arr_standard[i] + "|" + ((i < arr_standard_value.Length) ? arr_standard_value[i] : "0");
                                }
                            }
                        }
                    }
                    int goods_quantity = Convert.ToInt32(dr_meal_good["quantity"]);
                    Model.unit model_unit = new BLL.unit().GetModel(Convert.ToInt32(dr_meal_good["unit_id"]));
                    if (model_unit != null)
                    {
                        unit_id = model_unit.id;
                        goods_quantity = goods_quantity * model_unit.quantity;
                    }

                    //统计购物车
                    shopping_key.Add(goods_id + "-" + standard + "-" + unit_id + "&" + goods_quantity);
                }
                else
                {
                    quantity_ture = false;
                    good_true = false;
                }
            }
            if (!quantity_ture || !good_true)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"库存不足,添加购物车失败\"}");
                return;
            }
            foreach (string str in shopping_key)
            {
                if (!string.IsNullOrEmpty(str))
                {
                    Web.UI.ShopCart.Add(str.Split('&')[0], Convert.ToInt32(str.Split('&')[1]));
                }

            }

            Model.cart_total cartModel = Web.UI.ShopCart.GetTotal(group_id);

            context.Response.Write("{\"status\":1, \"msg\":\"商品已成功添加到购物车!\", \"quantity\":" + cartModel.total_quantity + ", \"amount\":" + cartModel.real_amount + "}");
            return;
        }
Beispiel #9
0
        private void add_car(HttpContext context)
        {
            int goods_id = DTRequest.GetQueryInt("goods_id");
            int goods_quantity = DTRequest.GetQueryInt("goods_quantity", 1);
            string standard = DTRequest.GetQueryString("standard");
            decimal unit_id = DTRequest.GetQueryDecimal("unit_id", 0);
            if (goods_id <= 0)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"您提交的商品参数有误!\"}");
                return;
            }
            //查找会员组
            int group_id = 0;
            Model.users groupModel = new Web.UI.BasePage().GetUserInfo();
            if (groupModel != null)
            {
                group_id = groupModel.group_id;
            }
            //规格ID|规格值ID,规格ID|规格值ID
            BLL.standard_price bll_standard_price = new BLL.standard_price();
            string standard_value_ids = "";
            if (!string.IsNullOrEmpty(standard))
            {
                string[] arr_standard = standard.Split(',');
                foreach (string str in arr_standard)
                {
                    if (!string.IsNullOrEmpty(str))
                    {
                        if (str.Split('|').Length == 2)
                        {
                            standard_value_ids += str.Split('|')[1] + ",";
                        }
                    }
                }
            }

            int total_quantity = goods_quantity;

            BLL.unit bll_unit = new BLL.unit();
            Model.unit model_unit = bll_unit.GetModel(unit_id);
            if (model_unit != null)
            {
                total_quantity = total_quantity * model_unit.quantity;
            }

            BLL.article bll_article = new BLL.article();
            Model.article model_article = bll_article.GetModel(goods_id);
            if (model_article != null)
            {
                if (model_article.fields["stock_quantity"] != null && model_article.fields["stock_quantity"].ToString() != "")
                {
                    if (Convert.ToInt32(model_article.fields["stock_quantity"]) < total_quantity)
                    {
                        context.Response.Write("{\"status\":0, \"msg\":\"对不起,该商品库存不足,购买失败!\"}");
                        return;
                    }
                }
                else
                {
                    context.Response.Write("{\"status\":0, \"msg\":\"对不起,该商品库存不足,购买失败!\"}");
                    return;
                }
            }

            if (!string.IsNullOrEmpty(standard_value_ids))
            {
                standard_value_ids = standard_value_ids.Substring(0, standard_value_ids.Length - 1);
                DataTable dt_standard_price = bll_standard_price.GetList("standard_value_ids='" + standard_value_ids + "' and good_id=" + goods_id).Tables[0];
                if (dt_standard_price != null && dt_standard_price.Rows.Count > 0)
                {
                    if (Convert.ToInt32(dt_standard_price.Rows[0]["stock_quantity"]) < total_quantity)
                    {
                        context.Response.Write("{\"status\":0, \"msg\":\"对不起,该商品库存不足,购买失败!\"}");
                        return;
                    }
                }
                else
                {
                    context.Response.Write("{\"status\":0, \"msg\":\"对不起,该商品库存不足,购买失败!\"}");
                    return;
                }
            }

            //统计购物车
            Web.UI.ShopCart.Add(goods_id + "-" + standard + "-" + unit_id, goods_quantity);
            Model.cart_total cartModel = Web.UI.ShopCart.GetTotal(group_id);
            context.Response.Write("{\"status\":1, \"msg\":\"商品已成功添加到购物车!\", \"quantity\":" + cartModel.total_quantity + ", \"amount\":" + cartModel.real_amount + "}");
            return;
        }
Beispiel #10
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));
        }
Beispiel #11
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;
                }
            }
        }
Beispiel #12
0
        private void get_car_list(HttpContext context)
        {
            IList<DTcms.Model.cart_items> ls1 = get_cart_list();
            string car_ids = DTRequest.GetQueryString("car_ids");
            DataTable dt = new DataTable();
            dt.Columns.Add("car_id");
            dt.Columns.Add("goods_id");
            dt.Columns.Add("title");
            dt.Columns.Add("img_url");
            dt.Columns.Add("standard");
            dt.Columns.Add("category");
            dt.Columns.Add("price");
            dt.Columns.Add("user_price");
            dt.Columns.Add("stock_quantity");
            dt.Columns.Add("quantity");
            dt.Columns.Add("weight");
            dt.Columns.Add("unit");
            dt.PrimaryKey = new DataColumn[] { dt.Columns["car_id"] };

            foreach (Model.cart_items item in ls1)
            {
                if (!string.IsNullOrEmpty(car_ids))
                {
                    if (car_ids.IndexOf((item.id + "-" + item.standard)) <= -1)
                    {
                        continue;
                    }
                }

                DataRow dr = dt.NewRow();
                dr["car_id"] = item.id + "-" + item.standard + "-" + item.unit_id;
                dr["goods_id"] = item.id;
                dr["title"] = item.title;
                dr["img_url"] = item.img_url;
                string str_standard = "";
                string[] arr_standard = item.standard.Split(',');
                foreach (string str in arr_standard)
                {
                    if (!string.IsNullOrEmpty(str))
                    {
                        BLL.standard_value bll_standard_value = new BLL.standard_value();
                        Model.standard_value model_standard_value = bll_standard_value.GetModel(Convert.ToInt32(str.Split('|')[1]));
                        if (model_standard_value != null)
                        {
                            str_standard += model_standard_value.value + " ";
                        }
                    }
                }
                dr["standard"] = str_standard.TrimEnd(' ');
                BLL.article bll = new BLL.article();
                Model.article model = bll.GetModel(item.id);
                dr["category"] = new BLL.article_category().GetTitle(model.category_id);
                if (new BasePage().GetUserInfo() != null)
                {
                    dr["price"] = item.user_price;
                }
                else
                {
                    dr["price"] = item.price;
                }

                dr["stock_quantity"] = item.stock_quantity;
                dr["quantity"] = item.quantity;
                dr["weight"] = model.fields["weight"];
                dr["unit"] = "";
                BLL.unit bll_unit = new BLL.unit();
                Model.unit model_unit = bll_unit.GetModel(item.unit_id);
                if (model_unit != null)
                {
                    string str_unit = model_unit.title;
                    if (!string.IsNullOrEmpty(model_unit.content))
                    {
                        str_unit += "(" + model_unit.content + ")";
                    }
                    dr["unit"] = str_unit;
                }
                dt.Rows.Add(dr);
            }
            if (dt != null && dt.Rows.Count > 0)
            {
                context.Response.Write(myJson.getJson(dt));
                return;
            }
            else
            {
                context.Response.Write("Null");
                return;
            }
        }
Beispiel #13
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;
            }
        }
Beispiel #14
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;
        }
Beispiel #15
0
        /// <summary>
        /// 获得购物车列表
        /// </summary>
        public static IList<Model.cart_items> GetList(int group_id)
        {
            IDictionary<string, int> dic = GetCart();
            if (dic==null || dic.Count <= 0)
            {
                 #region 获取数据库购物车
                Model.users model = new BasePage().GetUserInfo();
                if (model != null)
                {
                    BLL.cart cartbll = new BLL.cart();
                    DataTable dt = cartbll.GetList("UserID='" + model.id + "'").Tables[0];
                    if (dt.Rows.Count <= 0)
                    {
                        //return null;
                    }
                    else
                    {
                        dic = new Dictionary<string, int>();
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {

                            dic.Add(dt.Rows[i]["ProductName"].ToString(), int.Parse(dt.Rows[i]["Counts"].ToString()));

                        }

                    }

                }
                #endregion
            }
            if (dic != null)
            {
                IList<Model.cart_items> iList = new List<Model.cart_items>();

                foreach (var item in dic)
                {
                    BLL.article bll = new BLL.article();

                    //key:1547-27|120,28|122-55
                    int goods_id = Convert.ToInt32(item.Key.Split('-')[0]);
                    string standard = item.Key.Split('-')[1];

                    decimal unit_id = decimal.Parse(item.Key.Split('-')[2], 0);// Convert.ToDecimal(item.Key.Split('-')[2]);
                    Model.article model = bll.GetModel(Convert.ToInt32(goods_id));
                    if (model == null || !model.fields.ContainsKey("sell_price"))
                    {
                        continue;
                    }
                    string standard_value_ids = "";
                    string[] arr_standard = standard.Split(',');
                    foreach (string str in arr_standard)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            standard_value_ids += str.Split('|')[1] + ",";
                        }
                    }
                    if (!string.IsNullOrEmpty(standard_value_ids))
                    {
                        standard_value_ids = standard_value_ids.Substring(0, standard_value_ids.Length - 1);
                    }

                    Model.cart_items modelt = new Model.cart_items();
                    modelt.id = model.id;
                    modelt.title = model.title;
                    modelt.img_url = model.img_url;
                    modelt.standard = standard;
                    modelt.unit_id = unit_id;
                    if (model.fields.ContainsKey("point"))
                    {
                        modelt.point = Utils.StrToInt(model.fields["point"], 0);
                    }

                    modelt.price = Utils.StrToDecimal(model.fields["sell_price"], 0);
                    modelt.user_price = Utils.StrToDecimal(model.fields["sell_price"], 0);

                    //单位价格  -- 有单位  无会员 无规格
                    BLL.unit bll_unit = new BLL.unit();
                    Model.unit model_unit = bll_unit.GetModel(unit_id);
                    if (model_unit != null)
                    {
                        modelt.price = Utils.StrToDecimal(model.fields["sell_price"], 0) * model_unit.quantity * (model_unit.rate / 100);
                        modelt.user_price = Utils.StrToDecimal(model.fields["sell_price"], 0) * model_unit.quantity * (model_unit.rate / 100);
                    }

                    //规格价格  --有/无单位  无会员  有规格
                    BLL.standard_price bll_standard_price = new BLL.standard_price();

                    DataTable dt_standard_price = bll_standard_price.GetList("standard_value_ids='" + standard_value_ids + "' and good_id=" + goods_id).Tables[0];
                    if (dt_standard_price != null && dt_standard_price.Rows.Count > 0)
                    {
                        modelt.user_price = modelt.price = Utils.StrToDecimal(dt_standard_price.Rows[0]["sell_price"].ToString(), 0);
                        if (model_unit != null)
                        {
                            modelt.user_price = modelt.price = Utils.StrToDecimal(dt_standard_price.Rows[0]["sell_price"].ToString(), 0) * model_unit.quantity * (model_unit.rate / 100);
                        }
                    }

                    if (model.fields.ContainsKey("stock_quantity"))
                    {
                        modelt.stock_quantity = Utils.StrToInt(model.fields["stock_quantity"], 0);
                    }
                    //会员价格
                    if (model.group_price != null)
                    {
                        Model.user_group_price gmodel = model.group_price.Find(p => p.group_id == group_id);
                        if (gmodel != null)
                        {
                            modelt.user_price = gmodel.price;
                            //有规格才有规格等级价格
                            if (dt_standard_price != null && dt_standard_price.Rows.Count > 0)
                            {
                                BLL.standard_group_price bll_standard_group_price = new BLL.standard_group_price();
                                DataTable dt_standard_group_price = bll_standard_group_price.GetList("good_id=" + goods_id + " and standard_price_id=" + dt_standard_price.Rows[0]["id"].ToString() + " and group_id=" + group_id).Tables[0];
                                //有规格会员价格
                                if (dt_standard_group_price != null && dt_standard_group_price.Rows.Count > 0)
                                {
                                    //规格会员价格  无单位-- 有规格 有会员
                                    modelt.user_price = Convert.ToDecimal(dt_standard_group_price.Rows[0]["group_price"]);
                                }

                            }
                            if (model_unit != null)
                            {
                                modelt.user_price = modelt.user_price * model_unit.quantity * (model_unit.rate / 100);
                            }
                        }
                    }
                    modelt.quantity = item.Value;
                    iList.Add(modelt);
                }
                return iList;
            }
            return null;
        }
Beispiel #16
0
        private void add_order(HttpContext context)
        {
            int address_id = DTRequest.GetQueryInt("address");
            int freight_id = DTRequest.GetQueryInt("freight");
            string car_ids = DTRequest.GetQueryString("car_ids");

            Model.users model = new BasePage().GetUserInfo();
            if (model == null)
            {
                context.Response.Write("{\"status\":\"0\", \"msg\":\"对不起,请重新登录!\"}");
                return;
            }

            //统计购物车
            BLL.express bll_express = new BLL.express();
            Model.express model_express = bll_express.GetModel(freight_id);
            if (model_express == null)
            {
                context.Response.Write("{\"status\":\"0\", \"msg\":\"对不起,该配送方式不存在或已删除!\"}");
                return;
            }

            BLL.address bll_address = new BLL.address();
            Model.address model_address = bll_address.GetModel(address_id);
            if (model_address == null)
            {
                context.Response.Write("{\"status\":\"0\", \"msg\":\"对不起,该收货信息不存在或已删除!\"}");
                return;
            }

            IList<Model.cart_items> iList = DTcms.Web.UI.ShopCart.GetList(model.group_id);
            if (iList == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,购物车为空,无法结算!\"}");
                return;
            }

            //保存订单=======================================================================
            Model.orders model_order = new Model.orders();

            model_order.order_no = "B" + Utils.GetOrderNumber(); //订单号B开头为商品订单
            model_order.user_id = model.id;
            model_order.user_name = model.user_name;
            model_order.payment_id = 0;
            model_order.express_id = model_express.id;
            model_order.accept_name = model_address.consignee;
            model_order.post_code = model_address.zipcode;
            model_order.telphone = model_address.consignee_phone;
            model_order.mobile = model_address.consignee_mobile;
            model_order.address = new BLL.province().GetModel(model_address.province).ProvinceName + "|" + new BLL.city().GetModel(model_address.city).CityName + "|" + new BLL.district().GetModel(model_address.distract).DistrictName + "|" + model_address.content;
            model_order.message = "";

            model_order.express_status = 1;
            model_order.express_fee = model_express.express_fee; //物流费用
            //如果是先款后货的话

            //购物积分,可为负数

            model_order.add_time = DateTime.Now;
            //商品详细列表
            decimal real_amount = 0;
            decimal payable_amount = 0;
            int total_point = 0;
            List<Model.order_goods> gls = new List<Model.order_goods>();
            BLL.standard bll_standard = new BLL.standard();
            foreach (Model.cart_items item in iList)
            {
                string[] arr_car_id = car_ids.Split('_');
                foreach (string str in arr_car_id)
                {

                    if ((item.id + "-" + item.standard + "-" + item.unit_id).Trim() == str)
                    {
                        //{   //40-1|红色,2|黑色_10-1|红色,2|黑色      商品ID-规格ID|规格值ID,规格ID|规格值ID-单位ID
                        //    string[] arr_good_standard=str.Split('-');
                        //    string str_standard = "";
                        //    foreach (string str1 in arr_good_standard)
                        //    {
                        //        BLL.standard bll_standard = new BLL.standard();
                        //        Model.standard model_standard = bll_standard.GetModel(Convert.ToInt32(str1.Split('|')[0]));
                        //        if (model_standard != null)
                        //        {
                        //            str_standard += model_standard.title + ":" + str1.Split('|')[1];
                        //        }
                        //    }
                        string str_standard = "";
                        //190-14|41-4650
                        string standard_title_id = "";
                        string standard_value_id = "";
                        Model.article model_good = new BLL.article().GetModel(item.id);
                        if (model_good == null)
                        {
                            return;
                        }
                        string good_no = model_good.fields["goods_no"];
                        //规格
                        if (!string.IsNullOrEmpty(item.standard))
                        {
                            string[] arr_standard = item.standard.Split(',');
                            for (int i = 0; i < arr_standard.Length; i++)
                            {
                                Model.standard model_standard = bll_standard.GetModel(Convert.ToInt32(arr_standard[i].Split('|')[0]));
                                Model.standard_value model_standard_value = new BLL.standard_value().GetModel(Convert.ToInt32(arr_standard[i].Split('|')[1]));
                                if (model_standard != null && model_standard_value != null)
                                {

                                    str_standard += model_standard.title + ":" + arr_standard[i].Split('|')[1] + ",";
                                    standard_title_id += model_standard.id + ",";
                                    standard_value_id += model_standard_value.id + ",";
                                }
                            }
                        }

                        if (!string.IsNullOrEmpty(standard_title_id) && !string.IsNullOrEmpty(standard_value_id))
                        {
                            DataTable dt_standard_value = new BLL.standard_price().GetList("good_id='" + item.id + "' and standard_ids='" + standard_title_id.Substring(0, standard_title_id.Length - 1) + "' and standard_value_ids='" + standard_value_id.Substring(0, standard_value_id.Length - 1) + "'").Tables[0];
                            if (dt_standard_value != null && dt_standard_value.Rows.Count == 1)
                            {
                                good_no = dt_standard_value.Rows[0]["good_no"].ToString();
                            }
                        }

                        real_amount += item.user_price * item.quantity;
                        payable_amount += item.price * item.quantity;
                        total_point += item.point * item.quantity;

                        BLL.unit bll_unit = new BLL.unit();
                        Model.unit model_unit = bll_unit.GetModel(item.unit_id);
                        string str_unit = "";
                        if (model_unit != null)
                        {
                            str_unit = model_unit.title;
                            if (!string.IsNullOrEmpty(model_unit.content))
                            {
                                str_unit += "(" + model_unit.content + ")";
                            }
                        }

                        gls.Add(new Model.order_goods { goods_id = item.id, good_no = good_no, goods_title = item.title, goods_price = item.price, real_price = item.user_price, quantity = item.quantity, point = item.point, standard = (string.IsNullOrEmpty(str_standard) ? "" : str_standard.Substring(0, str_standard.Length - 1)), unit_id = item.unit_id, unit = str_unit });
                    }
                }

            }

            model_order.payable_amount = payable_amount;
            model_order.real_amount = real_amount;
            model.point = total_point;
            //订单总金额=实付商品金额+运费+支付手续费
            model_order.order_amount = model_order.real_amount + model_order.express_fee + model_order.payment_fee;
            model_order.order_goods = gls;
            int result = new BLL.orders().Add(model_order);
            if (result < 1)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"订单保存过程中发生错误,请重新提交!\"}");
                return;
            }
            else
            {
                string[] arr_car_id = car_ids.Split('_');
                foreach (string str in arr_car_id)
                {
                    //清空购物车
                    DTcms.Web.UI.ShopCart.Clear(str);
                }
                context.Response.Write("{\"status\":1, \"msg\":\"提交订单成功!\",\"order_no\":\"" + model_order.order_no + "\",\"order_money\":\"" + model_order.order_amount + "\",\"user_money\":\"" + model.amount + "\",\"order_id\":\"" + result + "\"}");
                return;
            }
        }
Beispiel #17
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];
            }
        }
Beispiel #18
0
        /// <summary>
        /// 获得购物车列表
        /// </summary>
        public static IList <Model.cart_items> GetList(int group_id)
        {
            IDictionary <string, int> dic = GetCart();

            if (dic == null || dic.Count <= 0)
            {
                #region 获取数据库购物车
                Model.users model = new BasePage().GetUserInfo();
                if (model != null)
                {
                    BLL.cart  cartbll = new BLL.cart();
                    DataTable dt      = cartbll.GetList("UserID='" + model.id + "'").Tables[0];
                    if (dt.Rows.Count <= 0)
                    {
                        //return null;
                    }
                    else
                    {
                        dic = new Dictionary <string, int>();
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            dic.Add(dt.Rows[i]["ProductName"].ToString(), int.Parse(dt.Rows[i]["Counts"].ToString()));
                        }
                    }
                }
                #endregion
            }
            if (dic != null)
            {
                IList <Model.cart_items> iList = new List <Model.cart_items>();

                foreach (var item in dic)
                {
                    BLL.article bll = new BLL.article();


                    //key:1547-27|120,28|122-55
                    int    goods_id = Convert.ToInt32(item.Key.Split('-')[0]);
                    string standard = item.Key.Split('-')[1];

                    decimal       unit_id = decimal.Parse(item.Key.Split('-')[2], 0);// Convert.ToDecimal(item.Key.Split('-')[2]);
                    Model.article model   = bll.GetModel(Convert.ToInt32(goods_id));
                    if (model == null || !model.fields.ContainsKey("sell_price"))
                    {
                        continue;
                    }
                    string   standard_value_ids = "";
                    string[] arr_standard       = standard.Split(',');
                    foreach (string str in arr_standard)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            standard_value_ids += str.Split('|')[1] + ",";
                        }
                    }
                    if (!string.IsNullOrEmpty(standard_value_ids))
                    {
                        standard_value_ids = standard_value_ids.Substring(0, standard_value_ids.Length - 1);
                    }

                    Model.cart_items modelt = new Model.cart_items();
                    modelt.id       = model.id;
                    modelt.title    = model.title;
                    modelt.img_url  = model.img_url;
                    modelt.standard = standard;
                    modelt.unit_id  = unit_id;
                    if (model.fields.ContainsKey("point"))
                    {
                        modelt.point = Utils.StrToInt(model.fields["point"], 0);
                    }

                    modelt.price      = Utils.StrToDecimal(model.fields["sell_price"], 0);
                    modelt.user_price = Utils.StrToDecimal(model.fields["sell_price"], 0);

                    //单位价格  -- 有单位  无会员 无规格
                    BLL.unit   bll_unit   = new BLL.unit();
                    Model.unit model_unit = bll_unit.GetModel(unit_id);
                    if (model_unit != null)
                    {
                        modelt.price      = Utils.StrToDecimal(model.fields["sell_price"], 0) * model_unit.quantity * (model_unit.rate / 100);
                        modelt.user_price = Utils.StrToDecimal(model.fields["sell_price"], 0) * model_unit.quantity * (model_unit.rate / 100);
                    }

                    //规格价格  --有/无单位  无会员  有规格
                    BLL.standard_price bll_standard_price = new BLL.standard_price();

                    DataTable dt_standard_price = bll_standard_price.GetList("standard_value_ids='" + standard_value_ids + "' and good_id=" + goods_id).Tables[0];
                    if (dt_standard_price != null && dt_standard_price.Rows.Count > 0)
                    {
                        modelt.user_price = modelt.price = Utils.StrToDecimal(dt_standard_price.Rows[0]["sell_price"].ToString(), 0);
                        if (model_unit != null)
                        {
                            modelt.user_price = modelt.price = Utils.StrToDecimal(dt_standard_price.Rows[0]["sell_price"].ToString(), 0) * model_unit.quantity * (model_unit.rate / 100);
                        }
                    }


                    if (model.fields.ContainsKey("stock_quantity"))
                    {
                        modelt.stock_quantity = Utils.StrToInt(model.fields["stock_quantity"], 0);
                    }
                    //会员价格
                    if (model.group_price != null)
                    {
                        Model.user_group_price gmodel = model.group_price.Find(p => p.group_id == group_id);
                        if (gmodel != null)
                        {
                            modelt.user_price = gmodel.price;
                            //有规格才有规格等级价格
                            if (dt_standard_price != null && dt_standard_price.Rows.Count > 0)
                            {
                                BLL.standard_group_price bll_standard_group_price = new BLL.standard_group_price();
                                DataTable dt_standard_group_price = bll_standard_group_price.GetList("good_id=" + goods_id + " and standard_price_id=" + dt_standard_price.Rows[0]["id"].ToString() + " and group_id=" + group_id).Tables[0];
                                //有规格会员价格
                                if (dt_standard_group_price != null && dt_standard_group_price.Rows.Count > 0)
                                {
                                    //规格会员价格  无单位-- 有规格 有会员
                                    modelt.user_price = Convert.ToDecimal(dt_standard_group_price.Rows[0]["group_price"]);
                                }
                            }
                            if (model_unit != null)
                            {
                                modelt.user_price = modelt.user_price * model_unit.quantity * (model_unit.rate / 100);
                            }
                        }
                    }
                    modelt.quantity = item.Value;
                    iList.Add(modelt);
                }
                return(iList);
            }
            return(null);
        }