コード例 #1
0
        protected void OnDelete_User(object sender, EventArgs e)
        {
            hidTAB.Value = "#tab1";
            LinkButton lnk = sender as LinkButton;

            string recId = lnk.Attributes["RecId"];

            try
            {
                if (mp.DeleteUser(Convert.ToDecimal(recId)) == true)
                {
                    this.lblUsrMsg.Text = MessageFormatter.GetFormattedSuccessMessage("User Deleted Succesfully!");

                    GridView2.DataBind();
                }
                else
                {
                    this.lblUsrMsg.Text = MessageFormatter.GetFormattedErrorMessage("Error Deleted User!");
                }
            }
            catch (Exception ex)
            {
                this.lblUsrMsg.Text = MessageFormatter.GetFormattedErrorMessage("Error:" + ex.Message);
            }
            // Usrs.Attributes.Add("class", "active");
        }
コード例 #2
0
        private void btnDeleteUser_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult result = MessageBox.Show("Do you want to delete this user ?", "Delete user", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result == DialogResult.Yes)
                {
                    bool status = userProvider.DeleteUser(txtUsername.Text, true);

                    if (status)
                    {
                        MessageBox.Show("User deleted successfully", "Delete user", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        loadUsers();
                    }
                    else
                    {
                        MessageBox.Show("Failed to delete user", "Delete user", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    MessageBox.Show("Deletion aborted", "Delete user", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show("Failed to delete user, " + ex.Message, "Delete user", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Failed to delete user, " + ex.Message, "Delete user", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to delete user, " + ex.Message, "Delete user", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #3
0
 public ActionResult DeleteConfirmed(UserEntity user)
 {
     provider.DeleteUser(user.Id, true);
     return(RedirectToAction("Index", "Home"));
 }