Exemple #1
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            var response = new EmployeeCardSQLiteRepository().SetStatusDeleted(CurrentEmployeeCardDG.Identifier);

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

                CurrentEmployeeCardForm            = new EmployeeCardViewModel();
                CurrentEmployeeCardForm.Identifier = Guid.NewGuid();
                CurrentEmployeeCardForm.ItemStatus = ItemStatus.Added;

                CurrentEmployeeCardDG = null;

                EmployeeCreatedUpdated();

                Thread displayThread = new Thread(() => DisplayEmployeeCardData());
                displayThread.IsBackground = true;
                displayThread.Start();
            }
            else
            {
                MainWindow.ErrorMessage = response.Message;
            }
        }
Exemple #2
0
        public void DisplayEmployeeCardData()
        {
            EmployeeCardDataLoading = true;

            EmployeeCardListResponse response = new EmployeeCardSQLiteRepository()
                                                .GetEmployeeCardsByEmployee(MainWindow.CurrentCompanyId, CurrentEmployee.Identifier);

            if (response.Success)
            {
                EmployeeCardsFromDB = new ObservableCollection <EmployeeCardViewModel>(
                    response.EmployeeCards ?? new List <EmployeeCardViewModel>());
            }
            else
            {
                EmployeeCardsFromDB = new ObservableCollection <EmployeeCardViewModel>();
            }

            EmployeeCardDataLoading = false;
        }
Exemple #3
0
        private void btnAddCard_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (CurrentEmployeeCardForm.Description == null)
            {
                MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Opis"));
                return;
            }

            #endregion

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


                CurrentEmployeeCardForm.Employee = CurrentEmployee;


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

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

                    CurrentEmployeeCardForm            = new EmployeeCardViewModel();
                    CurrentEmployeeCardForm.Identifier = Guid.NewGuid();
                    CurrentEmployeeCardForm.ItemStatus = ItemStatus.Added;
                    CurrentEmployeeCardForm.IsSynced   = false;
                    return;
                }

                CurrentEmployeeCardForm            = new EmployeeCardViewModel();
                CurrentEmployeeCardForm.Identifier = Guid.NewGuid();
                CurrentEmployeeCardForm.ItemStatus = ItemStatus.Added;
                CurrentEmployeeCardForm.IsSynced   = false;
                EmployeeCreatedUpdated();

                DisplayEmployeeCardData();

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

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