Пример #1
0
        private void AddWorkerIDButton(object sender, System.Windows.RoutedEventArgs e)
        {
            if (globalDatabasePath != null)
            {
                CommonOpenFileDialog dialogFileSelect = new CommonOpenFileDialog();
                dialogFileSelect.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                dialogFileSelect.Filters.Add(new CommonFileDialogFilter("Arkusz programu Microsoft Excel (*.xlsx)", ".xlsx"));
                if (dialogFileSelect.ShowDialog() == CommonFileDialogResult.Ok)
                {
                    //Update DB
                    if (DatabaseHandling.AddWorkerID(globalDatabasePath, dialogFileSelect.FileName) == 0)
                    {
                        this.ShowMessageAsync("Błąd pliku", "Wybrany plik jest niepoprawny, pusty lub otwarty");
                        return;
                    }

                    //Fill list
                    MainList.ItemsSource = DatabaseHandling.LoadAllByDate(globalDatabasePath);
                    this.ShowMessageAsync("Gotowe", "Załadowano kodowanie.");
                }
            }
            else
            {
                this.ShowMessageAsync("Brak danych", "Dodaj najpierw plik");
            }
        }
Пример #2
0
        private void ResetFilterButton(object sender, System.Windows.RoutedEventArgs e)
        {
            DateFromPicker.SelectedDate = null;
            DateToPicker.SelectedDate   = null;
            CardID.Text      = "Kod karty";
            ServiceCard.Text = "Kod karty";

            if (globalDatabasePath != null)
            {
                MainList.ItemsSource = DatabaseHandling.LoadAllByDate(globalDatabasePath);
            }
        }
Пример #3
0
        private async void SelectFileButton(object sender, System.Windows.RoutedEventArgs e)
        {
            CommonOpenFileDialog dialogFileSelect = new CommonOpenFileDialog();

            dialogFileSelect.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            dialogFileSelect.Filters.Add(new CommonFileDialogFilter("Arkusz programu Microsoft Excel (*.xlsx)", ".xlsx"));
            if (dialogFileSelect.ShowDialog() == CommonFileDialogResult.Ok)
            {
                //Remove previous DB (if exists)
                if (globalDatabasePath != null)
                {
                    GC.Collect();
                    GC.WaitForPendingFinalizers();

                    File.Delete(globalDatabasePath);
                }

                globalDatabasePath = dialogFileSelect.FileName.Remove(dialogFileSelect.FileName.Length - 4, 4) + "sqlite";

                //Get size and verify file
                int rowNumber = DatabaseHandling.GetRowNumber(globalDatabasePath);

                ////////////////////////////////////////////////////////////////////////
                //                              DEMO                                  //
                ////////////////////////////////////////////////////////////////////////

                //if (rowNumber > 50)
                //{
                //    await this.ShowMessageAsync("DEMO", "Wersja demo obsługuje do 50 wierszy pliku wsadowego.");
                //    globalDatabasePath = null;
                //    return;
                //}

                ////////////////////////////////////////////////////////////////////////
                //                              DEMO                                  //
                ////////////////////////////////////////////////////////////////////////


                if (rowNumber == -1)
                {
                    await this.ShowMessageAsync("Błąd pliku", "Załadowany plik jest niepoprawny");

                    globalDatabasePath = null;
                    return;
                }
                else if (rowNumber == -2)
                {
                    await this.ShowMessageAsync("Plik w użyciu", "Wybrany plik jest otwarty. Zamknij go i spróbuj ponownie.");

                    globalDatabasePath = null;
                    return;
                }

                //Create DB
                ProgressDialogController controller = await this.ShowProgressAsync("Ładowanie", "Dane są odczytywane");

                controller.Maximum = (double)rowNumber;
                controller.Minimum = 0;

                IProgress <double> progress = new Progress <double>(value => controller.SetProgress(value));
                progress.Report(0);

                await Task.Run(() =>
                {
                    DatabaseHandling.CreateTempDB(globalDatabasePath);
                    DatabaseHandling.FillDB(globalDatabasePath, progress);
                });

                await controller.CloseAsync();

                //Fill list
                MainList.ItemsSource = DatabaseHandling.LoadAllByDate(globalDatabasePath);

                //Invalid file was loaded
                if (MainList.Items.Count == 0)
                {
                    await this.ShowMessageAsync("Błąd pliku", "Załadowany plik jest pusty lub niepoprawny.");

                    globalDatabasePath = null;
                }
            }
            else
            {
                return;
            }
        }