/// <summary>
        /// 绑定数据
        /// </summary>
        /// <param name="id"></param>
        private void Bind(int id)
        {
            ShowShop.BLL.Product.Productclass data = new ShowShop.BLL.Product.Productclass();
            ShowShop.Model.Product.Productclass model = data.GetModelID(id);
            if (model != null)
            {
                //this.returnLink.NavigateUrl = "productclass_list.aspx?w_d_fatherid=" + model.Fatherid.ToString();
                this.returnLinkBottom.NavigateUrl = "productclass_list.aspx?w_d_fatherid=" + model.Fatherid.ToString();
                this.hffatherid.Value = model.Fatherid.ToString();
                this.hfparentpath.Value = model.Parentpath;
                this.txtDescription.Text = model.Description;
                this.txtName.Text = model.Name;
                this.txtSort.Text = model.Sort.ToString();
                //this.rdolstIsRecommend.SelectedValue = model.Isrecommend.ToString();
                //this.txtContentPageTemplate.Text= model.Contenttemplate ;
                //this.txtListPageTemplate.Text = model.Listtemplate;
                //this.txtWebPagePath.Text=model.Sectiontemplate ;
                //this.ddlProductType.SelectedValue = model.ProductTypeId.ToString();
                model = data.GetModelID(Convert.ToInt32(model.Fatherid));
                if (model != null)
                {
                    this.ddlTheirclass.Items.Add(new ListItem(model.Name, id.ToString()));
                }
                else
                {
                    this.ddlTheirclass.Items.Add(new ListItem("顶级分类", id.ToString()));
                }
            }

            model = null;
        }
 private void Judge(string cid)
 {
     ShowShop.BLL.Product.Productclass probll = new ShowShop.BLL.Product.Productclass();
     DataTable dt = probll.GetFatherList(int.Parse(cid));
     if (dt.Rows.Count > 0)
     {
         Response.Write("该子类下还存在分类,请选择下级分类!");
     }
     else
     {
         Response.Write("ok");
     }
 }
        /// <summary>
        /// 列表
        /// </summary>
        /// <returns></returns>
        protected string GetList()
        {
            ChangeHope.WebPage.Table table = new ChangeHope.WebPage.Table();
            ShowShop.BLL.Product.Productclass data = new ShowShop.BLL.Product.Productclass();
            ChangeHope.DataBase.DataByPage dataPage = data.GetList();
            //第一步先添加表头
            table.AddHeadCol("5%", "序号");
            table.AddHeadCol("35%", "分类名称");
               // table.AddHeadCol("25%", "商品类型");
            table.AddHeadCol("10%", "排序");
               // table.AddHeadCol("5%", "状态");
            table.AddHeadCol("20%", "操作");
            table.AddRow();
            //添加表的内容
            if (dataPage.DataReader != null)
            {
                int curpage = ChangeHope.WebPage.PageRequest.GetInt("pageindex");
                if (curpage < 0)
                {
                    curpage = 1;
                }
                int count = 0;
                while (dataPage.DataReader.Read())
                {
                    count++;
                    string No = (15 * (curpage - 1) + count).ToString();
                    table.AddCol(No);
                    table.AddCol(string.Format("<a href='?w_d_fatherid={0}'>{1}</a>", dataPage.DataReader["cid"].ToString(), dataPage.DataReader["name"].ToString()));
                  //  table.AddCol(dataPage.DataReader["TypeName"].ToString());
                    table.AddCol(string.Format("<input id='sort{0}' value='{1}' size='5' onblur='Sort({0},{1})'/>", dataPage.DataReader["cid"].ToString(), dataPage.DataReader["sort"].ToString()));
                   // table.AddCol(string.Format("<img src='../images/{0}.gif' alt='推荐与否'/>", dataPage.DataReader["isrecommend"].ToString()));
                    table.AddCol(string.Format("<a href=productclass_edit.aspx?id={0}>编辑</a> <a href='#' onclick='Del({0})'>删除</a> <a href=productclass_edit.aspx?fatherid={0}>添加子分类</a>", dataPage.DataReader["cid"].ToString()));

                    table.AddRow();
                }
            }
            string view = table.GetTable() + dataPage.PageToolBar;
            dataPage.Dispose();
            dataPage = null;
            return view;
        }
 /// <summary>
 /// 获取分类名称
 /// </summary>
 /// <param name="strId"></param>
 /// <returns></returns>
 protected string ProductClassName(string strId)
 {
     string reStr = string.Empty;
     if (!string.IsNullOrEmpty(strId))
     {
         ShowShop.BLL.Product.Productclass dll = new ShowShop.BLL.Product.Productclass();
         DataTable dt = dll.GetMoreThanClassName(strId);
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             if (!string.IsNullOrEmpty(reStr))
             {
                 reStr = reStr + "," + dt.Rows[i]["name"].ToString();
             }
             else
             {
                 reStr = dt.Rows[i]["name"].ToString();
             }
         }
     }
     return reStr;
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                InitWebControl();

                #region 编辑绑定数据
                if (ChangeHope.WebPage.PageRequest.GetInt("id") >0 )
                {
                    Bind(ChangeHope.WebPage.PageRequest.GetInt("id"));
                }
                #endregion
                #region 新增分类
                if (ChangeHope.WebPage.PageRequest.GetInt("fatherid") > 0)
                {
                    int fatherid=ChangeHope.WebPage.PageRequest.GetInt("fatherid") ;
                    ShowShop.BLL.Product.Productclass data = new ShowShop.BLL.Product.Productclass();
                    ShowShop.Model.Product.Productclass model = data.GetModelID(fatherid);
                    if (model != null)
                    {
                        this.ddlTheirclass.Items.Add(new ListItem(model.Name, "0"));
                        this.hffatherid.Value = fatherid.ToString();
                        this.hfparentpath.Value =model.Parentpath+","+fatherid;
                    }
                  // this.returnLink.NavigateUrl = "productclass_list.aspx?w_d_fatherid=" + fatherid;
                    this.returnLinkBottom.NavigateUrl = "productclass_list.aspx?w_d_fatherid=" + fatherid;
                }
                else if (ChangeHope.WebPage.PageRequest.GetInt("fatherid") == 0)
                {
                    this.ddlTheirclass.Items.Add(new ListItem("顶级分类","0"));
                    this.hffatherid.Value = "0";
                    this.hfparentpath.Value = "0";
                   // this.returnLink.NavigateUrl = "productclass_list.aspx?w_d_fatherid=0";
                    this.returnLinkBottom.NavigateUrl = "productclass_list.aspx?w_d_fatherid=0";
                }
                #endregion

            }
        }
 /// <summary>
 /// 导航
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 protected string GetToolBar(int id)
 {
     StringBuilder toolbar = new StringBuilder();
     toolbar.AppendLine("<a href='?w_d_fatherid=0'>顶级分类</a>");
     ShowShop.BLL.Product.Productclass data = new ShowShop.BLL.Product.Productclass();
     ShowShop.Model.Product.Productclass model = data.GetModelID(id);
     if (model != null)
     {
         string Currently=string.Format(">> <a href='?w_d_fatherid={0}'>{1}</a>  ", model.ID, model.Name);
         string[] parentPath =model.Parentpath.Split(',');
         for (int i = 0; i < parentPath.Length; i++)
         {
             model = data.GetModelID(Convert.ToInt32(parentPath[i]));
             if (model != null)
             {
                 toolbar.AppendFormat(">> <a href='?w_d_fatherid={0}'>{1}</a>  ", model.ID, model.Name);
             }
         }
         toolbar.Append(Currently);
     }
     toolbar.Append("&nbsp;|&nbsp;<a href='productclass_edit.aspx?fatherid=" + id + "'>添加同分类</a>");
     return toolbar.ToString();
 }
        private void Save()
        {
            ShowShop.BLL.Product.Productclass data = new ShowShop.BLL.Product.Productclass();
            ShowShop.Model.Product.Productclass model = new ShowShop.Model.Product.Productclass();
            model.ID = ChangeHope.Common.StringHelper.StringToInt(this.ddlTheirclass.SelectedValue);
            model.Fatherid = ChangeHope.Common.StringHelper.StringToInt(this.hffatherid.Value);
            model.Name = this.txtName.Text;
            model.Description = this.txtDescription.Text;
            model.Sort = ChangeHope.Common.StringHelper.StringToInt(this.txtSort.Text);
               // model.Isrecommend = ChangeHope.Common.StringHelper.StringToInt(this.rdolstIsRecommend.SelectedValue);
            model.Parentpath = this.hfparentpath.Value;
            //model.Contenttemplate = this.txtContentPageTemplate.Text;
            //model.Listtemplate = this.txtListPageTemplate.Text;
            //model.Sectiontemplate = this.txtWebPagePath.Text;
            //model.ProductTypeId = Convert.ToInt32(this.ddlProductType.SelectedValue);
            if (model.ID > 0)
            {
                ShowShop.Common.PromptInfo.Popedom("001001004", "对不起,您没有权限进行编辑");
                data.Update(model);
                this.ltlMsg.Text = "操作成功, 已保存该信息.";
                this.pnlMsg.Visible = true;
                this.pnlMsg.CssClass = "actionOk";

            }
            else
            {
                ShowShop.Common.PromptInfo.Popedom("001001002", "对不起,您没有权限进行新增");
                data.Add(model);
                this.ltlMsg.Text = "操作成功,已保存该信息.";
                this.pnlMsg.Visible = true;
                this.pnlMsg.CssClass = "actionOk";

            }
        }
 /// <summary>
 /// 修改排列顺序
 /// </summary>
 /// <param name="id"></param>
 /// <param name="sort"></param>
 private void sort(int id, int sort)
 {
     ShowShop.BLL.Product.Productclass bll = new ShowShop.BLL.Product.Productclass();
     bll.Amend(id, "sort", sort);
     Response.Write("ok");
 }
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="id"></param>
 private void del(int id)
 {
     ShowShop.BLL.Product.Productclass bll = new ShowShop.BLL.Product.Productclass();
     DataTable dt = bll.GetFatherList(id);
     if (dt.Rows.Count > 0)
     {
         Response.Write("该分类还有下级分类,请删除下级分类!");
     }
     else
     {
         bll.Delete(id);
     }
 }