Exemple #1
0
        public void CreateFireDocument(VPEmployee emp, string reason)
        {
            string currentPath = Environment.CurrentDirectory;

            currentPath = currentPath.Remove(currentPath.IndexOf(@"\VacationPlus"));
            FlowDocument fw     = new FlowDocument();
            Paragraph    mainpr = new Paragraph();

            mainpr.Inlines.Add(new Bold(new Run($"\tОб увольнении {emp.fullName}")));
            Paragraph textpr1 = new Paragraph();
            Paragraph textpr2 = new Paragraph();
            Paragraph textpr3 = new Paragraph();

            textpr1.Inlines.Add(new Run($"Данный сотрудник был уволен из отдела -> \"{emp.deptName}\","));
            textpr2.Inlines.Add(new Run($"по причине -> \"{ reason }.\""));
            textpr3.Inlines.Add(new Run($"Дата увольнения -> {DateTime.Now.ToShortDateString()}"));
            fw.Blocks.Add(mainpr);
            fw.Blocks.Add(textpr1);
            fw.Blocks.Add(textpr2);
            fw.Blocks.Add(textpr3);
            var content = new TextRange(fw.ContentStart, fw.ContentEnd);

            if (content.CanSave(DataFormats.Rtf))
            {
                using (FileStream stream = new FileStream(currentPath + $@"\VacationPlus\VacationPlus\Documents\Fire\{emp.id}_{emp.fullName}.rtf", FileMode.CreateNew, FileAccess.Write))
                { content.Save(stream, DataFormats.Rtf); }
            }

            if (File.Exists(currentPath + $@"\VacationPlus\VacationPlus\Documents\Hire\{emp.id}_{emp.fullName}.rtf"))
            {
                File.Delete(currentPath + $@"\VacationPlus\VacationPlus\Documents\Hire\{emp.id}_{emp.fullName}.rtf");
            }
        }
Exemple #2
0
        public void CreateHireDocument(VPEmployee emp)
        {
            string currentPath = Environment.CurrentDirectory;

            currentPath  = currentPath.Remove(currentPath.IndexOf(@"\VacationPlus"));
            currentPath += @"\VacationPlus\VacationPlus\Documents\Hire";
            FlowDocument fw     = new FlowDocument();
            Paragraph    mainpr = new Paragraph();

            mainpr.Inlines.Add(new Bold(new Run($"\tОб принятии на работу {emp.fullName}")));
            Paragraph textpr1 = new Paragraph();
            Paragraph textpr2 = new Paragraph();

            textpr1.Inlines.Add(new Run($"Данный сотрудник впредь работает в отделе -> \"{emp.deptName}\""));
            textpr2.Inlines.Add(new Run($"Дата принятия -> {DateTime.Now.ToShortDateString()}"));
            fw.Blocks.Add(mainpr);
            fw.Blocks.Add(textpr1);
            fw.Blocks.Add(textpr2);
            var content = new TextRange(fw.ContentStart, fw.ContentEnd);

            if (content.CanSave(DataFormats.Rtf))
            {
                using (FileStream stream = new FileStream(currentPath + $@"\{emp.id}_{emp.fullName}.rtf", FileMode.CreateNew, FileAccess.Write))
                { content.Save(stream, DataFormats.Rtf); }
            }
        }
 public EmployeeWindowLogic()
 {
     currentUser = new VPEmployee()
     {
         address        = StaticData.Employee.address,
         workbegin      = StaticData.Employee.workbegin,
         cityID         = StaticData.Employee.cityID,
         cityName       = db.Cities.FirstOrDefault(temp => temp.id == StaticData.Employee.cityID).name,
         countryID      = StaticData.Employee.countryID,
         countryName    = db.Countries.FirstOrDefault(temp => temp.id == StaticData.Employee.countryID).name,
         deptID         = StaticData.Employee.departmentID,
         deptName       = db.Departments.FirstOrDefault(temp => temp.id == StaticData.Employee.departmentID).name,
         email          = StaticData.Employee.email,
         fullName       = StaticData.Employee.fullName,
         id             = StaticData.Employee.id,
         login          = StaticData.Employee.login,
         password       = StaticData.Employee.password,
         phoneNumber    = StaticData.Employee.phoneNumber,
         vacationStatus = StaticData.Employee.vacationStatus == 1 ? true : false
     };
     StaticData.Vacation            = db.Vacations.FirstOrDefault(item => item.idEmp == currentUser.id);
     StaticData.Vacation.daysCount  = (DateTime.Now - currentUser.workbegin.GetValueOrDefault()).Days;
     StaticData.Vacation.daysCount /= 30;//Кол-во месяцев
     StaticData.Vacation.daysCount  = StaticData.Vacation.daysCount * 2;
     dayscount = StaticData.Vacation.daysCount;
     db.SaveChanges();
 }
Exemple #4
0
        private void EmpList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            VPEmployee temp = EmpList.SelectedItem as VPEmployee;

            if (temp != null)
            {
                for (int i = 0; i < DeptComboBox.Items.Count; i++)
                {
                    if ((DeptComboBox.Items[i] as ComboBoxItem).Content.ToString() == temp.deptName)
                    {
                        DeptComboBox.SelectedIndex = i;
                        break;
                    }
                }
                for (int i = 0; i < CountryComboBox.Items.Count; i++)
                {
                    if ((CountryComboBox.Items[i] as ComboBoxItem).Content.ToString() == temp.countryName)
                    {
                        CountryComboBox.SelectedIndex = i;
                        break;
                    }
                }
                for (int i = 0; i < CityComboBox.Items.Count; i++)
                {
                    if ((CityComboBox.Items[i] as ComboBoxItem).Content.ToString() == temp.cityName)
                    {
                        CityComboBox.SelectedIndex = i;
                        break;
                    }
                }
                if (temp.vacationStatus == false)
                {
                    StateLabel.Content = "Не на отпуске";
                }
                else
                {
                    StateLabel.Content = "На отпуске";
                }
            }
        }
Exemple #5
0
 private void DeclineVacationButton_Click(object sender, RoutedEventArgs e)
 {
     if (EmpList.SelectedItem != null)
     {
         VPEmployee temp = EmpList.SelectedItem as VPEmployee;
         if (temp.vacationStatus == true)
         {
             AdminWindow.logic.DeclineVacation(temp.id);
             AdminWindow.SetSettingLabel("Сотрудник отозван!");
             EmpList.ItemsSource = AdminWindow.logic.GetEmpList();
             UpdateAllComboBoxes();
         }
         else
         {
             AdminWindow.SetSettingLabel("Данный сотрудник не на отпуске!");
         }
     }
     else
     {
         AdminWindow.SetSettingLabel("Выберите сотрудника!");
     }
 }