Ejemplo n.º 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 group in ClassGroups)
                        {
                            if (group.NameOfGroup.Equals(parts[0].Trim(' ')))
                            {
                                exist = true;
                            }
                        }
                        if (!exist)
                        {
                            Department Department = null;
                            foreach (var dep in departments)
                            {
                                if (dep.NameOfDepartment.Equals(parts[2].Trim(' ')))
                                {
                                    Department = dep;
                                }
                            }
                            if (Department != null)
                            {
                                Group group = new Group
                                {
                                    NameOfGroup = parts[0].Trim(' '),
                                    Term        = Convert.ToInt32(parts[1].Trim(' ')),
                                    Department  = Department
                                };

                                if (RequestToDataBase.Instance.requestInsertIntoGroup(group))
                                {
                                    ClassGroups.Add(group);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void Add()
        {
            var context = new GroupVM(departments.ToArray());
            var wing    = new NewGroup()
            {
                DataContext = context
            };

            wing.ShowDialog();
            System.Console.WriteLine(context.Group != null);
            if (context.Group != null)
            {
                ClassGroups.Add(context.Group);
            }
        }
Ejemplo n.º 3
0
        private void Add()
        {
            var context = new GroupVM(departments.ToArray());
            var wind    = new NewGroup()
            {
                DataContext = context
            };

            wind.ShowDialog();
            if (wind.DialogResult == true)
            {
                if (context.Group != null)
                {
                    if (RequestToDataBase.Instance.requestInsertIntoGroup(context.Group))
                    {
                        ClassGroups.Add(context.Group);
                    }
                }
            }
        }