protected void btnSave_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Request.QueryString["catId"]);
            CategoryBLL cb = new CategoryBLL();
            if (Request.QueryString["catId"] == null)
            {
                Category c = new Category();
                c.Name = txtName.Text;
                c.IsActive = true;
                c.Date = DateTime.Now;

                cb.Add(c);
            }

            else
            {
                Category c = cb.Get(x => x.Id == id).FirstOrDefault();
                c.Name = txtName.Text;
                c.IsActive = true;
                c.Date = DateTime.Now;
                cb.Update(c);
            }

            Response.Redirect("Categories.aspx");
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CategoryBLL cb = new CategoryBLL();

            rptCategories.DataSource = cb.Get(x => x.IsActive == true).ToList();
            rptCategories.DataBind();
        }
Esempio n. 3
0
        /// <summary>
        /// 分类页面
        /// </summary>
        /// <param name="tag"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public string Category(string tag, int page)
        {
            string   html     = String.Empty;
            Category category = cbll.Get(a => String.Compare(tag, a.Tag, true) == 0);

            if (category != null)
            {
                /*********************************
                *  @ 单页,跳到第一个特殊文档,
                *  @ 如果未设置则最新创建的文档,
                *  @ 如未添加文档则返回404
                *********************************/
                if (category.ModuleID == (int)SysModuleType.CustomPage)
                {
                    Archive a = bll.GetFirstSpecialArchive(category.ID);
                    if (a == null)
                    {
                        global::System.Data.DataTable dt = bll.GetArchives(category.ID, 1);
                        if (dt.Rows.Count == 1)
                        {
                            a = dt.Rows[0].ToEntity <Archive>();
                        }
                        else
                        {
                            return(base.Render404());
                        }
                    }

                    Response.StatusCode       = 302;
                    Response.RedirectLocation = String.Format("/{0}/{1}.html",
                                                              category.Tag,
                                                              String.IsNullOrEmpty(a.Alias) ? a.ID : a.Alias
                                                              );
                    Response.End();
                    return(null);
                }

                html = PageGenerator.ReturnGenerate(PageGeneratorObject.CategoryPage, category, page);
            }
            else
            {
                return(base.Render404());
            }

            return(html);
        }
 public CategoryEditForm(int id)
 {
     InitializeComponent();
     _categoryBLL = new CategoryBLL();
     _cat         = _categoryBLL.Get(id);
     isSave       = false;
     btnSave.Text = "Güncelle";
 }
