void deleteButton_Click(object sender, EventArgs e)
        {
            if (adminId > 0)
            {
                AdminTableAdapter      adminAdapter = new AdminTableAdapter();
                DollarSaverDB.AdminRow admin        = adminAdapter.GetAdmin(adminId)[0];

                if (admin.Role == AdminRole.Root && admin.IsStationIdNull())
                {
                    try {
                        adminAdapter.Delete(admin.AdminId);
                        InfoMessage = "Root User deleted";
                    } catch (SqlException ex) {
                        if (ex.Number == 547)
                        {
                            ErrorMessage = "Root User cannot be deleted due to database constraints.";
                        }
                        else
                        {
                            throw ex;
                        }
                    }
                }
            }

            RedirectToUserList();
        }
Exemple #2
0
        void deleteButton_Click(object sender, EventArgs e)
        {
            if (adminId > 0)
            {
                AdminTableAdapter      adminAdapter = new AdminTableAdapter();
                DollarSaverDB.AdminRow admin        = adminAdapter.GetAdmin(adminId)[0];

                if (admin.StationId == StationId)
                {
                    try {
                        adminAdapter.Delete(admin.AdminId);
                        InfoMessage = "Admin deleted";
                    } catch (SqlException ex) {
                        if (ex.Number == 547)
                        {
                            ErrorMessage = "Admin cannot be deleted due to database constraints.";
                        }
                        else
                        {
                            throw ex;
                        }
                    }
                }
            }

            Response.Redirect("~/admin/AdminList.aspx");
        }
Exemple #3
0
 public int Delete(int id)
 {
     return(db.Delete(id));
 }