Exemplo n.º 1
0
 public static int InsertNewsCategory(NewsCategory newsCategory)
 {
     return(SQLDataAccess.ExecuteScalar <int>("Insert into [Settings].[NewsCategory] ([Name],[SortOrder],[UrlPath]) values (@Name,@SortOrder,@UrlPath); Select SCOPE_IDENTITY ();",
                                              CommandType.Text,
                                              new SqlParameter("@Name", newsCategory.Name),
                                              new SqlParameter("@UrlPath", newsCategory.UrlPath),
                                              new SqlParameter("@SortOrder", newsCategory.SortOrder)));
 }
Exemplo n.º 2
0
 public static void UpdateNewsCategory(NewsCategory newsCategory)
 {
     SQLDataAccess.ExecuteNonQuery("Update [Settings].[NewsCategory] set [Name]=@name,[UrlPath] = @UrlPath , [SortOrder] = @SortOrder where NewsCategoryID = @NewsCategoryID",
                                   CommandType.Text,
                                   new SqlParameter("@NewsCategoryID", newsCategory.NewsCategoryID),
                                   new SqlParameter("@Name", newsCategory.Name),
                                   new SqlParameter("@UrlPath", newsCategory.UrlPath),
                                   new SqlParameter("@SortOrder", newsCategory.SortOrder));
 }
Exemplo n.º 3
0
        public static int InsertNewsCategory(NewsCategory newsCategory)
        {
            var id = SQLDataAccess.ExecuteScalar <int>("Insert into [Settings].[NewsCategory] ([Name],[SortOrder],[UrlPath]) values (@Name,@SortOrder,@UrlPath); Select SCOPE_IDENTITY ();",
                                                       CommandType.Text,
                                                       new SqlParameter("@Name", newsCategory.Name),
                                                       new SqlParameter("@UrlPath", newsCategory.UrlPath),
                                                       new SqlParameter("@SortOrder", newsCategory.SortOrder));

            if (newsCategory.Meta != null)
            {
                if (!newsCategory.Meta.Title.IsNullOrEmpty() || !newsCategory.Meta.MetaKeywords.IsNullOrEmpty() || !newsCategory.Meta.MetaDescription.IsNullOrEmpty() || !newsCategory.Meta.H1.IsNullOrEmpty())
                {
                    newsCategory.Meta.ObjId = id;
                    MetaInfoService.SetMeta(newsCategory.Meta);
                }
            }
            return(id);
        }
Exemplo n.º 4
0
 public static void UpdateNewsCategory(NewsCategory newsCategory)
 {
     SQLDataAccess.ExecuteNonQuery("Update [Settings].[NewsCategory] set [Name]=@name,[UrlPath] = @UrlPath , [SortOrder] = @SortOrder where NewsCategoryID = @NewsCategoryID",
                                   CommandType.Text,
                                   new SqlParameter("@NewsCategoryID", newsCategory.NewsCategoryID),
                                   new SqlParameter("@Name", newsCategory.Name),
                                   new SqlParameter("@UrlPath", newsCategory.UrlPath),
                                   new SqlParameter("@SortOrder", newsCategory.SortOrder));
     if (newsCategory.Meta != null)
     {
         if (newsCategory.Meta.Title.IsNullOrEmpty() && newsCategory.Meta.MetaKeywords.IsNullOrEmpty() && newsCategory.Meta.MetaDescription.IsNullOrEmpty() && newsCategory.Meta.H1.IsNullOrEmpty())
         {
             if (MetaInfoService.IsMetaExist(newsCategory.NewsCategoryID, MetaType.NewsCategory))
             {
                 MetaInfoService.DeleteMetaInfo(newsCategory.NewsCategoryID, MetaType.NewsCategory);
             }
         }
         else
         {
             MetaInfoService.SetMeta(newsCategory.Meta);
         }
     }
 }
