private void UpdateCategoryItems()
        {
            //if category is being deleted or deactivated, unassign and deactivate all items belonging to the category
            BPArticles bpArticles = new BPArticles();
            BEArticles dsArticles = bpArticles.SelectByArticleCategoryID(ArticleCategoryID);

            foreach (BEArticles.tbl_ArticlesRow row in dsArticles.tbl_Articles)
            {
                row.ArticleCategoryID = 0;
                row.ArticleActive = false;
            }
            bpArticles.Update(dsArticles);
        }
Esempio n. 2
0
        private void SaveArticleInfo()
        {
            bool isNew = false;
            BPArticles bp = new BPArticles();
            BEArticles dsArticles = new BEArticles();
            BEArticles.tbl_ArticlesRow article = null;

            int tempImageID1 = 0;
            int tempImageID2 = 0;

            if (ArticleID > 0)
            {
                dsArticles = bp.SelectArticleByID(ArticleID);
                article = dsArticles.tbl_Articles.FindByArticleID(ArticleID);

                if (!article.IsArticleImageID1Null())
                    tempImageID1 = article.ArticleImageID1;

                if (!article.IsArticleImageID2Null())
                    tempImageID2 = article.ArticleImageID2;
            }

            if (article == null)
            {
                article = dsArticles.tbl_Articles.Newtbl_ArticlesRow();
                isNew = true;
            }

            //page
            article.ArticleTitle = txtArticleTitle.Text.Trim();
            article.ArticleCategoryID = Convert.ToInt32(ddlCategories.SelectedValue);

            if (dtArticleDate.Date != dtArticleDate.MinDate)
                article.ArticleDate = dtArticleDate.Date;
            else
                article.SetArticleDateNull();

            if (edtBody1.Text.Trim() == "" || edtBody1.Text.Trim() == "<p>&nbsp;</p>")
                article.SetArticleBody1Null();
            else
                article.ArticleBody1 = edtBody1.Text.Trim();

            if (edtBody2.Text.Trim() == "" || edtBody2.Text.Trim() == "<p>&nbsp;</p>")
                article.SetArticleBody2Null();
            else
                article.ArticleBody2 = edtBody2.Text.Trim();

            //image 1
            if (imgArticleImageID1.SelectedImage > 0)
            {
                article.ArticleImageID1 = imgArticleImageID1.SelectedImage;
                if (ddlArticleImageAlignment1.SelectedValue == "Left" || ddlArticleImageAlignment1.SelectedValue == "Right" || ddlArticleImageAlignment1.SelectedValue == "Top" || ddlArticleImageAlignment1.SelectedValue == "Bottom")
                    article.ArticleImageAlignment1 = Convert.ToInt32(Enum.Parse(typeof(ImageAlignment), ddlArticleImageAlignment1.SelectedValue));
                else
                    article.SetArticleImageAlignment1Null();
            }
            else
            {
                article.SetArticleImageID1Null();
                article.SetArticleImageAlignment1Null();
            }

            //image 2
            if (imgArticleImageID2.SelectedImage > 0)
            {
                article.ArticleImageID2 = imgArticleImageID2.SelectedImage;
                if (ddlArticleImageAlignment2.SelectedValue == "Left" || ddlArticleImageAlignment2.SelectedValue == "Right" || ddlArticleImageAlignment2.SelectedValue == "Top" || ddlArticleImageAlignment2.SelectedValue == "Bottom")
                    article.ArticleImageAlignment2 = Convert.ToInt32(Enum.Parse(typeof(ImageAlignment), ddlArticleImageAlignment2.SelectedValue));
                else
                    article.SetArticleImageAlignment2Null();
            }
            else
            {
                article.SetArticleImageID2Null();
                article.SetArticleImageAlignment2Null();
            }

            //external article
            if (rblExternalArticle.SelectedValue == "True")
            {
                article.ExternalArticle = true;
                if (txtExternalURL.Text.Trim() != "")
                {
                    if (txtExternalURL.Text.Trim().Length < 8)
                        article.ExternalURL = "http://" + txtExternalURL.Text.Trim();
                    else if (txtExternalURL.Text.Trim().Substring(0, 7) != "http://" && txtExternalURL.Text.Trim().Substring(0, 8) != "https://")
                        article.ExternalURL = "http://" + txtExternalURL.Text.Trim();
                    else
                        article.ExternalURL = txtExternalURL.Text.Trim();

                }
                else
                    article.SetExternalURLNull();
            }
            else
            {
                article.ExternalArticle = false;
                article.SetExternalURLNull();
            }

            if (noBrowsePage)
                article.ArticleActive = true;
            else
                article.ArticleActive = chkArticleActive.Checked;

            article.DateModified = DateTime.Now;
            article.ModifiedByAdminID = PageUserID;

            if (isNew)
            {
                article.ArticleTypeID = SubTypeID;
                article.DateCreated = DateTime.Now;
                dsArticles.tbl_Articles.Addtbl_ArticlesRow(article);
            }

            bp.Update(dsArticles);
            ArticleID = article.ArticleID;

            if (isNew)
            {
                //Add to main Pages table
                BPPages bpPages = new BPPages();
                BEPages dsPages = new BEPages();
                BEPages.tbl_PagesRow pageRow = dsPages.tbl_Pages.Newtbl_PagesRow();

                pageRow.PageTypeID = PageTypeID;
                pageRow.PageTypeSpecificID = ArticleID;
                pageRow.SubTypeID = SubTypeID;

                dsPages.tbl_Pages.Addtbl_PagesRow(pageRow);
                bpPages.Update(dsPages);
            }

            //Resize images
            int[] selectedImageIDs = new int[2];
            bool doResize = false;

            if (!article.IsArticleImageID1Null() && (article.ArticleImageID1 != tempImageID1))
            {
                selectedImageIDs[0] = imgArticleImageID1.SelectedImage;
                doResize = true;
            }

            if (!article.IsArticleImageID2Null() && (article.ArticleImageID2 != tempImageID2))
            {
                selectedImageIDs[1] = imgArticleImageID2.SelectedImage;
                doResize = true;
            }

            if (doResize)
                ResizePageImages(selectedImageIDs);
        }