Esempio n. 5
0
        /// <summary>
        /// 获取栏目文件路径,如/news/us/
        /// </summary>
        /// <param name="categoryID"></param>
        /// <param name="useHyperlink">是否加上超链接</param>
        /// <param name="linkFormat">链接格式,如/{0}/</param>
        /// <returns></returns>
        public static string GenerateSitemap(string categoryTag, string split, bool useHyperlink, string linkFormat)
        {
            int           i = 0, j = 0;
            string        categoryPath = null;
            StringBuilder sb           = new StringBuilder();
            Category      category     = categoryBLL.Get(a => String.Compare(a.Tag, categoryTag, true) == 0);

            //如果栏目不存在
            if (category == null)
            {
                return(String.Empty);
            }

            IList <Category> categories = new List <Category>(categoryBLL.GetCategories(category.Lft, category.Rgt, CategoryContainerOption.ParentsAndSelf));

            j = categories.Count;

            foreach (Category c in categories)
            {
                categoryPath = String.Format("{0}/{1}{2}", categoryPath, c.Tag, i < j ? "/" : "");

                //
                //TODO:如果启用多目录,则注释下行
                //
                //categoryPath = c.Tag;

                if (useHyperlink)
                {
                    sb.Append("<a href=\"")
                    .Append(String.Format(linkFormat, categoryPath))
                    .Append("\"");

                    //栏目的上一级添加不追踪特性
                    if (i < j - 2)
                    {
                        sb.Append(" rel=\"nofollow\"");
                    }
                    sb.Append(">").Append(c.Name).Append("</a>");
                }
                else
                {
                    sb.Append(c.Name);
                }

                //添加分隔符
                if (i < j - 1)
                {
                    sb.Append(split);
                }
                ++i;
            }

            //去掉双斜杠
            Regex reg = new Regex("\\b//");

            return(reg.Replace(sb.ToString(), "/"));
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     CategoryBLL cb=new CategoryBLL();
     if (IsPostBack) return;
     ddlCategories.DataValueField = "Id";
     ddlCategories.DataTextField = "Name";
     ddlCategories.DataSource = cb.Get(x => x.IsActive == true).ToList();
     ddlCategories.DataBind();
 }
        protected void rptCategories_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int categoryId = Convert.ToInt32(e.CommandArgument);

            CategoryBLL cb = new CategoryBLL();

            Category c = cb.Get(x => x.Id == categoryId).FirstOrDefault();

            c.IsActive = false;
            cb.Update(c);
            Fill();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack) return;
            if (Request.QueryString["catId"] != null)
            {
                int id = Convert.ToInt32(Request.QueryString["catId"]);
                CategoryBLL cb = new CategoryBLL();
                Category c = cb.Get(x => x.Id == id).FirstOrDefault();

                txtName.Text = c.Name;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Helper.Sayfalar = new List<string> { "Kategoriler", "Kategori Ekle" };

            if (IsPostBack) return;

            int id = Convert.ToInt32(Request.QueryString["catId"]);
            CategoryBLL cb = new CategoryBLL();
            if (Request.QueryString["catId"] != null)
            {

                Category c = cb.Get(x => x.Id == id).FirstOrDefault();
                txtCategoryName.Text = c.Name;
            }
        }
        private void silToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int      id     = (int)dgvCategories.SelectedRows[0].Cells[0].Value;
            Category cat    = _categoryBLL.Get(id);
            bool     result = _categoryBLL.Delete(cat);

            if (result)
            {
                MessageBox.Show("Silme gerçekleşti.");
            }
            else
            {
                MessageBox.Show("SİLİNEMEDİ.");
            }
            dgvCategories.DataSource = _categoryBLL.GetAll();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack) return;
            CategoryBLL cb = new CategoryBLL();
            ddlCategories.DataTextField = "Name";
            ddlCategories.DataValueField = "Id";
            ddlCategories.DataSource = cb.Get(x => x.IsActive == true).ToList();
            ddlCategories.DataBind();

            if (Request.QueryString["productId"]!=null)
            {
                int id = Convert.ToInt32(Request.QueryString["productId"]);
                ProductBLL pb = new ProductBLL();
                Product p = pb.Get(x => x.Id == id).FirstOrDefault();

                txtName.Text = p.Name;
                txtPrice.Text = p.Price.ToString();
                txtStock.Text = p.Stock.ToString();
                txtDetail.Text = p.Detail;
            }
        }
Esempio n. 12
0
        /// <summary>
        /// 栏目页面
        /// </summary>
        /// <param name="tag"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public void Category(string lang, string allcate)
        {
            string tag  = null;
            int    page = 1;

            Regex paramRegex = new Regex("/*([^/]+)/(p(\\d+).html)*$", RegexOptions.IgnoreCase);

            if (paramRegex.IsMatch(allcate))
            {
                Match mc = paramRegex.Match(allcate);

                tag = mc.Groups[1].Value;

                //计算页吗:页码如:p3
                if (mc.Groups[3].Value != "")
                {
                    page = int.Parse(mc.Groups[3].Value);
                }
            }
            else
            {
                base.RenderNotfound();
                return;
            }

            string   html     = String.Empty;
            Category category = cbll.Get(a => String.Compare(tag, a.Tag, true) == 0);

            if (category == null)
            {
                base.RenderNotfound();
                return;
            }
            else
            {
                //获取路径
                string categoryPath = ArchiveUtility.GetCategoryUrlPath(category);

                if (!allcate.StartsWith(categoryPath + "/"))
                {
                    base.RenderNotfound();
                    return;
                }

                /*********************************
                *  @ 单页,跳到第一个特殊文档,
                *  @ 如果未设置则最新创建的文档,
                *  @ 如未添加文档则返回404
                *********************************/
                if (category.ModuleID == (int)SysModuleType.CustomPage)
                {
                    Archive a = bll.GetFirstSpecialArchive(category.ID);
                    if (a == null)
                    {
                        global::System.Data.DataTable dt = bll.GetArchives(category.ID, 1);
                        if (dt.Rows.Count == 1)
                        {
                            a = dt.Rows[0].ToEntity <Archive>();
                        }
                        else
                        {
                            base.RenderNotfound("栏目下应确保有推荐的文档存在!");
                            return;
                        }
                    }
                    Response.StatusCode = 302;

                    Response.RedirectLocation = String.Format("/{0}/{1}/{2}.html",
                                                              lang,
                                                              categoryPath,
                                                              String.IsNullOrEmpty(a.Alias) ? a.ID : a.Alias
                                                              );
                    Response.End();
                    return;
                }

                html = cmsPage.GetCategory(category, page, lang);
            }

            base.Render(html);
        }
