protected DataView GetData()
        {
            BPArticleCategories bp = new BPArticleCategories();
            DSArticleCategories = bp.SelectByArticleTypeID(SubTypeID);

            DSArticleCategories.tbl_ArticleCategories.DefaultView.Sort = DSArticleCategories.tbl_ArticleCategories.ArticleCategoryOrderColumn.ColumnName;
            BindMoveControl(DSArticleCategories.tbl_ArticleCategories.DefaultView);

            DSArticleCategories.tbl_ArticleCategories.DefaultView.RowFilter = 
                    RowFilter(DSArticleCategories.tbl_ArticleCategories.ArticleCategoryNameColumn.ColumnName, 
                               ((LinkButton)rptLetters.Items[0].FindControl("lnkLetter")).CommandName, 
                                DSArticleCategories.tbl_ArticleCategories.ArticleCategoryActiveColumn.ColumnName, 
                                lstActive.SelectedValue);

            return DSArticleCategories.tbl_ArticleCategories.DefaultView;
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            BPArticleCategories bp = new BPArticleCategories();
            BEArticles ds = bp.SelectByID(ArticleCategoryID);
            BEArticles.tbl_ArticleCategoriesRow category = ds.tbl_ArticleCategories.FindByArticleCategoryID(ArticleCategoryID);

            if (category != null)
            {
                UpdateCategoryItems();

                category.Delete();
                bp.Update(ds);
            }

            BrowseRedirect();
        }
        private void SaveCategoryInfo()
        {
            bool isNew = false;
            BPArticleCategories bp = new BPArticleCategories();
            BEArticles ds = new BEArticles();
            BEArticles.tbl_ArticleCategoriesRow category = null;

            if (ArticleCategoryID > 0)
            {
                ds = bp.SelectByID(ArticleCategoryID);
                category = ds.tbl_ArticleCategories.FindByArticleCategoryID(ArticleCategoryID);

                if (category.ArticleCategoryActive && (!chkArticleCategoryActive.Checked))
                    UpdateCategoryItems();
            }

            if (category == null)
            {
                category = ds.tbl_ArticleCategories.Newtbl_ArticleCategoriesRow();
                isNew = true;
            }

            category.ArticleCategoryName = txtArticleCategoryName.Text.Trim();

            if (txtArticleCategoryDescription.Text.Trim() != "")
                category.ArticleCategoryDescription = txtArticleCategoryDescription.Text.Trim();
            else
                category.SetArticleCategoryDescriptionNull();

            category.ArticleTypeID = SubTypeID;
            category.ArticleCategoryActive = chkArticleCategoryActive.Checked;
            category.DateModified = DateTime.Now;
            category.ModifiedByAdminID = PageUserID;

            if (isNew)
            {
                category.ArticleCategoryOrder = bp.GetArticleCategoryMaxOrder(SubTypeID);
                category.DateCreated = DateTime.Now;
                ds.tbl_ArticleCategories.Addtbl_ArticleCategoriesRow(category);
            }

            bp.Update(ds);
        }
        private void BindArticleCategories()
        {
            if (ArticleCategoryID != 0)
            {
                BPArticleCategories bp = new BPArticleCategories();
                BEArticles dsArticleCategories = bp.SelectByID(ArticleCategoryID);
                BEArticles.tbl_ArticleCategoriesRow category = null;
                    
                if (dsArticleCategories.tbl_ArticleCategories.Count > 0)
                {
                    category = dsArticleCategories.tbl_ArticleCategories[0];

                    txtArticleCategoryName.Text = category.ArticleCategoryName;
                    txtArticleCategoryDescription.Text = (category.IsArticleCategoryDescriptionNull()) ? "" : category.ArticleCategoryDescription;
                    chkArticleCategoryActive.Checked = category.ArticleCategoryActive;

                    lblTitle.Text = "Edit " + SubTypeName + " Category - " + category.ArticleCategoryName;

                }
            }
            else
            {
                btnDelete.Visible = false;
                lblTitle.Text = "Add " + SubTypeName + " Category";
            }
        }
        protected void btnMove_Click(object sender, EventArgs e)
        {
            bool found1 = false, found2 = false;
            int Position = Convert.ToInt32(ddlPosition.SelectedValue);
            int ItemToMove = Convert.ToInt32(ddlItemToMove.SelectedValue);

            BPArticleCategories bp = new BPArticleCategories();
            BEArticles ds = bp.SelectByArticleTypeID(SubTypeID);
            BEArticles.tbl_ArticleCategoriesRow[] categoryRows =
                (BEArticles.tbl_ArticleCategoriesRow[])ds.tbl_ArticleCategories.Select("", ds.tbl_ArticleCategories.ArticleCategoryOrderColumn.ColumnName);

            BEArticles.tbl_ArticleCategoriesRow moveCategory = ds.tbl_ArticleCategories.FindByArticleCategoryID(ItemToMove);

            foreach (BEArticles.tbl_ArticleCategoriesRow category in categoryRows)
            {
                if (found1 && found2)
                    break;

                if (category.ArticleCategoryID == moveCategory.ArticleCategoryID)
                {
                    found1 = true;

                    if (category.ArticleCategoryID == Position)
                        found2 = true;

                }
                else if (category.ArticleCategoryID == Position)
                {
                    found2 = true;

                    if (rblBeforeAfter.SelectedValue == "0")
                    {
                        moveCategory.ArticleCategoryOrder = category.ArticleCategoryOrder;
                        category.ArticleCategoryOrder++;
                    }
                    else
                    {
                        if (found1)
                            category.ArticleCategoryOrder--;

                        moveCategory.ArticleCategoryOrder = category.ArticleCategoryOrder + 1;
                    }
                }
                else if (found1 && !found2)
                    category.ArticleCategoryOrder--;

                else if (found2 && !found1)
                    category.ArticleCategoryOrder++;

            }

            bp.Update(ds);

            dgArticleCategories.DataSource = GetData();
            dgArticleCategories.DataBind();
        }
Exemplo n.º 6
0
        private void BindArticleCategories()
        {
            BPArticleCategories bp = new BPArticleCategories();
            BEArticles ds = bp.SelectActiveByArticleTypeID(SubTypeID);

            ds.tbl_ArticleCategories.DefaultView.Sort =
                    ds.tbl_ArticleCategories.ArticleCategoryOrderColumn.ColumnName;

            ddlCategories.DataSource = ds.tbl_ArticleCategories.DefaultView;
            ddlCategories.DataTextField = ds.tbl_ArticleCategories.ArticleCategoryNameColumn.ColumnName;
            ddlCategories.DataValueField = ds.tbl_ArticleCategories.ArticleCategoryIDColumn.ColumnName;
            ddlCategories.DataBind();
            ddlCategories.Items.Insert(0, new ListItem("(Select Category)", "0"));

        }