Esempio n. 1
0
 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])
         );
 }
Esempio n. 2
0
 /// <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));
             }
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Добавить сотрудника
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void BtnAddEmployee_Click(object sender, RoutedEventArgs e)
        {
            EmployeeWindow employeeWindow = new EmployeeWindow();

            employeeWindow.btnCancel.Click           += (o, h) => employeeWindow.Close();
            employeeWindow.cbDocumentType.ItemsSource = Enum.GetValues(typeof(Document.DocumentTypes));
            employeeWindow.cbDepartment.ItemsSource   = org.Departments;
            employeeWindow.btnAddEmployee.Click      += (o, h) =>
            {
                if (!String.IsNullOrEmpty(employeeWindow.tbFirstName.Text) && !String.IsNullOrEmpty(employeeWindow.tbSecondName.Text) &&
                    employeeWindow.dpBirthDay.SelectedDate.HasValue && employeeWindow.cbDocumentType.SelectedItem != null &&
                    !String.IsNullOrEmpty(employeeWindow.tbSerial.Text) && !String.IsNullOrEmpty(employeeWindow.tbNumber.Text))
                {
                    if (org.AddEmployee(new Employee(
                                            employeeWindow.tbFirstName.Text
                                            , employeeWindow.tbSecondName.Text
                                            , employeeWindow.dpBirthDay.SelectedDate.Value
                                            , (Document.DocumentTypes)employeeWindow.cbDocumentType.SelectedItem
                                            , employeeWindow.tbSerial.Text, employeeWindow.tbNumber.Text
                                            , (employeeWindow.cbDepartment.SelectedItem as Department).DepartmentId
                                            )))
                    {
                        mainWindow.lbEmployees.ItemsSource = org.GetEmployees((mainWindow.lbDepartments.SelectedItem as Department).DepartmentId);
                        employeeWindow.Close();
                    }
                    else
                    {
                        MessageBox.Show("Такой сотрудник уже есть");
                    }
                }
                else
                {
                    MessageBox.Show("Заполните все параметры");
                }
            };
            employeeWindow.Owner = mainWindow;
            employeeWindow.ShowDialog();
        }