예제 #1
0
        private void grida2_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key.Equals(Key.F5))
            {
                AllUsersInformation allUsersInformation = grida2.SelectedItem as AllUsersInformation;

                foreach (var item in allUsers)
                {
                    if (item.Login == allUsersInformation.Login)
                    {
                        switch (index)
                        {
                        case 3:
                            if (authoriz.ChangeAccessForSomeUser(user, item, allUsersInformation.ObjectName1, Convert.ToInt32(allUsersInformation.ObjectAccess1)))
                            {
                                MessageBox.Show("Changed access to the object: " + allUsersInformation.ObjectName1, "Success");
                            }
                            else
                            {
                                MessageBox.Show("You don't have access", "Error!");
                            }
                            break;

                        case 5:
                            if (authoriz.ChangeAccessForSomeUser(user, item, allUsersInformation.ObjectName2, Convert.ToInt32(allUsersInformation.ObjectAccess2)))
                            {
                                MessageBox.Show("Changed access to the object: " + allUsersInformation.ObjectName2, "Success");
                            }
                            else
                            {
                                MessageBox.Show("You don't have access", "Error!");
                            }
                            break;

                        case 7:
                            if (authoriz.ChangeAccessForSomeUser(user, item, allUsersInformation.ObjectName3, Convert.ToInt32(allUsersInformation.ObjectAccess3)))
                            {
                                MessageBox.Show("Changed access to the object: " + allUsersInformation.ObjectName3, "Success");
                            }
                            else
                            {
                                MessageBox.Show("You don't have access", "Error!");
                            }
                            break;

                        default:
                            Console.WriteLine("Default case");
                            break;
                        }
                    }
                    else
                    {
                    }
                }
            }
        }
예제 #2
0
        public Information(User user, Authoriz authoriz)
        {
            InitializeComponent();

            this.user     = user;
            this.authoriz = authoriz;
            userName.Text = user.Login;

            string[] list = JsonTools.DeserializeFromFile <JArray>("namesFile.txt").ToObject <string[]>();

            List <string> asd = new List <string>();

            var info = authoriz.CheckAccessUsers(user, list);

            foreach (var item in info)
            {
                AccessLevelForUser dic = new AccessLevelForUser();
                dic.nameObject = item.Key;
                dic.nameAccess = item.Value.ToString();

                grida.Items.Add(dic);
            }
            grida.IsReadOnly = true;

            allUsers = authoriz.GetDataAllUsers();

            ObservableCollection <AllUsersInformation> allUsersInformation1 = new ObservableCollection <AllUsersInformation>();

            foreach (var item in allUsers)
            {
                AllUsersInformation allUsersInformation = new AllUsersInformation();

                allUsersInformation.Login     = item.Login;
                allUsersInformation.SuperUser = item.SuperUser;

                for (int i = 0; i < info.Count; i++)
                {
                    switch (i)
                    {
                    case 0:
                        allUsersInformation.ObjectName1   = item.Access.ElementAt(i).Key;
                        allUsersInformation.ObjectAccess1 = item.Access.ElementAt(i).Value.ToString();
                        break;

                    case 1:
                        allUsersInformation.ObjectName2   = item.Access.ElementAt(i).Key;
                        allUsersInformation.ObjectAccess2 = item.Access.ElementAt(i).Value.ToString();
                        break;

                    case 2:
                        allUsersInformation.ObjectName3   = item.Access.ElementAt(i).Key;
                        allUsersInformation.ObjectAccess3 = item.Access.ElementAt(i).Value.ToString();
                        break;

                    default:
                        Console.WriteLine("Default case");
                        break;
                    }
                }
                allUsersInformation1.Add(allUsersInformation);
            }
            grida2.ItemsSource = allUsersInformation1;
        }