private static void FillOrgStructure() { org = new Organisation("MyCompany"); org.AddDeparment(new Department("Main Department")); org.AddEmployee( new Programmer("Nikolay", "Dontsov", new DateTime(1990, 12, 22) , new Document("3243", "34234", Document.DocumentType.Passport), org.Departments[0]) ); org.AddDeparment(new Department("Second Department")); org.AddEmployee( new Programmer("Vasilyi", "Pupkin", new DateTime(1920, 12, 22) , new Document("3243", "34234", Document.DocumentType.DriverLicense), org.Departments[1]) ); }
/// <summary> /// Загрузка данных об организации из файла /// </summary> private static void FillOrgStructure() { org = new Organisation("MyCompany"); using (StreamReader streamReader = new StreamReader("InfoBase/departments.csv")) { while (!streamReader.EndOfStream) { org.AddDeparment(new Department(streamReader.ReadLine())); } } using (StreamReader streamReader = new StreamReader("InfoBase/employee.csv")) { string[] emp; int deptId; while (!streamReader.EndOfStream) { emp = streamReader.ReadLine().Split(';'); if (emp.Length == 7) { deptId = (from d in org.Departments where d.DepartmentName == emp[6] select d.DepartmentId).First(); org.AddEmployee(new Employee(emp[0], emp[1] , DateTime.Parse(emp[2], System.Globalization.CultureInfo.CurrentCulture) , (Document.DocumentTypes)Enum.Parse(typeof(Document.DocumentTypes), emp[3]) , emp[4], emp[5] , deptId)); } } } }
/// <summary> /// Добавить отдел /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void BtnAddDepartment_Click(object sender, RoutedEventArgs e) { DepartmentWindow departmentWindow = new DepartmentWindow(); departmentWindow.btnCancel.Click += (o, h) => departmentWindow.Close(); departmentWindow.btnAddDepartment.Click += (o, h) => { if (org.AddDeparment(new Department(departmentWindow.tbDeparmentName.Text))) { departmentWindow.Close(); } else { MessageBox.Show("Такой отдел уже есть"); } }; departmentWindow.Owner = mainWindow; departmentWindow.ShowDialog(); }