private void Add() { var context = new FacultyVM(); var wind = new NewFaculty() { DataContext = context }; wind.ShowDialog(); if (context.Faculty != null) { ClassFaculty.Add(context.Faculty); } }
private void Load() { string pathToCsv = ""; OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Файл csv|*.csv"; if (openFileDialog.ShowDialog() == true) { pathToCsv = openFileDialog.FileName; } if (!String.IsNullOrEmpty(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 faculty in ClassFaculty) { if (faculty.NameOfFaculty.Equals(parts[0].Trim(' '))) { exist = true; } } if (!exist) { Faculty faculty = new Faculty { NameOfFaculty = parts[0].Trim(' ') }; if (RequestToDataBase.Instance.requestInsertIntoFaculty(faculty)) { ClassFaculty.Add(faculty); } } } reader.Close(); } } }
private void Add() { var context = new FacultyVM(); var wind = new NewFaculty() { DataContext = context }; wind.ShowDialog(); if (wind.DialogResult == true) { if (context.Faculty != null) { if (RequestToDataBase.Instance.requestInsertIntoFaculty(context.Faculty)) { ClassFaculty.Add(context.Faculty); } } } }