//Handles insert article public void Update_Article(Object s, EventArgs e) { //Instantiate database field ArticleInfo UpdateArticle = new ArticleInfo(); UpdateArticle.ID = (int)Util.Val(Request.QueryString["aid"]); UpdateArticle.Title = Request.Form["Title"]; UpdateArticle.Content = Request.Form["Content"]; UpdateArticle.Author = Request.Form["Author"]; UpdateArticle.CatID = int.Parse(Request.Form["CAT_ID"]); UpdateArticle.Keyword = Request.Form["Keyword"]; UpdateArticle.Summary = Request.Form["Summary"]; Caching.PurgeCacheItems("Newest_Articles"); //Notify user if error occured. if (UpdateArticle.Update() != 0) { JSLiteral.Text = Util.JSProcessingErrorAlert; return; } //Release allocated memory UpdateArticle = null; //If success, redirect to article update confirmation page. Util.PageRedirect(7); Util = null; }
public void Finalize_EditSubmission(Object s, EventArgs e) { //Instantiate database field ArticleInfo EditSubmission = new ArticleInfo(); EditSubmission.ID = (int)Util.Val(Request.QueryString["aid"]); EditSubmission.Title = Request.Form["Title"]; EditSubmission.Content = Request.Form["Content"]; EditSubmission.Author = Request.Form["Author"]; EditSubmission.CatID = int.Parse(Request.Form["CAT_ID"]); EditSubmission.Keyword = Request.Form["Keyword"]; EditSubmission.Summary = Request.Form["Summary"]; //Notify user if error occured. if (EditSubmission.Update() != 0) { JSLiteral.Text = Util.JSProcessingErrorAlert; return; } Response.Redirect("articlepreview.aspx?aid=" + EditSubmission.ID); //Release allocated memory EditSubmission = null; Util = null; }
public void Finalize_EditSubmission(Object s, EventArgs e) { //Instantiate database field ArticleInfo EditSubmission = new ArticleInfo(); EditSubmission.ID = (int)Util.Val(Request.QueryString["aid"]); EditSubmission.Title = Request.Form["Title"]; EditSubmission.Content = Request.Form["Content"]; EditSubmission.Author = Request.Form["Author"]; EditSubmission.CatID = int.Parse(Request.Form["CAT_ID"]); EditSubmission.Keyword = Request.Form["Keyword"]; EditSubmission.Summary = Request.Form["Summary"]; //Notify user if error occured. if (EditSubmission.Update() != 0) { JSLiteral.Text = Util.JSProcessingErrorAlert; return; } Response.Redirect("articlepreview.aspx?aid=" + EditSubmission.ID); //Release allocated memory EditSubmission = null; Util = null; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Validate admin session username and password by comparing them to the admin user database record. UserNameVal.ValidateAdminUserNameandPass(); //Get admin username from the sessioan variable and place it in the label. lblusername.Text = "Welcome Admin: " + UserNameVal.AdminUsername; if (Request.QueryString["prevedit"] != null) { btn1.Visible = false; btn2.Visible = true; } else { btn1.Visible = true; btn2.Visible = false; } //Instantiate database field ArticleDetail Article = new ArticleDetail(); Article.WhatPageID = (int)Util.Val(Request.QueryString["show"]); //Parameter 2 = we are dealing with the admin/updatearticle.aspx. Article.ID = (int)Util.Val(Request.QueryString["aid"]); //Fill up database fields Article.fillup(); string categoryname; categoryname = Article.Category; lbtitle.Text = Article.Title; lbcatname2.Text = Article.Category; Title.Value = Article.Title; Content.Value = Util.FormatText(Article.Content); Summary.Value = Util.FormatText(Article.Summary); Keyword.Value = Article.Keyword; Author.Value = Article.Author; CAT_ID.Value = Article.CatID.ToString(); //Release allocated memory myBL = null; Util = null; Article = null; } }
/// <summary> /// Perform Admin username and password session validation. /// </summary> public static void ValidateAdminUserNameandPass() { //Instantiate utility object Utility Util = new Utility(); Blogic myBL = new Blogic(); //If it is null, redirect to login page. if ((HttpContext.Current.Session["adminuserid"] == null) && (HttpContext.Current.Session["adminpassword"] == null)) { //Redirect to admin login page. Util.PageRedirect(6); return; } try { //Get admin username stored in the database IDataReader dr = myBL.AdminGetCredentialSessionValidation; dr.Read(); //Check whether admin username or password match from the admin user database, else redirect to the login page. if (HttpContext.Current.Session["adminuserid"].ToString() != dr["uname"].ToString() || HttpContext.Current.Session["adminpassword"].ToString() != dr["password"].ToString()) { //Redirect to admin login page. Util.PageRedirect(6); } //Release allocated memory. dr.Close(); dr = null; Util = null; } catch (Exception ex) { throw ex; } }
//Handles insert article public void Update_Article(Object s, EventArgs e) { //Instantiate database field ArticleInfo UpdateArticle = new ArticleInfo(); UpdateArticle.ID = (int)Util.Val(Request.QueryString["aid"]); UpdateArticle.Title = Request.Form["Title"]; UpdateArticle.Content = Request.Form["Content"]; UpdateArticle.Author = Request.Form["Author"]; UpdateArticle.CatID = int.Parse(Request.Form["CAT_ID"]); UpdateArticle.Keyword = Request.Form["Keyword"]; UpdateArticle.Summary = Request.Form["Summary"]; Caching.PurgeCacheItems("Newest_Articles"); //Notify user if error occured. if (UpdateArticle.Update() != 0) { JSLiteral.Text = Util.JSProcessingErrorAlert; return; } //Release allocated memory UpdateArticle = null; //If success, redirect to article update confirmation page. Util.PageRedirect(7); Util = null; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Validate admin session username and password by comparing them to the admin user database record. UserNameVal.ValidateAdminUserNameandPass(); //Get admin username from the sessioan variable and place it in the label. lblusername.Text = "Welcome Admin: " + UserNameVal.AdminUsername; if (Request.QueryString["prevedit"] != null) { btn1.Visible = false; btn2.Visible = true; } else { btn1.Visible = true; btn2.Visible = false; } //Instantiate database field ArticleDetail Article = new ArticleDetail(); Article.WhatPageID = (int)Util.Val(Request.QueryString["show"]); //Parameter 2 = we are dealing with the admin/updatearticle.aspx. Article.ID = (int)Util.Val(Request.QueryString["aid"]); //Fill up database fields Article.fillup(); string categoryname; categoryname = Article.Category; lbtitle.Text = Article.Title; lbcatname2.Text = Article.Category; Title.Value = Article.Title; Content.Value = Util.FormatText(Article.Content); Summary.Value = Util.FormatText(Article.Summary); Keyword.Value = Article.Keyword; Author.Value = Article.Author; CAT_ID.Value = Article.CatID.ToString(); //Release allocated memory myBL = null; Util = null; Article = null; } }
/// <summary> /// Get article title, author, date, hits, rating and content from the DB matching the Article ID provided. /// </summary> public override void fillup() { //Instantiate Action Stored Procedure object Blogic FetchData = new Blogic(); //Instantiate object Utility Util = new Utility(); //Parameter 1 = we are dealing with the articledetail.aspx not the admin article update which is 2. IDataReader dr = FetchData.GetArticleDetail(ID, WhatPageID); dr.Read(); if (WhatPageID == constant.intArticleDetails) //Populate articledetail.aspx { try { if (dr["Title"] != DBNull.Value) { this._Title = (string)dr["Title"]; } if (dr["Author"] != DBNull.Value) { this._Author = (string)dr["Author"]; } if (dr["No_Rates"] != DBNull.Value) { this._NoRates = dr["No_Rates"].ToString(); } if (dr["HITS"] != DBNull.Value) { this._Hits = (int)dr["HITS"]; } if (dr["Rates"] != DBNull.Value) { this._Rating = dr["Rates"].ToString(); } if (dr["Content"] != DBNull.Value) { this._Content = (string)dr["Content"]; } if (dr["CAT_NAME"] != DBNull.Value) { this._Category = (string)dr["CAT_NAME"]; } if (dr["CAT_ID"] != DBNull.Value) { this._CatID = (int)dr["CAT_ID"]; } if (dr["Post_Date"] != DBNull.Value) { this._Date = (DateTime)(dr["Post_Date"]); } } catch { //Redirect to page not found. //1 = pagenotfound.aspx Util.PageRedirect(1); } return; } else if (WhatPageID == constant.intArticleAdminUpdate) //Populate Admin/updatearticle.aspx { try { if (dr["Title"] != DBNull.Value) { this._Title = (string)dr["Title"]; } if (dr["Author"] != DBNull.Value) { this._Author = (string)dr["Author"]; } if (dr["CAT_NAME"] != DBNull.Value) { this._Category = (string)dr["CAT_NAME"]; } if (dr["Content"] != DBNull.Value) { this._Content = (string)dr["Content"]; } if (dr["Summary"] != DBNull.Value) { this._Summary = (string)dr["Summary"]; } if (dr["Keyword"] != DBNull.Value) { this._Keyword = (string)dr["Keyword"]; } if (dr["CAT_ID"] != DBNull.Value) { this._CatID = (int)dr["CAT_ID"]; } if (dr["Post_Date"] != DBNull.Value) { this._Date = (DateTime)(dr["Post_Date"]); } } catch { //Redirect to page not found. //1 = pagenotfound.aspx Util.PageRedirect(1); } return; } else if (WhatPageID == constant.intArticleAdminPreview) //Populate Admin/articlepreview.aspx { try { if (dr["Title"] != DBNull.Value) { this._Title = (string)dr["Title"]; } if (dr["Content"] != DBNull.Value) { this._Content = (string)dr["Content"]; } } catch { //Redirect to page not found. //1 = pagenotfound.aspx Util.PageRedirect(1); } return; } //Release allocated memory dr.Close(); dr = null; FetchData = null; Util = null; }
/// <summary> /// Get recipe name, author, date, hits, rating, ingredients, instructions and other field from the DB matching the Recipe ID provided. /// </summary> public override void fillup() { //Instantiate Action Stored Procedure object Blogic FetchData = new Blogic(); //Instantiate object Utility Util = new Utility(); /* The reason why we have to use a conditional statement is because we are dealing with 3 diffrent * stored procedures to return the data. Each sproc has its number of columns declared and diffrent where clauses. */ if (WhatPageID == constant.intRecipeDetails) //Populate Recipedetail.aspx database fields { try { IDataReader dr = FetchData.GetRecipeDetail(ID); dr.Read(); if (dr["Name"] != DBNull.Value) { this._RecipeName = (string)dr["Name"]; } if (dr["Author"] != DBNull.Value) { this._Author = (string)dr["Author"]; } if (dr["CAT_ID"] != DBNull.Value) { this._CatID = (int)dr["CAT_ID"]; } if (dr["NO_RATES"] != DBNull.Value) { this._NoRates = dr["NO_RATES"].ToString(); } if (dr["HITS"] != DBNull.Value) { this._Hits = (int)dr["HITS"]; } if (dr["Rates"] != DBNull.Value) { this._Rating = dr["Rates"].ToString(); } if (dr["Category"] != DBNull.Value) { this._Category = (string)dr["Category"]; } if (dr["Ingredients"] != DBNull.Value) { this._Ingredients = (string)dr["Ingredients"]; } if (dr["Instructions"] != DBNull.Value) { this._Instructions = (string)dr["Instructions"]; } if (dr["Date"] != DBNull.Value) { this._Date = (DateTime)(dr["Date"]); } if (dr["TOTAL_COMMENTS"] != DBNull.Value) { this._CountComments = (int)dr["TOTAL_COMMENTS"]; } if (dr["LINK_APPROVED"] != DBNull.Value) { this._Approved = (int)dr["LINK_APPROVED"]; } if (dr["RecipeImage"] != DBNull.Value) { this._RecipeImage = (string)dr["RecipeImage"]; } //Release allocated memory dr.Close(); dr = null; } catch { //Redirect to page not found. //1 = pagenotfound.aspx Util.PageRedirect(1); } return; } else if (WhatPageID == constant.intRecipeAdminViewing) //Populate Admin/viewing.aspx database fields { try { IDataReader dr = FetchData.AdminRecipeApprovalReview(ID); dr.Read(); if (dr["Name"] != DBNull.Value) { this._RecipeName = (string)dr["Name"]; } if (dr["Author"] != DBNull.Value) { this._Author = (string)dr["Author"]; } if (dr["HITS"] != DBNull.Value) { this._Hits = (int)dr["HITS"]; } if (dr["Category"] != DBNull.Value) { this._Category = (string)dr["Category"]; } if (dr["Ingredients"] != DBNull.Value) { this._Ingredients = (string)dr["Ingredients"]; } if (dr["Instructions"] != DBNull.Value) { this._Instructions = (string)dr["Instructions"]; } if (dr["Date"] != DBNull.Value) { this._Date = (DateTime)(dr["Date"]); } if (dr["LINK_APPROVED"] != DBNull.Value) { this._Approved = (int)dr["LINK_APPROVED"]; } if (dr["HIT_DATE"] != DBNull.Value) { this._HitDate = (DateTime)dr["HIT_DATE"]; } //Release allocated memory dr.Close(); dr = null; } catch { //Redirect to page not found. //1 = pagenotfound.aspx Util.PageRedirect(1); } return; } else if (WhatPageID == constant.intRecipeAdminEditing) //Populate Admin/editing.aspx database fields { try { IDataReader dr = FetchData.GetRecipeDetailForUpdate(ID); dr.Read(); if (dr["Name"] != DBNull.Value) { this._RecipeName = (string)dr["Name"]; } if (dr["Author"] != DBNull.Value) { this._Author = (string)dr["Author"]; } if (dr["HITS"] != DBNull.Value) { this._Hits = (int)dr["HITS"]; } if (dr["Ingredients"] != DBNull.Value) { this._Ingredients = (string)dr["Ingredients"]; } if (dr["Instructions"] != DBNull.Value) { this._Instructions = (string)dr["Instructions"]; } //Release allocated memory dr.Close(); dr = null; } catch { //Redirect to page not found. //1 = pagenotfound.aspx Util.PageRedirect(1); } return; } //Release allocated memory FetchData = null; Util = null; }