示例#1
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            var response = new EmployeeProfessionItemSQLiteRepository().SetStatusDeleted(CurrentEmployeeProfessionDG.Identifier);

            if (response.Success)
            {
                MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Stavka_je_uspešno_obrisanaUzvičnik"));

                CurrentEmployeeProfessionForm            = new EmployeeProfessionItemViewModel();
                CurrentEmployeeProfessionForm.Identifier = Guid.NewGuid();
                CurrentEmployeeProfessionForm.ItemStatus = ItemStatus.Added;

                CurrentEmployeeProfessionDG = null;

                EmployeeCreatedUpdated();

                Thread displayThread = new Thread(() => DisplayEmployeeProfessionData());
                displayThread.IsBackground = true;
                displayThread.Start();
            }
            else
            {
                MainWindow.ErrorMessage = response.Message;
            }
        }
示例#2
0
        public void DisplayEmployeeProfessionData()
        {
            EmployeeProfessionDataLoading = true;

            EmployeeProfessionItemListResponse response = new EmployeeProfessionItemSQLiteRepository()
                                                          .GetEmployeeProfessionsByEmployee(MainWindow.CurrentCompanyId, CurrentEmployee.Identifier);

            if (response.Success)
            {
                EmployeeProfessionsFromDB = new ObservableCollection <EmployeeProfessionItemViewModel>(
                    response.EmployeeProfessionItems ?? new List <EmployeeProfessionItemViewModel>());
            }
            else
            {
                EmployeeProfessionsFromDB = new ObservableCollection <EmployeeProfessionItemViewModel>();
            }

            EmployeeProfessionDataLoading = false;
        }
示例#3
0
        private void btnAddEmployee_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (CurrentEmployeeProfessionForm.Profession?.Name == null)
            {
                MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_polje_naziv_profesije"));
                return;
            }

            #endregion

            Thread th = new Thread(() =>
            {
                SubmitButtonEnabled = false;


                CurrentEmployeeProfessionForm.Employee = CurrentEmployee;


                CurrentEmployeeProfessionForm.Company = new CompanyViewModel()
                {
                    Id = MainWindow.CurrentCompanyId
                };
                CurrentEmployeeProfessionForm.CreatedBy = new UserViewModel()
                {
                    Id = MainWindow.CurrentUserId
                };

                new EmployeeProfessionItemSQLiteRepository().Delete(CurrentEmployeeProfessionForm.Identifier);
                var response = new EmployeeProfessionItemSQLiteRepository().Create(CurrentEmployeeProfessionForm);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = response.Message;

                    CurrentEmployeeProfessionForm            = new EmployeeProfessionItemViewModel();
                    CurrentEmployeeProfessionForm.Identifier = Guid.NewGuid();
                    CurrentEmployeeProfessionForm.ItemStatus = ItemStatus.Added;
                    CurrentEmployeeProfessionForm.IsSynced   = false;
                    return;
                }

                CurrentEmployeeProfessionForm            = new EmployeeProfessionItemViewModel();
                CurrentEmployeeProfessionForm.Identifier = Guid.NewGuid();
                CurrentEmployeeProfessionForm.ItemStatus = ItemStatus.Added;
                CurrentEmployeeProfessionForm.IsSynced   = false;
                EmployeeCreatedUpdated();

                DisplayEmployeeProfessionData();

                Application.Current.Dispatcher.BeginInvoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new Action(() =>
                {
                    popCountry.Focus();
                })
                    );

                SubmitButtonEnabled = true;
            });
            th.IsBackground = true;
            th.Start();
        }