예제 #1
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (CurrentEmployeeOnBusinessPartner == null)
            {
                MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Radnik_u_odabranoj_firmi"));
                return;
            }

            #endregion

            Thread th = new Thread(() =>
            {
                EmployeeByBusinessPartnerResponse response = employeeByBusinessPartnerService.Delete(CurrentEmployeeOnBusinessPartner);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_brisanja_sa_serveraUzvičnik"));
                    return;
                }

                response = new EmployeeByBusinessPartnerSQLiteRepository().Delete(CurrentEmployeeOnBusinessPartner.Identifier, CurrentBusinessPartner.Identifier);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_lokalnog_brisanjaUzvičnik"));
                    return;
                }

                Sync();
            });
            th.IsBackground = true;
            th.Start();
        }
예제 #2
0
        public void DisplayEmployeesOnBusinessPartnerData()
        {
            EmployeeOnBusinessPartnerDataLoading = true;

            EmployeeByBusinessPartnerListResponse response = new EmployeeByBusinessPartnerSQLiteRepository()
                                                             .GetByBusinessPartner(CurrentBusinessPartner.Identifier, "", currentPageRight, itemsPerPageRight);

            if (response.Success)
            {
                EmployeesOnBusinessPartnerFromDB = new ObservableCollection <EmployeeByBusinessPartnerViewModel>(response?.EmployeeByBusinessPartners ?? new List <EmployeeByBusinessPartnerViewModel>());
                totalItemsRight = response.TotalItems;
            }
            else
            {
                EmployeesOnBusinessPartnerFromDB = new ObservableCollection <EmployeeByBusinessPartnerViewModel>();
                totalItemsRight         = 0;
                MainWindow.ErrorMessage = response.Message;
            }

            int itemFrom = totalItemsRight != 0 ? (currentPageRight - 1) * itemsPerPageRight + 1 : 0;
            int itemTo   = currentPageRight * itemsPerPageRight < totalItemsRight ? currentPageRight * itemsPerPageRight : totalItemsRight;

            PaginationDisplayRight = itemFrom + " - " + itemTo + " od " + totalItemsRight;

            EmployeeOnBusinessPartnerDataLoading = false;
        }
예제 #3
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (CurrentEmployeeNotOnBusinessPartner == null)
            {
                MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Radnik_bez_firme"));
                return;
            }

            #endregion

            Thread th = new Thread(() =>
            {
                EmployeeByBusinessPartnerViewModel employeeByBusinessPartner = new EmployeeByBusinessPartnerViewModel()
                {
                    Identifier      = Guid.NewGuid(),
                    Employee        = CurrentEmployeeNotOnBusinessPartner,
                    BusinessPartner = CurrentBusinessPartner,
                    StartDate       = CurrentEmployeeNotOnBusinessPartner.ContractStartDate,
                    EndDate         = CurrentEmployeeNotOnBusinessPartner.ContractEndDate,
                    Company         = new CompanyViewModel()
                    {
                        Id = MainWindow.CurrentCompanyId
                    },
                    CreatedBy = new UserViewModel()
                    {
                        Id = MainWindow.CurrentUserId
                    }
                };

                EmployeeByBusinessPartnerResponse response = new EmployeeByBusinessPartnerSQLiteRepository().Create(employeeByBusinessPartner);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_lokalnog_čuvanjaUzvičnik"));
                    return;
                }

                response = employeeByBusinessPartnerService.Create(employeeByBusinessPartner);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Podaci_su_sačuvani_u_lokaluUzvičnikTačka_Greška_kod_čuvanja_na_serveruUzvičnik"));
                    return;
                }

                MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Podaci_su_uspešno_unetiUzvičnik"));

                DisplayEmployeesNotOnBusinessPartnerData();
                DisplayEmployeesOnBusinessPartnerData();
            });
            th.IsBackground = true;
            th.Start();
        }