Example #1
0
        private void get_prop_page(HttpContext context)
        {
            try
            {
                StringBuilder strhtml  = new StringBuilder();
                int           category = DTRequest.GetFormInt("category", 0);
                int           page     = DTRequest.GetFormInt("page", 1);

                BLL.property       pro       = new BLL.property();
                BLL.property_value pro_value = new BLL.property_value();

                BLL.article_category catgory = new BLL.article_category();
                string    category_ids       = "";
                DataTable dt_pro             = null;
                if (category == 0)
                {
                    dt_pro = pro.GetList("").Tables[0];
                }
                else
                {
                    DataTable cat_dt = catgory.GetList(0, 2, category.ToString());//查找类别下的所有类别
                    if (cat_dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < cat_dt.Rows.Count; i++)
                        {
                            category_ids += cat_dt.Rows[i][0].ToString() + ",";
                        }
                        category_ids = category_ids.Substring(0, category_ids.Length - 1);
                    }
                    dt_pro = pro.GetList("category_id in(" + category_ids + ")").Tables[0];
                }
                if (dt_pro.Rows.Count > 0)
                {
                    for (int i = 0; i < dt_pro.Rows.Count; i++)
                    {
                        strhtml.Append("<dl>");
                        strhtml.Append("<dt>" + dt_pro.Rows[i]["title"] + "</dt>");
                        DataTable dt_pro_value = pro_value.GetList("property_id='" + dt_pro.Rows[i][0] + "'").Tables[0];
                        if (dt_pro_value.Rows.Count > 0)
                        {
                            for (int j = 0; j < dt_pro_value.Rows.Count; j++)
                            {
                                strhtml.Append("<dd><a style=\"cursor:pointer;\" onclick='getpagedata(" + dt_pro_value.Rows[j][0] + "," + category + "," + page + ")'>" + dt_pro_value.Rows[j]["value"] + "</a><span></span></dd>");
                            }
                        }
                        strhtml.Append("</dl>");
                    }
                    context.Response.Write("{ \"info\":\"获取数据成功!\", \"status\":\"1\" ,\"html\":\"" + myJson.String2Json(strhtml.ToString()) + "\",\"pagelist\":\"\"}");
                    return;
                }
                context.Response.Write("{ \"info\":\"该类别暂未添加属性!\", \"status\":\"0\" }");
            }
            catch (Exception ex)
            {
                context.Response.Write("{ \"info\":\"该类别暂未添加属性!\", \"status\":\"0\" }");
                return;
            }
        }
Example #2
0
        private void RptBind(string _strWhere, string _orderby)
        {
            this.page = DTRequest.GetQueryInt("page", 1);

            if (category_id > 0)
            {
                _strWhere += " and category_id in(select id from dt_article_category where class_list like '%," + category_id + ",%')";
                ddlCategoryId.SelectedValue = category_id.ToString();
            }

            BLL.property bll = new BLL.property();
            this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount);
            this.rptList.DataBind();

            //绑定页码
            txtPageNum.Text = this.pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("list.aspx", "category_id={0}&page={1}",
                                              this.category_id.ToString(), "__id__");

            PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
        }