Esempio n. 13
0
 private void Fill()
 {
     CategoryBLL cb = new CategoryBLL();
     rptCategories.DataSource = cb.Get(x => x.IsActive == true).ToList();
     rptCategories.DataBind();
 }
Esempio n. 14
0
 public IHttpActionResult Get(int SiteID)
 {
     return(Ok(_CategoryService.Get(SiteID, User.Identity.GetUserId())));
 }
Esempio n. 15
0
        /// <summary>
        /// 列表页面
        /// </summary>
        /// <param name="tag"></param>
        /// <param name="page"></param>
        public void List(string tag, int page)
        {
            const int pageSize = 20;

            Category catalog = cbll.Get(a => a.Tag == tag);

            if (catalog == null)
            {
                Render404(); return;
            }

            string archiveListHtml,
                   pagedHtml,
                   keywords   = catalog.Keywords,
                   descripton = catalog.Description;

            int recordCount,
                pages;

            StringBuilder sb = new StringBuilder(800);

            User   m;
            int    i = 0, j;
            string membername;

            foreach (DataRow dr in bll.GetPagedArchives(catalog.ID, pageSize, page, out recordCount, out pages).Rows)
            {
                j          = i++ % 3;
                m          = ubll.GetUser(dr["author"].ToString());
                membername = m == null ? dr["author"].ToString() : m.Name;
                if (j == 1)
                {
                    membername = String.Format("<span style=\"color:green\">{0}</span>", membername);
                }
                else if (j == 2)
                {
                    membername = String.Format("<span style=\"color:#0066cc\">{0}</span>", membername);
                }

                sb.Append("<li><img src=\"/images/default_face.gif\" width=\"20\" height=\"20\" align=\"absmiddle\" /><span class=\"bbs1\">")
                .Append(membername).Append("&nbsp;</span><span class=\"cDGray\">").Append(String.Format("{0:MM月dd日}", dr["createdate"]))
                .Append("</span> 发布: <a href=\"/s_").Append(dr["id"].ToString()).Append("/\" target=\"_blank\" class=\"bbs1\">").Append(dr["title"].ToString())
                .Append("</a> [<span class=\"cDGray\">").Append(catalog.Name).Append("</span>]</li>");
            }

            archiveListHtml = sb.ToString();

            pagedHtml = OPS.Web.UI.PagedLinkBuilder.BuildPagerInfo("/" + catalog.Tag + "/", "/" + catalog.Tag + "/{0}/", page, recordCount, pages);


            //输出到页面
            PageUtility.Render("ba546efe2c0c5095",
                               new
            {
                catalogName     = catalog.Name,
                catalogTag      = catalog.Tag,
                pageTitle       = page == 1 ? "" : "(第" + page + "页)",
                archiveListHtml = archiveListHtml,
                pagedHtml       = pagedHtml,

                h_topics      = hotTopics,
                r_topics      = recommendTopics,
                h_companyinfo = companyInfo
            });
        }
Esempio n. 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Helper.Sepet != null)
            {
                ltrQuantiy.Text = Helper.Sepet.Count.ToString();
                decimal total = 0;
                foreach (var p in Helper.Sepet)
                {
                    total += p.Price * p.Quantity;
                }
                ltrTotal.Text = String.Format("{0:0.00}", total);
            }
            else
            {
                ltrQuantiy.Text = "0";
                ltrTotal.Text = "0";
            }

            if (IsPostBack) return;

            CategoryBLL cb = new CategoryBLL();

            rptCategories.DataSource = cb.Get(x => x.IsActive == true).ToList();
            rptCategories.DataBind();
        }