示例#1
0
 public void Delete()
 {
     if (SelectedDataItem != null)
     {
         if (MessageBox.Show("Are you sure you want to delete all selected Groups??",
                             "Delete",
                             MessageBoxButton.YesNo,
                             MessageBoxImage.Warning) == MessageBoxResult.Yes)
         {
             IsInProgress = true;
             new Thread(() =>
             {
                 foreach (var item in DataGridSource)
                 {
                     if (item.IsChecked)
                     {
                         try
                         {
                             DataAccess.DeleteGroup(item.GId);
                             DataAccess.DeleteGroupRoles(item.GId);
                         }
                         catch { MessageBox.Show("could not open connection with server!\nCheck your internet connection or server is connected", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); }
                     }
                 }
                 DataGridSource.ReFill(DataGridSource.Where(x => !x.IsChecked).ToList());
                 IsInProgress = false;
             })
             {
                 IsBackground = true
             }.Start();
             GroupRolesSource.Clear();
         }
     }
 }
示例#2
0
 public void SelectIndexChanged(GroupsModel group)
 {
     if (group != null)
     {
         GroupRolesSource.Clear();
         var roles = GroupRoles.Where(x => x.GrolrGIdFk == group.GId);
         foreach (var item in roles)
         {
             var role = Roles.Where(x => x.RoleId == item.GrolrRoleIdFk).FirstOrDefault();
             if (role != null)
             {
                 GroupRolesSource.Add(role.FillRoles(item));
             }
         }
     }
 }
示例#3
0
 protected void GroupItemChanging(GroupsModel newValue)
 {
     if (newValue != null)
     {
         GroupRolesSource.Clear();
         var roles = GroupRoles.Where(x => x.GrolrGIdFk == newValue.GId);
         foreach (var item in roles)
         {
             var role = Roles.Where(x => x.RoleId == item.GrolrRoleIdFk).FirstOrDefault();
             if (role != null)
             {
                 GroupRolesSource.Add(role.FillRoles(item));
             }
         }
     }
 }
示例#4
0
        public void Refresh()
        {
            GroupRoles.Clear();
            new Thread(() =>
            {
                List <GroupsModel> dataSource = null;
                Thread inProgress             = new Thread(() =>
                {
                    IsInProgress = true;
                    try
                    {
                        dataSource = DataAccess.GroupsData();
                        GroupRoles = DataAccess.GroupRolesData();
                        Roles      = DataAccess.RolesData();
                    }
                    catch { MessageBox.Show("could not open connection with server!\nCheck your internet connection or server is connected", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); }
                })
                {
                    IsBackground = true
                };


                inProgress.Start();
                while (inProgress.IsAlive)
                {
                    if (RotateAngle > 360)
                    {
                        RotateAngle = 0;
                    }
                    RotateAngle += 18.25;
                    Thread.Sleep(50);
                }
                while (RotateAngle > 0 && RotateAngle < 365)
                {
                    RotateAngle += 18.25;
                    Thread.Sleep(50);
                }
                RotateAngle = 0;
                DataGridSource.ReFill(dataSource);
                IsInProgress = false;
            })
            {
                IsBackground = true
            }.Start();
            GroupRolesSource.Clear();
        }
示例#5
0
 public void Edit()
 {
     if (SelectedDataItem != null)
     {
         var item = SelectedDataItem;
         for (int i = 0; i < Roles.Count; i++)
         {
             var role = GroupRolesSource.Where(x => x.RoleId == Roles[i].RoleId).FirstOrDefault();
             if (role != null)
             {
                 var groupRoles = GroupRoles.Where(x => x.GrolrRoleIdFk == Roles[i].RoleId && x.GrolrGIdFk == item.GId).FirstOrDefault();
                 Roles[i].IsChecked   = true;
                 Roles[i].GroleAdd    = groupRoles.GroleAdd;
                 Roles[i].GroleEdit   = groupRoles.GroleEdit;
                 Roles[i].GroleDelete = groupRoles.GroleDelete;
                 Roles[i].GroleExport = groupRoles.GroleExport;
                 Roles[i].GrolePrint  = groupRoles.GrolePrint;
                 Roles[i].GroleView   = groupRoles.GroleView;
             }
             else
             {
                 Roles[i].IsChecked   = false;
                 Roles[i].GroleAdd    = false.ToIntState();
                 Roles[i].GroleEdit   = false.ToIntState();
                 Roles[i].GroleDelete = false.ToIntState();
                 Roles[i].GroleExport = false.ToIntState();
                 Roles[i].GrolePrint  = false.ToIntState();
                 Roles[i].GroleView   = false.ToIntState();
             }
         }
         VGroupsEdit edit = new VGroupsEdit(Roles, item);
         if (edit.ShowDialog() == true)
         {
             var dataContext = edit.DataContext as VMGroupsEdit;
             DataGridSource.Remove(SelectedDataItem);
             DataGridSource.Add(dataContext.EditGroup);
             GroupRoles.RemoveAll(x => x.GrolrGIdFk == item.GId);
             GroupRoles.AddRange(dataContext.DataGridSource.Where(x => x.RoleSelected()).Select(x => x.ToGroupRoles(item.GId)));
         }
         GroupRolesSource.Clear();
     }
 }
 protected void GroupItemChanging(GroupsModel newValue)
 {
     IsInProgress = true;
     new Thread(() =>
     {
     })
     {
         IsBackground = true
     }.Start();
     if (newValue != null)
     {
         GroupRolesSource.Clear();
         var roles = GroupRoles.Where(x => x.GrolrGIdFk == newValue.GId);
         foreach (var item in roles)
         {
             var role = Roles.Where(x => x.RoleId == item.GrolrRoleIdFk).FirstOrDefault();
             if (role != null)
             {
                 GroupRolesSource.Add(role.FillRoles(item));
             }
         }
     }
 }
示例#7
0
        public void Add()
        {
            foreach (var item in Roles)
            {
                item.IsChecked   = false;
                item.GroleAdd    = false.ToIntState();
                item.GroleEdit   = false.ToIntState();
                item.GroleDelete = false.ToIntState();
                item.GroleExport = false.ToIntState();
                item.GrolePrint  = false.ToIntState();
                item.GroleView   = false.ToIntState();
            }
            VGroupsAdd add = new VGroupsAdd(Roles);

            if (add.ShowDialog() == true)
            {
                DataGridSource.Add((add.DataContext as VMGroupsAdd).AddedGroup);
                foreach (var item in (add.DataContext as VMGroupsAdd).AddedGroupRoles)
                {
                    GroupRoles.Add(item);
                }
            }
            GroupRolesSource.Clear();
        }