Пример #1
0
        private void AddCompanyAndPost(object parameter)
        {
            var currentWorkerCompanyAndPostViewModel = new CurrentCompanyAndPostViewModel(SelectedDirectoryWorkerStartDate, DateTime.Now);
            var currentWorkerCompanyAndPostView      = new CurrentCompanyAndPostView();

            currentWorkerCompanyAndPostView.DataContext = currentWorkerCompanyAndPostViewModel;
            currentWorkerCompanyAndPostView.ShowDialog();

            var currentCompanyAndPost = currentWorkerCompanyAndPostViewModel.CurrentCompanyAndPost;

            if (currentCompanyAndPost != null)
            {
                var postSalary = BC.GetDirectoryPostSalaryByDate(currentCompanyAndPost.DirectoryPost.Id, new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1));

                currentCompanyAndPost.Salary = IsAdminSalary ? postSalary.AdminWorkerSalary.Value : postSalary.UserWorkerSalary;

                if (CurrentCompaniesAndPosts.Any())
                {
                    var prevPost = CurrentCompaniesAndPosts.OrderByDescending(s => s.PostChangeDate).First(s => currentCompanyAndPost.PostChangeDate.Date >= s.PostChangeDate.Date);
                    prevPost.PostFireDate = currentCompanyAndPost.PostChangeDate.AddDays(-1);

                    int index = CurrentCompaniesAndPosts.ToList().IndexOf(prevPost);
                    if (index != (CurrentCompaniesAndPosts.Count - 1))
                    {
                        currentCompanyAndPost.PostFireDate = CurrentCompaniesAndPosts[index + 1].PostChangeDate.AddDays(-1);
                    }
                }

                CurrentCompaniesAndPosts.Add(currentCompanyAndPost);
                CurrentCompaniesAndPosts = new ObservableCollection <CurrentCompanyAndPost>(CurrentCompaniesAndPosts.OrderBy(p => p.PostChangeDate));
            }
        }
Пример #2
0
        private void EditCompanyAndPost(object parameter)
        {
            int prevIndex = SelectedIndexCurrentCompanyAndPost;
            var currentWorkerCompanyAndPostViewModel = new CurrentCompanyAndPostViewModel(SelectedCurrentCompanyAndPost, SelectedDirectoryWorkerStartDate, DateTime.Now);
            var currentWorkerCompanyAndPostView      = new CurrentCompanyAndPostView();

            currentWorkerCompanyAndPostView.DataContext = currentWorkerCompanyAndPostViewModel;
            currentWorkerCompanyAndPostView.ShowDialog();

            var currentCompanyAndPost = currentWorkerCompanyAndPostViewModel.CurrentCompanyAndPost;

            if (currentCompanyAndPost != null)
            {
                var postSalary = BC.GetDirectoryPostSalaryByDate(currentCompanyAndPost.DirectoryPost.Id, new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1));

                currentCompanyAndPost.Salary     = IsAdminSalary ? postSalary.AdminWorkerSalary.Value : postSalary.UserWorkerSalary;
                currentCompanyAndPost.HalfSalary = postSalary.UserWorkerHalfSalary ?? 0;

                if (CurrentCompaniesAndPosts.Any())
                {
                    var prevPost = CurrentCompaniesAndPosts[prevIndex != 0 ? prevIndex - 1 : 0];
                    prevPost.PostFireDate = currentCompanyAndPost.PostChangeDate.AddDays(-1);

                    if (prevIndex != (CurrentCompaniesAndPosts.Count - 1))
                    {
                        currentCompanyAndPost.PostFireDate = CurrentCompaniesAndPosts[prevIndex + 1].PostChangeDate.AddDays(-1);
                    }
                }

                CurrentCompaniesAndPosts.Remove(SelectedCurrentCompanyAndPost);
                CurrentCompaniesAndPosts.Insert(prevIndex, currentCompanyAndPost);
            }
        }
Пример #3
0
 private bool CanAddingWorker(object parameter)
 {
     return(IsValidateAllProperties() && CurrentCompaniesAndPosts.Any());
 }