예제 #1
0
        private void Load()
        {
            string         pathToCsv      = "";
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Файл csv|*.csv";
            if (openFileDialog.ShowDialog() == true)
            {
                pathToCsv = openFileDialog.FileName;
            }
            if (File.Exists(pathToCsv))
            {
                char[] delimiters = new char[] { ';' };
                using (StreamReader reader = new StreamReader(pathToCsv, System.Text.Encoding.Default))
                {
                    while (true)
                    {
                        string line = reader.ReadLine();
                        if (line == null)
                        {
                            break;
                        }
                        string[] parts = line.Split(delimiters);
                        bool     exist = false;
                        foreach (var subject in ClassSubject)
                        {
                            if (subject.NameOfSubject.Equals(parts[0].Trim(' ')))
                            {
                                exist = true;
                            }
                        }
                        if (!exist)
                        {
                            Department Department = null;
                            foreach (var dep in departments)
                            {
                                if (dep.NameOfDepartment.Equals(parts[1].Trim(' ')))
                                {
                                    Department = dep;
                                }
                            }
                            if (Department != null)
                            {
                                Subject subject = new Subject
                                {
                                    NameOfSubject = parts[0].Trim(' '),
                                    Department    = Department
                                };

                                if (RequestToDataBase.Instance.requestInsertIntoSubject(subject))
                                {
                                    ClassSubject.Add(subject);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
        private void Add()
        {
            var context = new SubjectVM(departments.ToArray());
            var wins    = new NewSubject()
            {
                DataContext = context
            };

            wins.ShowDialog();
            System.Console.WriteLine(context.Subject != null);
            if (context.Subject != null)
            {
                ClassSubject.Add(context.Subject);
            }
        }
예제 #3
0
        private void Add()
        {
            var context = new SubjectVM(departments.ToArray());
            var wind    = new NewSubject()
            {
                DataContext = context
            };

            wind.ShowDialog();
            if (wind.DialogResult == true)
            {
                if (context.Subject != null)
                {
                    if (RequestToDataBase.Instance.requestInsertIntoSubject(context.Subject))
                    {
                        ClassSubject.Add(context.Subject);
                    }
                }
            }
        }