Exemplo n.º 1
0
        void OpenHandler()
        {
            Debtors.Clear();

            string         filePath       = null;
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";

            if (openFileDialog.ShowDialog() == true)
            {
                filePath = openFileDialog.FileName;

                using (StreamReader reader = new StreamReader(filePath))
                {
                    string inputFromFile;

                    while ((inputFromFile = reader.ReadLine()) != null)
                    {
                        string[] words      = inputFromFile.Split(",");
                        Debtor   openDebtor = new Debtor(words[0], 0);
                        for (int i = 1; i < words.Length - 1; i += 2)
                        {
                            Debt openDebt = new Debt(words[i], double.Parse(words[i + 1]));
                            openDebtor.DebtsList.Add(openDebt);
                        }
                        Debtors.Add(openDebtor);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void NewFileCommand_Execute()
        {
            MessageBoxResult res = MessageBox.Show("Any unsaved data will be lost. Are you sure you want to initiate a new file?", "Warning",
                                                   MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);

            if (res == MessageBoxResult.Yes)
            {
                Debtors.Clear();
                filename = "";
            }
        }
Exemplo n.º 3
0
        private void ListOfDebtorsForm_Activated(object sender, EventArgs e)
        {
            _debtors.Clear();

            // проходим по всем семестрам, начиная с меньшего номера
            foreach (var semester in _root.Semesters.OrderBy(x => x.Number))
            {
                // смотрим в списке успеваемости для данного семестра
                foreach (var performances in _root.Performances.Where(x => x.IdSemester == semester.IdSemester)
                         .GroupBy(x => x.IdStudent).OrderBy(x => x.Key.ToString()))
                {
                    foreach (var item in performances.Where(x => x.Grade == Grade.Незачёт))
                    {
                        if (_root.Students.FirstOrDefault(x => x.IdStudent == item.IdStudent) == null)
                        {
                            continue;
                        }
                        // заполняем список должников
                        _debtors.Add(new Debtor
                        {
                            IdStudent    = item.IdStudent,
                            IdStudyGroup = Helper.GetStudentGroupId(item.IdStudent),
                            IdSemester   = item.IdSemester,
                            IdMatter     = item.IdMatter
                        });
                    }
                }
            }
            // заполняем таблицу фильтрованными значениями
            var panel = GridPanelBuilder.BuildPropertyPanel(_root, new Debtor(), _debtors);

            GridPanelBuilder.HideButtonsPanel(panel);
            panel.GridSelectedChanged += Panel_GridSelectedChanged;
            panel1.Controls.Add(panel);
            // предыдущую панель убираем
            if (panel1.Controls.Count > 1)
            {
                panel1.Controls.RemoveAt(0);
            }
            panel1.Enabled = true;
        }