Exemplo n.º 5
0
 public static void UpdateNewsCategory(NewsCategory newsCategory)
 {
     SQLDataAccess.ExecuteNonQuery("Update [Settings].[NewsCategory] set [Name]=@name,[UrlPath] = @UrlPath , [SortOrder] = @SortOrder where NewsCategoryID = @NewsCategoryID",
                                                CommandType.Text,
                                                new SqlParameter("@NewsCategoryID", newsCategory.NewsCategoryID),
                                                new SqlParameter("@Name", newsCategory.Name),
                                                new SqlParameter("@UrlPath", newsCategory.UrlPath),
                                                new SqlParameter("@SortOrder", newsCategory.SortOrder));
 }
Exemplo n.º 6
0
 public static int InsertNewsCategory(NewsCategory newsCategory)
 {
     return SQLDataAccess.ExecuteScalar<int>("Insert into [Settings].[NewsCategory] ([Name],[SortOrder],[UrlPath]) values (@Name,@SortOrder,@UrlPath); Select SCOPE_IDENTITY ();",
                                                 CommandType.Text,
                                                 new SqlParameter("@Name", newsCategory.Name),
                                                 new SqlParameter("@UrlPath", newsCategory.UrlPath),
                                                 new SqlParameter("@SortOrder", newsCategory.SortOrder));
 }
Exemplo n.º 7
0
        protected void grid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DeleteCategory")
            {
                NewsService.DeleteNewsCategory(SQLDataHelper.GetInt(e.CommandArgument));
            }

            if (e.CommandName == "AddCategory")
            {
                try
                {
                    GridViewRow footer = grid.FooterRow;
                    if (!UrlService.IsAvalibleUrl(ParamType.NewsCategory, ((TextBox)footer.FindControl("txtNewUrlPath")).Text))
                    {
                        lblError.Text = Resource.Admin_SynonymExist;
                        lblError.Visible = true;
                        return;
                    }

                    var temp = new NewsCategory
                        {
                            Name = ((TextBox)footer.FindControl("txtNewName")).Text,
                            UrlPath = ((TextBox)footer.FindControl("txtNewUrlPath")).Text,
                            SortOrder = ((TextBox)footer.FindControl("txtNewSortOrder")).Text.TryParseInt()
                        };
                    NewsService.InsertNewsCategory(temp);
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }
                grid.ShowFooter = false;
            }

            if (e.CommandName == "CancelAdd")
            {
                grid.ShowFooter = false;
            }
        }
Exemplo n.º 8
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (grid.UpdatedRow != null)
            {
                try
                {
                    var temp = new NewsCategory
                        {
                            NewsCategoryID = grid.UpdatedRow["ID"].TryParseInt(),
                            Name = grid.UpdatedRow["Name"],
                            UrlPath = grid.UpdatedRow["UrlPath"],
                            SortOrder = grid.UpdatedRow["SortOrder"].TryParseInt()
                        };

                    if (!UrlService.IsAvalibleUrl(temp.NewsCategoryID, ParamType.NewsCategory, temp.UrlPath))
                    {
                        lblError.Text = Resource.Admin_SynonymExist;
                        lblError.Visible = true;
                        return;
                    }

                    NewsService.UpdateNewsCategory(temp);
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }
            }

            DataTable data = _paging.PageItems;
            while (data.Rows.Count < 1 && _paging.CurrentPageIndex > 1)
            {
                _paging.CurrentPageIndex--;
                data = _paging.PageItems;
            }

            var clmn = new DataColumn("IsSelected", typeof(bool)) { DefaultValue = _inverseSelection };
            data.Columns.Add(clmn);
            if ((_selectionFilter != null) && (_selectionFilter.Values != null))
            {
                for (int i = 0; i <= data.Rows.Count - 1; i++)
                {
                    int intIndex = i;
                    if (Array.Exists(_selectionFilter.Values, c => c == (data.Rows[intIndex]["ID"]).ToString()))
                    {
                        data.Rows[i]["IsSelected"] = !_inverseSelection;
                    }
                }
            }

            if (data.Rows.Count < 1)
            {
                goToPage.Visible = false;
            }

            grid.DataSource = data;
            grid.DataBind();

            pageNumberer.PageCount = _paging.PageCount;
            lblFound.Text = _paging.TotalRowsCount.ToString();
        }