protected void grdArticles_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            DBA.NewArticle article = new DBA.NewArticle(ConfigurationManager.ConnectionStrings["DBConnection"].ToString());
            string[] str = e.CommandArgument.ToString().Split(',');
            article.ArticleId = int.Parse(str[0]);
            if (e.CommandName == "Del")
            {
                if (article.insertArticle(20))
                {
                    if (!string.IsNullOrEmpty(str[1]))
                    {
                        System.IO.File.Delete(Server.MapPath(str[1]));
                    }
                    BindGrid();
                }
            }
            else if (e.CommandName == "Ed")
            {
                string strURL = "NewArticle.aspx?Artid=";

                if (HttpContext.Current != null)
                {
                    HttpContext.Current.Response.Redirect(strURL + Server.UrlEncode(Common.Encrypt(e.CommandArgument.ToString())));
                }

            }
        }
 protected void BindGrid()
 {
     DBA.NewArticle article = new DBA.NewArticle(ConfigurationManager.ConnectionStrings["DBConnection"].ToString());
     article.UserFId = int.Parse(Session["UserID"].ToString());
     DataTable dt = article.getData(2);
     grdArticles.DataSource = dt;
     grdArticles.DataBind();
 }
 protected void BindCategory()
 {
     DBA.NewArticle newArticle = new DBA.NewArticle(ConfigurationManager.ConnectionStrings["DBConnection"].ToString());
     DataTable dt = newArticle.getData(1);
     ddlCategory.DataSource = dt;
     ddlCategory.DataValueField = "ID";
     ddlCategory.DataTextField = "CategoryName";
     ddlCategory.DataBind();
 }
 protected void AssignValues(int ArticleID)
 {
     DBA.NewArticle newArticle = new DBA.NewArticle(ConfigurationManager.ConnectionStrings["DBConnection"].ToString());
     newArticle.ArticleId = ArticleID;
     DataTable dt = newArticle.getData(3);
     ddlCategory.DataSource = dt;
     if (dt.Rows.Count > 0)
     {
         txtTitle.Text = dt.Rows[0]["Title"].ToString();
         txtDescription.Text = dt.Rows[0]["Description"].ToString();
         ViewState["ImgPath"] = dt.Rows[0]["ImgPath"].ToString();
         ddlCategory.SelectedValue = dt.Rows[0]["CategoryFId"].ToString();
         BtnSubmit.Text = "Update";
         UpdatePanel1.Update();
     }
 }
        protected void LoadArticles()
        {
            DBA.NewArticle article = new DBA.NewArticle(ConfigurationManager.ConnectionStrings["DBConnection"].ToString());
            DataTable dt = article.getData(7);
            StringBuilder strHTML = new StringBuilder();
            int cnt = dt.Rows.Count;
            if (cnt > 0)
            {

                int rowcnt = cnt / 5;
                if (cnt % 5 != 0)
                {
                    rowcnt = rowcnt + 1;
                }
                int k = 0;

                for (int i = 1; i <= rowcnt; i++)
                {
                    strHTML.Append("<div class=\"item\">");
                    for (int j = k; j < cnt; j++)
                    {
                        strHTML.Append("<div class=\"column\"><div class=\"inner\"><div class=\"image\">");
                        strHTML.Append("<a href=\"ArticleDetails.aspx?id=" + Common.Encrypt(dt.Rows[j]["ID"].ToString()) + "\"><img alt=\"\" src=" + dt.Rows[j]["ImgPath"] + " /></a></div>");
                        strHTML.Append("<h3><a href=\"ArticleDetails.aspx?id=" + Common.Encrypt(dt.Rows[j]["ID"].ToString()) + "\">" + dt.Rows[j]["Title"] + "</a></h3></div></div>");
                        if (i * 5 == j + 1)
                        {
                            k = j + 1;
                            break;
                        }
                    }
                    strHTML.Append("<div class=\"clear\"></div></div>");
                }

            }
            featured_slider.InnerHtml = strHTML.ToString();
        }
        protected bool InsertArticle()
        {
            int task = 0;
            DBA.NewArticle newArticle = new DBA.NewArticle(ConfigurationManager.ConnectionStrings["DBConnection"].ToString());
            if (BtnSubmit.Text == "Submit")
            {
                task = 10;
            }
            else if (BtnSubmit.Text == "Update")
            {
                task = 21;
                newArticle.ArticleId = int.Parse(ViewState["Artid"].ToString());
            }

            newArticle.UserFId = int.Parse(Session["UserID"].ToString());
            newArticle.Title = txtTitle.Text.Trim();
            newArticle.Description = txtDescription.Text.Trim();
            if (ddlCategory.SelectedIndex > 0)
            {
                newArticle.CategoryFId = int.Parse(ddlCategory.SelectedValue);
            }
            if (UploadImge.HasFile)
            {
                newArticle.ImgPath = "ArticleImages/" + Guid.NewGuid() + ".jpg";
                string mappedPath = Server.MapPath(newArticle.ImgPath);
                UploadImge.SaveAs(mappedPath);
            }
            else
            {
                if (task == 21)
                {
                    newArticle.ImgPath = ViewState["ImgPath"].ToString();
                }
            }
            if (newArticle.insertArticle(task))
            {
                return true;
            }
            return false;
        }