Пример #1
0
 /// <summary>
 /// Metoda zawierająca inizjalizację wszystkich komend w widoku
 /// W tym widoku jest tylko jedna komenda opisana wyżej
 /// </summary>
 private void InitCommand()
 {
     CreateBaseCommand = new RelayCommand(() =>
     {
         if (PathName == null)
         {
             MessageBoxResult result = MessageBox.Show("Wybierz odpowiednie rozszerzenie",
                                                       "Confirmation", MessageBoxButton.OK);
         }
         else if (BaseName == null || BaseName == "")
         {
             MessageBoxResult result = MessageBox.Show("Podaj nazwę bazy",
                                                       "Confirmation", MessageBoxButton.OK);
         }
         else if (TableName == null || TableName == "")
         {
             MessageBoxResult result = MessageBox.Show("Podaj nazwę arkusza",
                                                       "Confirmation", MessageBoxButton.OK);
         }
         else if (BaseName.FirstOrDefault() >= '0' && BaseName.FirstOrDefault() <= '9')
         {
             MessageBoxResult result = MessageBox.Show("Nazwa nie powinna zaczynać się cyfrą\n" +
                                                       "lub być liczbą",
                                                       "Confirmation", MessageBoxButton.OK);
             BaseName = "";
         }
         else if (TableName.FirstOrDefault() >= '0' && TableName.FirstOrDefault() <= '9')
         {
             MessageBoxResult result = MessageBox.Show("Nazwa nie powinna zaczynać się cyfrą\n" +
                                                       "lub być liczbą",
                                                       "Confirmation", MessageBoxButton.OK);
             TableName = "";
         }
         else
         {
             string file = $"D:\\{BaseName}.{PathName}";
             var stream  = new FileStream(file, FileMode.Create, FileAccess.Write);
             //XSSFWorkbook workbook = new XSSFWorkbook();
             XSSFSheet sheet = (XSSFSheet)(App.workbook.CreateSheet($"{TableName}"));
             App.workbook.Write(stream);
             stream.Close();
             navigationService.NavigateTo(ViewModelLocator.CreateBaseAddColumnsKey, file);
         }
     });
 }