Esempio n. 3
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            BPArticles bpArticles = new BPArticles();
            BEArticles dsArticles = bpArticles.SelectArticleByID(ArticleID);

            BPPages bpPages = new BPPages();
            BEPages dsPages = bpPages.SelectByPageTypeIDAndPageTypeSpecificID(PageTypeID, ArticleID);

            if (dsArticles.tbl_Articles.Count > 0)
            {
                dsArticles.tbl_Articles[0].Delete();
                bpArticles.Update(dsArticles);

                if (dsPages.tbl_Pages.Count > 0)
                {
                    dsPages.tbl_Pages[0].Delete();
                    bpPages.Update(dsPages);
                }
            }

            BrowseRedirect();
        }
Esempio n. 4
0
        private void BindArticleInfo()
        {
            if (noBrowsePage)
            {
                chkArticleActive.Enabled = false;
                btnDelete.Visible = false;
                txtArticleTitle.Enabled = false;
            }
            else
                chkArticleActive.Enabled = true;

            if (ArticleID > 0 || noBrowsePage)
            {
                BPArticles bp = new BPArticles();
                BEArticles ds;
                BEArticles.tbl_ArticlesRow article = null;

                if (noBrowsePage)
                    ds = bp.SelectByArticleTypeID(SubTypeID);
                else
                    ds = bp.SelectArticleByID(ArticleID);

                if (ds.tbl_Articles.Count > 0)
                {
                    article = ds.tbl_Articles[0];
                    if (noBrowsePage)
                        ArticleID = article.ArticleID;
                }

                if (article != null)
                {
                    lblTitle.Text = "Edit " + article.ArticleTitle;
                    txtArticleTitle.Text = article.ArticleTitle;

                    if (ddlCategories.Items.FindByValue(article.ArticleCategoryID.ToString()) != null)
                        ddlCategories.SelectedValue = article.ArticleCategoryID.ToString();

                    if (!article.IsArticleDateNull())
                        dtArticleDate.Date = article.ArticleDate;

                    if (!article.IsArticleBody1Null())
                        edtBody1.Text = article.ArticleBody1;
                    else
                        edtBody1.Text = "";

                    if (!article.IsArticleBody2Null())
                        edtBody2.Text = article.ArticleBody2;
                    else
                        edtBody2.Text = "";

                    if (!article.IsArticleImageID1Null())
                        imgArticleImageID1.SelectedImage = article.ArticleImageID1;

                    if (!article.IsArticleImageAlignment1Null())
                        ddlArticleImageAlignment1.SelectedValue = Enum.Parse(typeof(ImageAlignment), article.ArticleImageAlignment1.ToString()).ToString();

                    if (!article.IsArticleImageID2Null())
                        imgArticleImageID2.SelectedImage = article.ArticleImageID2;

                    if (!article.IsArticleImageAlignment2Null())
                        ddlArticleImageAlignment2.SelectedValue = Enum.Parse(typeof(ImageAlignment), article.ArticleImageAlignment2.ToString()).ToString();

                    rblExternalArticle.SelectedValue = article.ExternalArticle.ToString();
                    plcExternalURL.Visible = article.ExternalArticle;
                    txtExternalURL.Text = article.IsExternalURLNull() ? "" : article.ExternalURL;

                    chkArticleActive.Checked = article.ArticleActive;

                }
                else if (noBrowsePage)
                {
                    lblTitle.Text = "Edit " + SubTypeName;
                    edtBody1.Text = "";
                    edtBody2.Text = "";
                }
            }
            else
            {
                lblTitle.Text = "Add New " + SubTypeName;
                btnDelete.Visible = false;
                edtBody1.Text = "";
                edtBody2.Text = "";
            }
        }