private void edit_btn_Click(object sender, RoutedEventArgs e)
        {
            int idx = application_combobox.SelectedIndex;

            Security.Entities.Application app = apps.ElementAt(idx);
            idx = role_combobox.SelectedIndex;

            childCount++;
            new AddRole(user, this, roles.ElementAt(idx), app).Show();
            edit_btn.IsEnabled = false;
        }
        private void save_btn_Click(object sender, RoutedEventArgs e)
        {
            Security.Entities.Application app = applications.ElementAt(application_combobox.SelectedIndex);
            app.IsActive       = isActive_combobox.SelectedIndex == 0 ? true : false;
            app.LastModifiedBy = user.User_ID;
            app.LastModifiedOn = DateTime.Now;

            if (ApplicationDAO.updateApplication(app))
            {
                MessageBox.Show("Application updated", "SUCCESS");
            }
            else
            {
            }
        }
        private void loadRole(Role role, Security.Entities.Application app)
        {
            appComboBox.SelectedIndex = 0;

            role_name.Text      = role.Role_Name;
            role_name.IsEnabled = false;

            selectedPermStrings = (from rol in role.Permissions select rol.Permission_Name).ToList <String>();
            permStrings         = permStrings.Except(selectedPermStrings).ToList <String>();
            selected_applications_list_box.ItemsSource  = selectedPermStrings.ToArray <String>();
            avalaible_applications_list_box.ItemsSource = permStrings.ToArray <String>();

            String[] active = { "Active", "Disabled" };
            isActive_combobox.ItemsSource = active;

            isActive_combobox.SelectedIndex = role.IsActive ? 0 : 1;
        }
        private void addButton_Click(object sender, RoutedEventArgs e)
        {
            String appli = appName.Text;

            DateTime dateTime = DateTime.Now;

            Security.Entities.Application app = new Security.Entities.Application(0, appli, null, true, dateTime, dateTime, user.User_ID, user.User_ID);

            if (ApplicationDAO.saveApplication(app))
            {
                MessageBox.Show("Application has been added", "SUCCESS");
                this.Close();
            }
            else
            {
                MessageBox.Show("Application cannot be added", "FAILURE");
            }
        }
        public AddRole(User user, EditRole parent, Role role, Security.Entities.Application app)
        {
            InitializeComponent();

            this.user    = user;
            this.eparent = parent;

            addButton.Content = "Save Role";
            winTitle.Content  = "Edit Role";

            String[] appName = { app.Application_Name };
            appComboBox.ItemsSource = appName;
            appComboBox.IsEnabled   = false;

            isParentControlPanel = false;

            ofeRole = role;
            apps    = new List <Security.Entities.Application>();
            apps.Add(app);

            loadRole(role, app);
        }
        private void getPermissionsOfThisApplication(Security.Entities.Application application)
        {
            permissions = PermissionDAO.getAllPermissionsForApplication(application.App_ID);

            permStrings = (from perms in permissions select perms.Permission_Name).ToList <String>();
        }