protected void Button_DeleteAccount_Click(object sender, EventArgs e) { string sessionid = this.Session.SessionID; HttpCookie cookie = Request.Cookies[sessionid]; DataView dv = (DataView)SqlDataSourceAuth.Select(DataSourceSelectArguments.Empty); SqlDataSourceAuth.SelectCommand = "SELECT * FROM[Authentication] WHERE([Username] = @username)"; SqlDataSourcePro.SelectParameters.Add("username", cookie["username"]); if (dv.Table.Rows.Count != 0) { SqlDataSourceAuth.DeleteCommand = "DELETE FROM Authentication WHERE Username=@username"; SqlDataSourceAuth.DeleteParameters.Add("username", cookie["username"]); SqlDataSourceAuth.Delete(); Comment.Text = "Your account has been deleted"; if (userflag(cookie["username"])) { SqlDataSourcePro.DeleteCommand = "DELETE FROM Profile WHERE Username=@username"; SqlDataSourcePro.DeleteParameters.Add("username", cookie["username"]); SqlDataSourcePro.Delete(); Comment.Text = "Your profile has been deleted!"; } } FormsAuthentication.SignOut(); Response.Redirect("../Default.aspx"); }
protected void DeletePro_Click(object sender, EventArgs e) { string sessionid = this.Session.SessionID; HttpCookie cookie = Request.Cookies[sessionid]; if (userflag(cookie["username"]) == true) { SqlDataSourcePro.DeleteCommand = "DELETE FROM Profile WHERE Username=@username"; SqlDataSourcePro.DeleteParameters.Add("username", cookie["username"]); SqlDataSourcePro.Delete(); //FormsAuthentication.SignOut(); Comment.Text = "Your profile has been deleted!"; TextBox_Name.Text = ""; TextBox_Age.Text = ""; TextBox_Address.Text = ""; TextBox_Email.Text = ""; TextBox_Telephone.Text = ""; RadioButtonList_Gender.SelectedValue = null; } else { Comment.Text = "You don't have profile can be deleted"; } }