protected void rpPost_ItemCommand(object source, RepeaterCommandEventArgs e) { try { if (e.CommandName == "Read") { //db.AddParameter("@postid", e.CommandArgument); //db.ExecuteNonQuery("save_PostView", CommandType.StoredProcedure); Response.Redirect("singlepost.aspx?postid=" + e.CommandArgument.ToString() + "&type=admin"); } else if (e.CommandName == "EDT") { Response.Redirect("newpost.aspx?postid=" + e.CommandArgument.ToString()); } else if (e.CommandName == "DEL") { db.AddParameter("@postid", e.CommandArgument.ToString()); db.AddParameter("@blog_id", ConfigurationManager.AppSettings["BlogId"].ToString()); db.ExecuteNonQuery("update posts set active=0 where postid=@postid and blog_id=@blog_id", CommandType.Text); FillRp(); FillTrashGrid(true, false); lblErrorMsg.Text = "Post Deleted Successfully."; } else if (e.CommandName == "UNPublish") { db.AddParameter("@postid", e.CommandArgument.ToString()); db.AddParameter("@blog_id", ConfigurationManager.AppSettings["BlogId"].ToString()); db.ExecuteNonQuery("update posts set active=3 where postid=@postid and blog_id=@blog_id", CommandType.Text); FillRp(); FillTrashGrid(true, false); AdminMaster admin = Master as AdminMaster; admin.AdminSide(); lblErrorMsg.Text = "Post Unpublished Successfully."; } else if (e.CommandName == "Active") { db.AddParameter("@postid", e.CommandArgument.ToString()); db.AddParameter("@blog_id", ConfigurationManager.AppSettings["BlogId"].ToString()); db.ExecuteNonQuery("update posts set active=1 where postid=@postid and blog_id=@blog_id", CommandType.Text); FillTrashGrid(false, true); FillRp(); lblErrorMsg.Text = "Post Active Successfully."; } } catch (Exception ex) { lblErrorMsg.Text = ex.Message.ToString(); } }
protected void fuProfile_PreRender(object sender, EventArgs e) { try { if (fuProfile.HasFile) { if (IsPostBack && fuProfile.PostedFile != null) { string file_name = string.Empty, extension = string.Empty; file_name = fuProfile.FileName; extension = file_name.Substring(file_name.LastIndexOf(".")); if (extension.ToLower().Equals(".png") || extension.ToLower().Equals(".jpg") || extension.ToLower().Equals(".jpeg")) { file_name = file_name.Replace(file_name, hdnUserId.Value + extension); fuProfile.SaveAs(Server.MapPath(ConfigurationManager.AppSettings["profileurl"] + file_name)); imgProfile.ImageUrl = ConfigurationManager.AppSettings["profileurl"] + file_name; db.AddParameter("@userid", Request.QueryString["userid"].ToString()); db.AddParameter("@PicUrl", file_name); db.AddParameter("@blog_id", ConfigurationManager.AppSettings["BlogId"].ToString()); db.ExecuteNonQuery("update usermaster set pic_url=@picurl where userid=@userid and blog_id=@blog_id", CommandType.Text); lblErrorMsg.Text = "Profile Picture Change Successfully."; if (Request.QueryString["type"].ToString() == "user") { BlogAdmin blogmaster = Master as BlogAdmin; blogmaster.userSide(); } else if (Request.QueryString["type"].ToString() == "admin") { AdminMaster admin = Master as AdminMaster; admin.AdminSide(); } } else { lblErrorMsg.Text = "Please select .Png, .Jpg or jpeg file only"; return; } } } } catch (Exception ex) { lblErrorMsg.Text = ex.Message.ToString(); } }
protected void btnUpdate_Click(object sender, EventArgs e) { try { if (btnUpdate.TabIndex == 0) { btnUpdate.Text = "Update"; btnUpdate.TabIndex = 1; txtMobile.ReadOnly = false; txtName.ReadOnly = false; txtLastName.ReadOnly = false; } else { db.AddParameter("@userid", Request.QueryString["userid"].ToString()); db.AddParameter("@mobile", txtMobile.Text); db.AddParameter("@FirstName", txtName.Text); db.AddParameter("@LastName", txtLastName.Text); db.AddParameter("@blog_id", ConfigurationManager.AppSettings["BlogId"].ToString()); db.ExecuteNonQuery("save_user", CommandType.StoredProcedure); if (Request.QueryString["type"].ToString() == "user") { BlogAdmin blogmaster = Master as BlogAdmin; blogmaster.userSide(); } else if (Request.QueryString["type"].ToString() == "admin") { AdminMaster admin = Master as AdminMaster; admin.AdminSide(); } lblErrorMsg.Text = "Profile Updated Successfully."; btnUpdate.Text = "Edit"; btnUpdate.TabIndex = 0; txtMobile.ReadOnly = true; txtName.ReadOnly = true; txtLastName.ReadOnly = true; } } catch (Exception ex) { lblErrorMsg.Text = ex.Message.ToString(); } }
protected void rpComments_ItemCommand(object source, RepeaterCommandEventArgs e) { try { if (e.CommandName == "DEL") { db.AddParameter("@commentid", e.CommandArgument.ToString()); db.AddParameter("@active", 1); db.AddParameter("@blog_id", ConfigurationManager.AppSettings["BlogId"].ToString()); DataSet ds = db.ExecuteDataSet("get_comments", CommandType.StoredProcedure); if (ds.Tables[0].Rows.Count > 0) { db.ExecuteNonQuery("update PostComments set active=0 where commentsid=" + e.CommandArgument.ToString()); //Util.SendEmail(ds.Tables[0].Rows[0]["email"].ToString(), "Comment Approved", "Hi " + ds.Tables[0].Rows[0]["username"].ToString() + ", <br / >Thanks for your comment ! It have been approved. "); FillGrid(); AdminMaster admin = Master as AdminMaster; admin.AdminSide(); lblErrorMsg.Text = "Comment Delete Successfully."; } } //else if (e.CommandName == "Reject") //{ // db.ExecuteNonQuery("update PostComments set active=1 where commentsid=" + e.CommandArgument.ToString()); // FillGrid(); // db.AddParameter("@active", 2); // db.AddParameter("@commentid", e.CommandArgument.ToString()); // DataSet ds = db.ExecuteDataSet("get_comments", CommandType.StoredProcedure); // Util.SendEmail("*****@*****.**", "Comment Approved", "Hi " + ds.Tables[0].Rows[0]["username"].ToString() + ", <br / >Thanks for your comment ! It have been approved. "); // lblErrorMsg.Text = "Comment Approved"; //} } catch (Exception ex) { lblErrorMsg.Text = ex.Message.ToString(); } }
protected void rpDraft_ItemCommand(object source, RepeaterCommandEventArgs e) { try { if (e.CommandName == "Publish") { db.AddParameter("@postid", e.CommandArgument.ToString()); db.AddParameter("@blog_id", ConfigurationManager.AppSettings["BlogId"].ToString()); db.ExecuteNonQuery("update posts set active=1 where postid=@postid and blog_id=@blog_id", CommandType.Text); lblErrorMsg.Text = "Post Published"; FillRp(); AdminMaster master = Master as AdminMaster; master.AdminSide(); } else if (e.CommandName == "Read") { Response.Redirect("singlepost.aspx?postid=" + e.CommandArgument.ToString() + "&type=Draft"); } else if (e.CommandName == "EDT") { Response.Redirect("newpost.aspx?postid=" + e.CommandArgument.ToString()); } else if (e.CommandName == "DEL") { db.AddParameter("@postid", e.CommandArgument.ToString()); db.AddParameter("@blog_id", ConfigurationManager.AppSettings["BlogId"].ToString()); db.ExecuteNonQuery("update posts set active=0 where postid=@postid and blog_id=@blog_id", CommandType.Text); FillRp(); lblErrorMsg.Text = "Post Deleted Successfully."; } } catch (Exception ex) { lblErrorMsg.Text = ex.Message.ToString(); } }