Exemplo n.º 1
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            var response = new EmployeeDocumentSQLiteRepository().SetStatusDeleted(CurrentEmployeeDocumentDG.Identifier);

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

                CurrentEmployeeDocumentForm            = new EmployeeDocumentViewModel();
                CurrentEmployeeDocumentForm.Identifier = Guid.NewGuid();
                CurrentEmployeeDocumentForm.CreateDate = DateTime.Now;
                CurrentEmployeeDocumentForm.ItemStatus = ItemStatus.Added;

                CurrentEmployeeDocumentDG = null;

                EmployeeCreatedUpdated();

                Thread displayThread = new Thread(() => DisplayEmployeeDocumentData());
                displayThread.IsBackground = true;
                displayThread.Start();
            }
            else
            {
                MainWindow.ErrorMessage = response.Message;
            }
        }
Exemplo n.º 2
0
        public void DisplayEmployeeDocumentData()
        {
            EmployeeDocumentDataLoading = true;

            EmployeeDocumentListResponse response = new EmployeeDocumentSQLiteRepository()
                                                    .GetEmployeeDocumentsByEmployee(MainWindow.CurrentCompanyId, CurrentEmployee.Identifier);

            if (response.Success)
            {
                EmployeeDocumentsFromDB = new ObservableCollection <EmployeeDocumentViewModel>(
                    response.EmployeeDocuments ?? new List <EmployeeDocumentViewModel>());
            }
            else
            {
                EmployeeDocumentsFromDB = new ObservableCollection <EmployeeDocumentViewModel>();
            }

            EmployeeDocumentDataLoading = false;
        }
        private void DisplayEmployeeDocumentData()
        {
            EmployeeDocumentDataLoading = true;

            EmployeeDocumentListResponse response = new EmployeeDocumentSQLiteRepository()
                                                    .GetFilteredEmployeeDocuments(MainWindow.CurrentCompanyId, FilterEmployeeDocuments);

            if (response.Success)
            {
                EmployeeDocumentsFromDB = new ObservableCollection <EmployeeDocumentViewModel>(
                    response.EmployeeDocuments ?? new List <EmployeeDocumentViewModel>());
            }
            else
            {
                EmployeeDocumentsFromDB = new ObservableCollection <EmployeeDocumentViewModel>();
            }

            EmployeeDocumentDataLoading = false;
        }
Exemplo n.º 4
0
        private void btnAddDocument_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (CurrentEmployeeDocumentForm.Name == null)
            {
                MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Naziv"));
                return;
            }

            #endregion

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


                CurrentEmployeeDocumentForm.Employee = CurrentEmployee;


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

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

                    CurrentEmployeeDocumentForm            = new EmployeeDocumentViewModel();
                    CurrentEmployeeDocumentForm.Identifier = Guid.NewGuid();
                    CurrentEmployeeDocumentForm.CreateDate = DateTime.Now;
                    CurrentEmployeeDocumentForm.ItemStatus = ItemStatus.Added;
                    CurrentEmployeeDocumentForm.IsSynced   = false;
                    return;
                }

                CurrentEmployeeDocumentForm            = new EmployeeDocumentViewModel();
                CurrentEmployeeDocumentForm.Identifier = Guid.NewGuid();
                CurrentEmployeeDocumentForm.CreateDate = DateTime.Now;
                CurrentEmployeeDocumentForm.ItemStatus = ItemStatus.Added;
                CurrentEmployeeDocumentForm.IsSynced   = false;
                EmployeeCreatedUpdated();

                DisplayEmployeeDocumentData();

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

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