コード例 #1
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            var response = new EmployeeLicenceItemSQLiteRepository().SetStatusDeleted(CurrentEmployeeLicenceDG.Identifier);

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

                CurrentEmployeeLicenceForm            = new EmployeeLicenceItemViewModel();
                CurrentEmployeeLicenceForm.Identifier = Guid.NewGuid();
                CurrentEmployeeLicenceForm.ItemStatus = ItemStatus.Added;

                CurrentEmployeeLicenceDG = null;

                EmployeeCreatedUpdated();

                Thread displayThread = new Thread(() => DisplayEmployeeLicenceData());
                displayThread.IsBackground = true;
                displayThread.Start();
            }
            else
            {
                MainWindow.ErrorMessage = response.Message;
            }
        }
コード例 #2
0
        public void DisplayEmployeeLicenceData()
        {
            EmployeeLicenceDataLoading = true;

            EmployeeLicenceItemListResponse response = new EmployeeLicenceItemSQLiteRepository()
                                                       .GetEmployeeLicencesByEmployee(MainWindow.CurrentCompanyId, CurrentEmployee.Identifier);

            if (response.Success)
            {
                EmployeeLicencesFromDB = new ObservableCollection <EmployeeLicenceItemViewModel>(
                    response.EmployeeLicenceItems ?? new List <EmployeeLicenceItemViewModel>());
            }
            else
            {
                EmployeeLicencesFromDB = new ObservableCollection <EmployeeLicenceItemViewModel>();
            }

            EmployeeLicenceDataLoading = false;
        }
コード例 #3
0
        private void btnAddLicence_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (CurrentEmployeeLicenceForm.Licence?.Description == null)
            {
                MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Licence"));
                return;
            }

            #endregion

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

                CurrentEmployeeLicenceForm.Employee = CurrentEmployee;

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

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

                    CurrentEmployeeLicenceForm            = new EmployeeLicenceItemViewModel();
                    CurrentEmployeeLicenceForm.Identifier = Guid.NewGuid();
                    CurrentEmployeeLicenceForm.ItemStatus = ItemStatus.Added;
                    CurrentEmployeeLicenceForm.IsSynced   = false;
                    return;
                }

                CurrentEmployeeLicenceForm            = new EmployeeLicenceItemViewModel();
                CurrentEmployeeLicenceForm.Identifier = Guid.NewGuid();
                CurrentEmployeeLicenceForm.ItemStatus = ItemStatus.Added;
                CurrentEmployeeLicenceForm.IsSynced   = false;
                EmployeeCreatedUpdated();

                DisplayEmployeeLicenceData();

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

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