Ejemplo n.º 1
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            List <UserData> users = new List <UserData>();

            users = await De_Serialization.Deserialisation <List <UserData> >("UserData.xml", CreationCollisionOption.OpenIfExists, users);

            foreach (UserData user in users)
            {
                if (user.AccountType == 0)
                {
                    students.Add(user);
                }
            }

            disciplines = await De_Serialization.Deserialisation <List <string> >("Disciplines.xml", CreationCollisionOption.OpenIfExists, disciplines);

            groups = await De_Serialization.Deserialisation <List <string> >("Groups.xml", CreationCollisionOption.OpenIfExists, groups);

            AddingItems(groups, groupsListBox);
            RaspComboBox.ItemsSource = groups;

            listBoxes = new List <ListBox>();
            listBoxes.Add(RaspMonListBox);
            listBoxes.Add(RaspTueListBox);
            listBoxes.Add(RaspWenListBox);
            listBoxes.Add(RaspThuListBox);
            listBoxes.Add(RaspFriListBox);
            listBoxes.Add(RaspSatListBox);

            for (int i = 0; i < biglist.Count; i++)
            {
                listBoxes[i].ItemsSource = biglist[i];
            }
        }
Ejemplo n.º 2
0
        private async void Page_Loading(FrameworkElement sender, object args) //Начало работы
        {
            listBoxes = new List <ListBox>();

            users = await De_Serialization.Deserialisation <List <UserData> >("UserData.xml", CreationCollisionOption.OpenIfExists, users);

            dataGrid.ItemsSource = users;
            usersclone           = users;

            disciplines = await De_Serialization.Deserialisation <List <string> >("Disciplines.xml", CreationCollisionOption.OpenIfExists, disciplines);

            AddingItems(disciplines, DisciplinesListBox);
            ExcelDiscComboBox.ItemsSource = disciplines;

            groups = await De_Serialization.Deserialisation <List <string> >("Groups.xml", CreationCollisionOption.OpenIfExists, groups);

            AddingItems(groups, GroupListBox);
            RaspComboBox.ItemsSource       = groups;
            ExcelGroupComboBox.ItemsSource = groups;

            listBoxes.Add(RaspMonListBox);
            listBoxes.Add(RaspTueListBox);
            listBoxes.Add(RaspWenListBox);
            listBoxes.Add(RaspThuListBox);
            listBoxes.Add(RaspFriListBox);
            listBoxes.Add(RaspSatListBox);
        }
Ejemplo n.º 3
0
        private async void dataGrid_CellEditEnded(object sender, Microsoft.Toolkit.Uwp.UI.Controls.DataGridCellEditEndedEventArgs e)//Проверка ячеек после изменения
        {
            usersclone = await De_Serialization.Deserialisation <List <UserData> >("UserData.xml", CreationCollisionOption.OpenIfExists, users);

            if (e.Column.Header.ToString() == "DisciplineType")
            {
                var  item    = (UserData)dataGrid.SelectedItem;
                bool confirm = false;
                if (item.AccountType == 0)
                {
                    foreach (string group in groups)
                    {
                        if (group == item.DisciplineType)
                        {
                            confirm = true;
                            break;
                        }
                    }
                }
                if (!confirm)
                {
                    users[dataGrid.SelectedIndex].DisciplineType = usersclone[dataGrid.SelectedIndex].DisciplineType;
                    dataGrid.ItemsSource = new List <UserData>();
                    dataGrid.ItemsSource = users;
                }
            }

            if (e.Column.Header.ToString() == "AccountType")
            {
                if (users[dataGrid.SelectedIndex].AccountType > 2 || users[dataGrid.SelectedIndex].AccountType < 0)
                {
                    users[dataGrid.SelectedIndex].AccountType = usersclone[dataGrid.SelectedIndex].AccountType;
                }
            }
        }