Example #3
0
        /// <summary>
        /// 绑定属性
        /// </summary>
        /// <param name="category_id"></param>
        private void Bind_Property(int category_id)
        {
            BLL.property bll = new BLL.property();
            DataTable dt = bll.GetList(" category_id in(select id from dt_article_category where (select class_list from dt_article_category where id=" + category_id + ") like '%,'+CONVERT(varchar(20),id)+',%')").Tables[0];
            string str_result = "";
            foreach (DataRow dr in dt.Rows)
            {
                str_result += "<dl>";
                str_result += "<dt>" + dr["title"].ToString() + ":</dt>";
                BLL.property_value bll_value = new BLL.property_value();
                DataTable dt_value = bll_value.GetList("property_id=" + dr["id"].ToString()).Tables[0];
                str_result += "<dd>";
                if (dt_value != null && dt_value.Rows.Count > 0)
                {
                    foreach (DataRow dr1 in dt_value.Rows)
                    {
                        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;
        }
Example #4
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
        }
Example #5
0
        private void RptBind(string _strWhere, string _orderby)
        {
            this.page = DTRequest.GetQueryInt("page", 1);

            if (category_id > 0)
            {
                _strWhere += " and category_id in(select id from dt_article_category where class_list like '%," + category_id + ",%')";
                ddlCategoryId.SelectedValue = category_id.ToString();
            }

            BLL.property bll = new BLL.property();
            this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount);
            this.rptList.DataBind();

            //绑定页码
            txtPageNum.Text = this.pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("list.aspx", "category_id={0}&page={1}",
                this.category_id.ToString(), "__id__");
            PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
        }
Example #6
0
        private void get_good_list(HttpContext context)
        {
            int page = DTRequest.GetQueryInt("page", 1);
            string flag = DTRequest.GetQueryString("flag");
            int pagesize = DTRequest.GetQueryInt("pagesize", 12);
            string order = DTRequest.GetQueryString("order");
            string keyword = DTRequest.GetQueryString("keyword");
            int category = DTRequest.GetQueryInt("category");
            string property = DTRequest.GetQueryString("property");

            string strwhere = " is_put=1 ";
            string strorder = "sort_id asc ,add_time desc";
            int totalcount = 0;

            DataSet ds = new DataSet();

            if (!string.IsNullOrEmpty(property))
            {
                //strwhere += " and id in ( select good_id from td_property_good where property_value_id in (" + property + ")) ";
                string where_pro = "";
                string[] str_arr = property.Split(',');
                for (int i = 0; i < str_arr.Length; i++)
                {
                    if (i == 0)
                    {
                        where_pro += " select good_id from td_property_good where property_value_id in(" + str_arr[i] + ") ";
                    }
                    else
                    {
                        where_pro = "select good_id from td_property_good where good_id in (" + where_pro + ") and   property_value_id=" + str_arr[i];
                    }
                }

                strwhere += " and id in (" + where_pro + ")";
            }

            if (!string.IsNullOrEmpty(keyword))
            {
                strwhere += " and (id in (select good_id from td_property_good where property_value_id in ( select id from td_property_value where value like '%" + keyword + "%')) or id in (select good_id from td_tag_good where tag_id in( select id from td_tag where title like '%" + keyword + "%')) or id in (select good_id from td_alias_good where alias_id in( select id from td_alias where title like '%" + keyword + "%'))or title like '%" + keyword + "%') ";
            }

            if (order == "moneya")
            {
                strorder = "sell_price asc";
            }
            if (order == "moneyd")
            {
                strorder = "sell_price desc";
            }

            BLL.article bll = new BLL.article();
            DataTable dt = bll.GetList("goods", category, pagesize, page, strwhere, strorder, out totalcount).Tables[0];

            DataTable dt_goods = new DataTable();
            dt_goods.Columns.Add("id");
            dt_goods.Columns.Add("title");
            dt_goods.Columns.Add("sell_price");
            dt_goods.Columns.Add("img_url");
            dt_goods.Columns.Add("standard");

            foreach (DataRow dr in dt.Rows)
            {
                DataRow new_dr = dt_goods.NewRow();
                new_dr["id"] = dr["id"];
                new_dr["title"] = dr["title"];
                new_dr["sell_price"] = dr["sell_price"];
                new_dr["img_url"] = dr["img_url"];

                BLL.standard_price bll_standard_price = new BLL.standard_price();
                DataTable dt_standard_price = bll_standard_price.GetList("good_id=" + Convert.ToInt32(dr["id"])).Tables[0];
                if (dt_standard_price != null && dt_standard_price.Rows.Count > 0)
                {
                    //有库存
                    new_dr["standard"] = 1;
                }
                else
                {
                    //没库存
                    new_dr["standard"] = 2;
                }

                dt_goods.Rows.Add(new_dr);
            }

            dt_goods.TableName = "dt_good";
            if (dt_goods != null && dt_goods.Rows.Count > 0)
            {
                ds.Tables.Add(dt_goods.Copy());
            }
            //刷新属性列表  单个类别绑定属性
            if (flag == "default" || flag == "self_category" || flag == "self")
            {
                DataTable dt_property = new DataTable();
                dt_property.Columns.Add("id");
                dt_property.Columns.Add("title");
                dt_property.Columns.Add("parent_id");

                dt_property.TableName = "dt_property";

                BLL.property bll_property = new BLL.property();
                DataTable old_dt_property = bll_property.GetList(0, "category_id in (select id from dt_article_category where class_list like '%," + category + ",%')", "add_time desc").Tables[0];
                foreach (DataRow dr in old_dt_property.Rows)
                {
                    DataRow new_dr = dt_property.NewRow();
                    new_dr["id"] = 0;
                    new_dr["title"] = dr["title"];
                    new_dr["parent_id"] = 0;

                    dt_property.Rows.Add(new_dr);
                    BLL.property_value bll_value = new BLL.property_value();
                    DataTable dt_property_value = bll_value.GetList(0, "property_id=" + dr["id"].ToString(), "add_time desc").Tables[0];
                    foreach (DataRow dr_value in dt_property_value.Rows)
                    {
                        DataRow new_dr_value = dt_property.NewRow();
                        new_dr_value["id"] = dr_value["id"];
                        new_dr_value["title"] = dr_value["value"];
                        new_dr_value["parent_id"] = dr["id"];
                        dt_property.Rows.Add(new_dr_value);
                    }
                }

                if (dt_property != null && dt_property.Rows.Count > 0)
                {
                    ds.Tables.Add(dt_property.Copy());
                }
            }
            //多个类别绑定属性
            if (flag == "other")
            {

                DataTable dt_good = bll.GetList(0, " id in (select good_id from td_property_good where property_value_id in ( select id from td_property_value where value like '%" + keyword + "%')) or id in (select good_id from td_tag_good where tag_id in( select id from td_tag where title like '%" + keyword + "%')) or id in (select good_id from td_alias_good where alias_id in( select id from td_alias where title like '%" + keyword + "%'))or title like '%" + keyword + "%' ", "sort_id asc,add_time desc").Tables[0];

                DataTable dt_category = new DataTable();
                dt_category.Columns.Add("id");
                dt_category.Columns.Add("title");
                BLL.article_category bll_category = new BLL.article_category();
                Model.article_category model_category;
                string category_ids = ",";
                foreach (DataRow dr in dt_good.Rows)
                {
                    if (category_ids.IndexOf("," + dr["category_id"].ToString() + ",") <= -1)
                    {
                        category_ids += dr["category_id"].ToString() + ",";
                        model_category = bll_category.GetModel(Convert.ToInt32(dr["category_id"]));
                        if (model_category != null)
                        {
                            DataRow new_dr = dt_category.NewRow();
                            new_dr["id"] = model_category.id;
                            new_dr["title"] = model_category.title;
                            dt_category.Rows.Add(new_dr);
                        }
                    }
                }
                if (dt_category != null && dt_category.Rows.Count > 0)
                {
                    dt_category.TableName = "dt_category";
                    ds.Tables.Add(dt_category.Copy());
                }

                if (!string.IsNullOrEmpty(category_ids.Trim(',')))
                {
                    DataTable dt_property = new DataTable();
                    dt_property.Columns.Add("id");
                    dt_property.Columns.Add("title");
                    dt_property.Columns.Add("parent_id");

                    dt_property.TableName = "dt_property";

                    BLL.property bll_property = new BLL.property();
                    DataTable old_dt_property = bll_property.GetList(0, "category_id in (" + category_ids.Substring(1, category_ids.Length - 2) + ")", "add_time desc").Tables[0];

                    foreach (DataRow dr in old_dt_property.Rows)
                    {
                        DataRow new_dr = dt_property.NewRow();
                        new_dr["id"] = 0;
                        new_dr["title"] = dr["title"];
                        new_dr["parent_id"] = 0;

                        dt_property.Rows.Add(new_dr);
                        BLL.property_value bll_value = new BLL.property_value();
                        DataTable dt_property_value = bll_value.GetList(0, "property_id=" + dr["id"].ToString(), "add_time desc").Tables[0];
                        foreach (DataRow dr_value in dt_property_value.Rows)
                        {
                            DataRow new_dr_value = dt_property.NewRow();
                            new_dr_value["id"] = dr_value["id"];
                            new_dr_value["title"] = dr_value["value"];
                            new_dr_value["parent_id"] = dr["id"];
                            dt_property.Rows.Add(new_dr_value);
                        }
                    }

                    if (dt_property != null && dt_property.Rows.Count > 0)
                    {
                        ds.Tables.Add(dt_property.Copy());
                    }

                }
            }

            DataTable dt_page = new DataTable();
            dt_page.Columns.Add("page");
            dt_page.TableName = "dt_page";
            BasePage _basepage = new BasePage();//(page, pagesize, category, property, order, keyword, flag)
            DataRow dr_page = dt_page.NewRow();
            dr_page["page"] = myJson.String2Json(_basepage.get_page_links(pagesize, page, totalcount, "javascript:get_good_list(__id__,12,'" + category + "','" + property + "','" + order + "','" + keyword + "','" + flag + "')"));
            dt_page.Rows.Add(dr_page);

            if (dt_page != null && dt_page.Rows.Count > 0)
            {
                ds.Tables.Add(dt_page);
            }

            if (ds != null && ds.Tables.Count > 0)
            {
                context.Response.Write(myJson.getJson(ds));
                return;
            }
            else
            {
                context.Response.Write("Null");
                return;
            }
        }
Example #7
0
        private void get_prop_page(HttpContext context)
        {
            try
            {
                StringBuilder strhtml = new StringBuilder();
                int category = DTRequest.GetFormInt("category", 0);
                int page = DTRequest.GetFormInt("page", 1);

                BLL.property pro = new BLL.property();
                BLL.property_value pro_value = new BLL.property_value();

                BLL.article_category catgory = new BLL.article_category();
                string category_ids = "";
                DataTable dt_pro = null;
                if (category == 0)
                    dt_pro = pro.GetList("").Tables[0];
                else
                {
                    DataTable cat_dt = catgory.GetList(0, 2, category.ToString());//查找类别下的所有类别
                    if (cat_dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < cat_dt.Rows.Count; i++)
                        {
                            category_ids += cat_dt.Rows[i][0].ToString() + ",";
                        }
                        category_ids = category_ids.Substring(0, category_ids.Length - 1);
                    }
                    dt_pro = pro.GetList("category_id in(" + category_ids + ")").Tables[0];
                }
                if (dt_pro.Rows.Count > 0)
                {
                    for (int i = 0; i < dt_pro.Rows.Count; i++)
                    {
                        strhtml.Append("<dl>");
                        strhtml.Append("<dt>" + dt_pro.Rows[i]["title"] + "</dt>");
                        DataTable dt_pro_value = pro_value.GetList("property_id='" + dt_pro.Rows[i][0] + "'").Tables[0];
                        if (dt_pro_value.Rows.Count > 0)
                        {
                            for (int j = 0; j < dt_pro_value.Rows.Count; j++)
                            {
                                strhtml.Append("<dd><a style=\"cursor:pointer;\" onclick='getpagedata(" + dt_pro_value.Rows[j][0] + "," + category + "," + page + ")'>" + dt_pro_value.Rows[j]["value"] + "</a><span></span></dd>");
                            }
                        }
                        strhtml.Append("</dl>");
                    }
                    context.Response.Write("{ \"info\":\"获取数据成功!\", \"status\":\"1\" ,\"html\":\"" + myJson.String2Json(strhtml.ToString()) + "\",\"pagelist\":\"\"}");
                    return;
                }
                context.Response.Write("{ \"info\":\"该类别暂未添加属性!\", \"status\":\"0\" }");
            }
            catch (Exception ex)
            {
                context.Response.Write("{ \"info\":\"该类别暂未添加属性!\", \"status\":\"0\" }");
                return;
            }
        }