Пример #1
0
        private void AddUserButton_Click(object sender, RoutedEventArgs e)//Добавление
        {
            UserData us = new UserData("", "", "", "", 0, "");

            users.Add(us);

            De_Serialization.Serialization <List <UserData> >("UserData.xml", CreationCollisionOption.ReplaceExisting, users);
            date = DateTime.Now;
            SaveTextBlock.Text = $"Последнее сохранение: {date}";

            dataGrid.ItemsSource = new List <UserData>();
            dataGrid.ItemsSource = users;
        }
Пример #2
0
        //---------------------------------------------------------------------------------------------------------------------------------------------Кнопки для пользователей
        private async void SaveUserButton_Click(object sender, RoutedEventArgs e) //Сохранение пользователей
        {
            usersclone = await De_Serialization.Deserialisation <List <UserData> >("UserData.xml", CreationCollisionOption.OpenIfExists, users);

            for (int i = 0; i < users.Count; i++)
            {
                if (users[i].Password != usersclone[i].Password)
                {
                    users[i].Password = Cypher.GetMd5Hash(users[i].Password);
                }
            }
            De_Serialization.Serialization <List <UserData> >("UserData.xml", CreationCollisionOption.ReplaceExisting, users);
            dataGrid.ItemsSource = new List <UserData>();
            dataGrid.ItemsSource = users;
            date = DateTime.Now;
            SaveTextBlock.Text = $"Последнее сохранение: {date}";
        }
Пример #3
0
        private async void AppBarButton_Click_1(object sender, RoutedEventArgs e) //Сохранение оценок
        {
            bool confirm = true;

            foreach (var mark in savingmarks)
            {
                if (mark == null)
                {
                    confirm = false;
                    break;
                }
            }
            if (JournalDispTextBox.Text != "" && JournalGroupTextBox.Text != "" && confirm)
            {
                savingmarks.Add(JournalDatePicker.Date.ToString("dd.MM.yyyy"));
                bool checkdate = false;
                for (int i = 0; i < marks.Count; i++)
                {
                    List <string> data = marks[i];
                    if (data[data.Count - 1] == savingmarks[savingmarks.Count - 1])
                    {
                        checkdate = true;
                        marks[i]  = savingmarks;
                        break;
                    }
                }
                if (!checkdate)
                {
                    marks.Add(savingmarks);
                }
                De_Serialization.Serialization <List <List <string> > >($"{JournalDispTextBox.Text}-{JournalGroupTextBox.Text}.xml", CreationCollisionOption.ReplaceExisting, marks);
            }
            else
            {
                ContentDialog prog = new ContentDialog()
                {
                    Title             = "Ошибка",
                    Content           = "Повторите заполнение оценок. Правильное заполнение: нажимаете на студента, затем в списке справа выбираете его оценку.",
                    PrimaryButtonText = "OK"
                };
                await prog.ShowAsync();
            }
        }
Пример #4
0
        public async void Refreshing(ListBox listBox)//Обновить список
        {
            if (listBox.Name == "DisciplinesListBox")
            {
                De_Serialization.Serialization <List <string> >("Disciplines.xml", CreationCollisionOption.ReplaceExisting, disciplines);
                DisciplinesListBox.Items.Clear();
                disciplines = await De_Serialization.Deserialisation <List <string> >("Disciplines.xml", CreationCollisionOption.OpenIfExists, disciplines);

                AddingItems(disciplines, DisciplinesListBox);
            }
            else
            {
                De_Serialization.Serialization <List <string> >("Groups.xml", CreationCollisionOption.ReplaceExisting, groups);
                GroupListBox.Items.Clear();
                groups = await De_Serialization.Deserialisation <List <string> >("Groups.xml", CreationCollisionOption.OpenIfExists, groups);

                AddingItems(groups, GroupListBox);
            }
        }
Пример #5
0
        private void SavingRasp() //Сохранить расписание
        {
            if (RaspComboBox.SelectedItem != null)
            {
                List <string> smollist;
                biglist = new List <List <string> >(new List <string> [6]);

                for (int i = 0; i < listBoxes.Count; i++)
                {
                    smollist = new List <string>();
                    for (int g = 0; g < listBoxes[i].Items.Count; g++)
                    {
                        string str = listBoxes[i].Items[g].ToString();
                        smollist.Add(str);
                    }
                    biglist[i] = smollist;
                }
                De_Serialization.Serialization <List <List <string> > >($"{RaspComboBox.SelectedItem.ToString()}.xml", CreationCollisionOption.ReplaceExisting, biglist);
            }
        }
Пример #6
0
        private async void RegLogButton_Click(object sender, RoutedEventArgs e) //Кнопка входа/регистрации
        {
            if (RegGrid.Visibility == Visibility.Visible)                       //Действия для регистрации
            {
                if (RegTextBox.Text != "")
                {
                    if (RegPasswordbx.Password != "")
                    {
                        string passw = Cypher.GetMd5Hash(RegPasswordbx.Password);
                        if (RegNameBox.Text != "")
                        {
                            if (RegSurNameBox.Text != "")
                            {
                                if (RegTypeBox.SelectedIndex != -1)
                                {
                                    UserData us = new UserData(RegTextBox.Text, passw, RegNameBox.Text, RegSurNameBox.Text, RegTypeBox.SelectedIndex, RegTextBlock.Text);
                                    users.Add(us);
                                    De_Serialization.Serialization <List <UserData> >("UserData.xml", CreationCollisionOption.OpenIfExists, users);

                                    RegGrid.Visibility   = Visibility.Collapsed;
                                    LoginGrid.Visibility = Visibility.Visible;
                                    RegLogButton.Content = "Войти";
                                }
                            }
                        }
                    }
                }
                //Ошибки
                if (RegTextBox.Text == "" || RegPasswordbx.Password == "" || RegNameBox.Text == "" || RegSurNameBox.Text == "" || RegTypeBox.SelectedIndex == -1)
                {
                    ContentDialog prog = new ContentDialog()
                    {
                        Title             = "Ошибка",
                        Content           = "Одно или несколько полей пустые",
                        PrimaryButtonText = "OK"
                    };
                    await prog.ShowAsync();
                }
            }
            else //Действия для входа
            {
                if (users.Count != 0 && LoginTextBox.Text != "" && Passwordbx.Password != "")
                {
                    string passw     = Cypher.GetMd5Hash(Passwordbx.Password);
                    bool   confirmed = true;
                    for (int i = 0; i < users.Count; i++)
                    {
                        if (LoginTextBox.Text == users[i].Login && passw == users[i].Password)
                        {
                            List <string> us = new List <string>()
                            {
                                users[i].Login, passw, users[i].Name, users[i].Surname, users[i].AccountType.ToString(), users[i].DisciplineType
                            };
                            De_Serialization.Serialization <List <string> >("LoginData.xml", CreationCollisionOption.ReplaceExisting, us);

                            confirmed = true;

                            if (users[i].AccountType == 0)
                            {
                                this.Frame.Navigate(typeof(StudentPage));
                            }
                            if (users[i].AccountType == 1)
                            {
                                this.Frame.Navigate(typeof(TeacherPage));
                            }
                            if (users[i].AccountType == 2)
                            {
                                this.Frame.Navigate(typeof(AdminPage));
                            }

                            break;
                        }
                        else
                        {
                            confirmed = false;
                        }
                    }
                    if (!confirmed)
                    {
                        ContentDialog prog = new ContentDialog()
                        {
                            Title             = "Ошибка",
                            Content           = "Неверный логин или пароль",
                            PrimaryButtonText = "OK"
                        };
                        await prog.ShowAsync();
                    }
                }
            }
        }