Ejemplo n.º 4
0
        //----------------------------------------------------------------------------------------------------------------Общее
        private async void Page_Loading(FrameworkElement sender, object args)
        {
            users = await De_Serialization.Deserialisation <List <UserData> >("UserData.xml", CreationCollisionOption.OpenIfExists, users);

            groups = await De_Serialization.Deserialisation <List <string> >("Groups.xml", CreationCollisionOption.OpenIfExists, groups);

            RegDiscBox.ItemsSource = groups;
        }
Ejemplo n.º 5
0
        //---------------------------------------------------------------------------------------------------------------------------------------------Кнопки для генерации
        private async void CreateExcelButton_Click(object sender, RoutedEventArgs e)
        {
            if (ExcelGroupComboBox.SelectedIndex != -1 && ExcelDiscComboBox.SelectedIndex != -1)
            {
                FileInfo fileex = new FileInfo(ApplicationData.Current.LocalFolder.Path + $@"\{groups[ExcelGroupComboBox.SelectedIndex]}.xlsx");

                ExcelPackage.LicenseContext = LicenseContext.NonCommercial;

                ToastNotifier toastNote = ToastNotificationManager.CreateToastNotifier();
                Windows.Data.Xml.Dom.XmlDocument xml   = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
                Windows.Data.Xml.Dom.XmlNodeList nodes = xml.GetElementsByTagName("text");
                nodes.Item(0).AppendChild(xml.CreateTextNode("Генерация Excel файла"));

                using (ExcelPackage excelPackage = new ExcelPackage(fileex))
                {
                    try
                    {
                        ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.Add($"{disciplines[ExcelDiscComboBox.SelectedIndex]}");

                        List <List <string> > marks = new List <List <string> >();
                        marks = await De_Serialization.Deserialisation <List <List <string> > >($"{disciplines[ExcelDiscComboBox.SelectedIndex]}-{groups[ExcelGroupComboBox.SelectedIndex]}.xml", CreationCollisionOption.OpenIfExists, marks);

                        for (int i = 1; i < marks.Count + 1; i++)
                        {
                            List <string> day = marks[i - 1];
                            for (int g = 1; g < day.Count + 1; g++)
                            {
                                string[] splitted = day[g - 1].Split('|');
                                if (i == 1 && g != day.Count)
                                {
                                    worksheet.Cells[g + 1, i].Value     = splitted[1];
                                    worksheet.Cells[g + 1, i + 1].Value = splitted[0];
                                }
                                else if (g == day.Count)
                                {
                                    worksheet.Cells[1, i + 1].Value = day[g - 1];
                                }
                                else
                                {
                                    worksheet.Cells[g + 1, i + 1].Value = splitted[0];
                                }
                            }
                        }

                        excelPackage.Save();

                        nodes.Item(1).AppendChild(xml.CreateTextNode("Excel файл успешно сохранен!"));
                    }
                    catch
                    {
                        nodes.Item(1).AppendChild(xml.CreateTextNode("Произошла ошибка в сохранении. Такое бывает, если в Excel уже есть лист с таким именем"));
                    }
                    ToastNotification toast = new ToastNotification(xml);
                    toast.ExpirationTime = DateTime.Now.AddSeconds(4);
                    toastNote.Show(toast);
                }
            }
        }
Ejemplo n.º 6
0
        }                                                                                            //Автосохранение

        private async void RaspComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) //Загрузка расписания группы
        {
            biglist = new List <List <string> >(new List <string> [6]);
            biglist = await De_Serialization.Deserialisation <List <List <string> > >($"{RaspComboBox.SelectedItem.ToString()}.xml", CreationCollisionOption.OpenIfExists, biglist);

            for (int i = 0; i < biglist.Count; i++)
            {
                listBoxes[i].ItemsSource = biglist[i];
            }
        }
Ejemplo n.º 7
0
        private async void AddingDiscItems() //Добавление дисциплин
        {
            if ((date != "Sunday" && date != "") && groupstring != "")
            {
                if (date == "Monday")
                {
                    dateint = 0;
                }
                if (date == "Tuesday")
                {
                    dateint = 1;
                }
                if (date == "Wednesday")
                {
                    dateint = 2;
                }
                if (date == "Thursday")
                {
                    dateint = 3;
                }
                if (date == "Friday")
                {
                    dateint = 4;
                }
                if (date == "Saturday")
                {
                    dateint = 5;
                }

                login = new List <string>();
                login = await De_Serialization.Deserialisation <List <string> >("LoginData.xml", CreationCollisionOption.OpenIfExists, login);

                biglist = new List <List <string> >(new List <string> [6]);
                biglist = await De_Serialization.Deserialisation <List <List <string> > >($"{groupstring}.xml", CreationCollisionOption.OpenIfExists, biglist);

                for (int i = 0; i < biglist.Count; i++)
                {
                    List <string> smollist  = biglist[i];
                    List <string> cleanlist = new List <string>();
                    for (int g = 0; g < smollist.Count; g++)
                    {
                        if (smollist[g].Contains(login[3]))
                        {
                            cleanlist.Add(smollist[g]);
                        }
                    }

                    biglist[i] = cleanlist;
                }
                disciplinesListBox.ItemsSource = new List <string>();
                disciplinesListBox.ItemsSource = biglist[dateint];
            }
        }
Ejemplo n.º 8
0
        private async void LoadUserButton_Click(object sender, RoutedEventArgs e)//Загрузка старых данных
        {
            usersclone = await De_Serialization.Deserialisation <List <UserData> >("UserData.xml", CreationCollisionOption.OpenIfExists, users);

            string confirm = await YesNoDialog("Подтвердите действие", $"Вы уверены, что хотите загрузить последние сохраненные данные, не сохранив нынешние? Последнее сохранение было в {date}");

            if (confirm == "yes")
            {
                users = usersclone;
                dataGrid.ItemsSource = new List <UserData>();
                dataGrid.ItemsSource = users;
            }
        }
Ejemplo n.º 9
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}";
        }
Ejemplo n.º 10
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);
            }
        }
Ejemplo n.º 11
0
        //---------------------------------------------------------------------------------------------------------------------------------------------Кнопки для групп

        private async void RaspListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (RaspDatePicker.Date.ToString() != "" && (sender as ListBox).SelectedIndex != -1)
            {
                string[] para = dayrasp[(sender as ListBox).SelectedIndex].Split(" | ");
                FinalDispTextBlock.Text = para[1];

                List <List <string> > marks = new List <List <string> >();
                marks = await De_Serialization.Deserialisation <List <List <string> > >($"{para[1]}-{login[5]}.xml", CreationCollisionOption.OpenIfExists, marks);

                List <string> desiredday = new List <string>();
                foreach (List <string> day in marks)
                {
                    if (day[day.Count - 1] == RaspDatePicker.Date.ToString("dd.MM.yyyy"))
                    {
                        desiredday = day;
                    }
                }

                if (desiredday.Count != 0)
                {
                    foreach (string student in desiredday)
                    {
                        if (student.Contains(login[3]))
                        {
                            string[] getgrade = student.Split('|');
                            FinalGradeTextBlock.Text = getgrade[0];
                            break;
                        }
                        else
                        {
                            FinalGradeTextBlock.Text = "Не выставлено";
                        }
                    }
                }
                else
                {
                    FinalGradeTextBlock.Text = "Не выставлено";
                }
            }
        }
Ejemplo n.º 12
0
        //---------------------------------------------------------------------------------------------------------------------------------------------Кнопки для расписания
        private async void RaspComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) //Выбор группы
        {
            login = new List <string>();
            login = await De_Serialization.Deserialisation <List <string> >("LoginData.xml", CreationCollisionOption.OpenIfExists, login);

            biglist = new List <List <string> >(new List <string> [6]);
            biglist = await De_Serialization.Deserialisation <List <List <string> > >($"{RaspComboBox.SelectedItem.ToString()}.xml", CreationCollisionOption.OpenIfExists, biglist);

            for (int i = 0; i < biglist.Count; i++)
            {
                List <string> smollist  = biglist[i];
                List <string> cleanlist = new List <string>();
                for (int g = 0; g < smollist.Count; g++)
                {
                    if (smollist[g].Contains(login[3]))
                    {
                        cleanlist.Add(smollist[g]);
                    }
                }

                biglist[i] = cleanlist;
                listBoxes[i].ItemsSource = biglist[i];
            }
        }
Ejemplo n.º 13
0
        //---------------------------------------------------------------------------------------------------------------------------------------------Кнопки для журнала
        private async void ListBoxItems() //Лист айтемы студентов + оценки
        {
            listbox.Items.Clear();
            List <UserData> groupstudent = new List <UserData>();

            foreach (UserData groupguy in students)
            {
                if (groupguy.DisciplineType == groupstring)
                {
                    groupstudent.Add(groupguy);
                }
            }
            savingmarks = new List <string>(new string[groupstudent.Count]);

            //Десериализация - начало
            if (discipstring != "" && groupstring != "")
            {
                marks = await De_Serialization.Deserialisation <List <List <string> > >($"{discipstring}-{groupstring}.xml", CreationCollisionOption.OpenIfExists, marks);
            }
            bool          confirm = false;
            List <string> data    = new List <string>();

            for (int i = 0; i < marks.Count; i++)
            {
                data = marks[i];
                if (data[data.Count - 1] == JournalDatePicker.Date.ToString("dd.MM.yyyy"))
                {
                    confirm = true;
                    break;
                }
            }
            //Десериализация - конец

            for (int i = 0; i < groupstudent.Count; i++)
            {
                ListBoxItem boxItem = new ListBoxItem();
                Grid        grid    = new Grid();

                boxItem.SizeChanged += (s, e) =>
                {
                    grid.Width = boxItem.ActualWidth - 25;
                };
                ColumnDefinition c1 = new ColumnDefinition();
                c1.Width = new GridLength(1, GridUnitType.Star);
                grid.ColumnDefinitions.Add(c1);
                ColumnDefinition c2 = new ColumnDefinition();
                c2.Width = new GridLength(1, GridUnitType.Auto);
                grid.ColumnDefinitions.Add(c2);

                TextBlock disciptextBox = new TextBlock();
                disciptextBox.FontSize            = 18;
                disciptextBox.Text                = $"{groupstudent[i].Surname} {groupstudent[i].Name}";
                disciptextBox.HorizontalAlignment = HorizontalAlignment.Stretch;
                Grid.SetColumn(disciptextBox, 0);
                grid.Children.Add(disciptextBox);

                ComboBox box = new ComboBox();
                box.Items.Add("5");
                box.Items.Add("4");
                box.Items.Add("3");
                box.Items.Add("2");
                box.Items.Add("НБ");
                if (confirm)
                {
                    string[] dapasplit = data[i].Split('|');
                    if (dapasplit[0] == "5")
                    {
                        box.SelectedIndex = 0;
                    }
                    if (dapasplit[0] == "4")
                    {
                        box.SelectedIndex = 1;
                    }
                    if (dapasplit[0] == "3")
                    {
                        box.SelectedIndex = 2;
                    }
                    if (dapasplit[0] == "2")
                    {
                        box.SelectedIndex = 3;
                    }
                    if (dapasplit[0] == "НБ")
                    {
                        box.SelectedIndex = 4;
                    }
                }
                box.HorizontalAlignment = HorizontalAlignment.Right;
                box.SelectionChanged   += (s, e) =>
                {
                    if (box.SelectedIndex != -1 && listbox.SelectedIndex != -1)
                    {
                        savingmarks[listbox.SelectedIndex] = $"{box.SelectedItem.ToString()}|{groupstudent[listbox.SelectedIndex].Surname}";
                    }
                };
                Grid.SetColumn(box, 1);
                grid.Children.Add(box);

                boxItem.Content = grid;
                listbox.Items.Add(boxItem);
            }
        }
Ejemplo n.º 14
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            login = await De_Serialization.Deserialisation <List <string> >("LoginData.xml", CreationCollisionOption.OpenIfExists, login);

            biglist = await De_Serialization.Deserialisation <List <List <string> > >($"{login[5]}.xml", CreationCollisionOption.OpenIfExists, biglist);
        }