private async void onOkImportExec(object _param) { if (string.IsNullOrEmpty(FileNameImport)) { showError = App.Current.FindResource("please_select_file").ToString() + " csv."; IsVisError = System.Windows.Visibility.Visible; return; } else if (_lstColumn != _strColumnName) { showError = App.Current.FindResource("content_file_invalid").ToString() + "\t\t"; IsVisError = System.Windows.Visibility.Visible; return; } else { showError = string.Empty; IsVisError = System.Windows.Visibility.Collapsed; } FirstFloor.ModernUI.Windows.Controls.ModernDialog mdd = new FirstFloor.ModernUI.Windows.Controls.ModernDialog(); mdd.Buttons = new System.Windows.Controls.Button[] { mdd.OkButton, mdd.CancelButton }; mdd.OkButton.TabIndex = 0; mdd.OkButton.Content = App.Current.FindResource("ok").ToString(); mdd.CancelButton.TabIndex = 1; mdd.CancelButton.Content = App.Current.FindResource("cancel").ToString(); mdd.TabIndex = -1; mdd.Height = 200; mdd.Title = App.Current.FindResource("notification").ToString(); mdd.Content = App.Current.FindResource("confirm_import").ToString(); mdd.OkButton.Focus(); mdd.ShowDialog(); if (mdd.MessageBoxResult == System.Windows.MessageBoxResult.OK) { IsShowProgress = true; IsVisibleButton = System.Windows.Visibility.Collapsed; string _fileImport = FileNameImport; var slowTask = Task <string> .Factory.StartNew(() => this._ImportFromCSV(Path.GetFileNameWithoutExtension(_fileImport), _fileImport)); await slowTask; IsShowProgress = false; IsVisibleButton = System.Windows.Visibility.Visible; if (slowTask.Result.ToString() == "Success") { string _strText = App.Current.FindResource("import_success").ToString().Replace("$$", App.Current.FindResource("cash_register").ToString()); System.Windows.MessageBox.Show(_strText, "Successfull"); FileInfo fi = new System.IO.FileInfo(_fileImport); File.Delete(fi.DirectoryName.ToString() + "\\schema.ini"); StaticClass.GeneralClass.app_settings["appIsRestart"] = true; Model.UpgradeDatabase.updateAppSetting(StaticClass.GeneralClass.app_settings); System.Diagnostics.Process.Start(System.Windows.Application.ResourceAssembly.Location); System.Windows.Application.Current.Shutdown(); } else { System.Windows.MessageBox.Show(App.Current.FindResource("err_import_tryagain").ToString(), "Error"); FileInfo fi = new System.IO.FileInfo(_fileImport); File.Delete(fi.DirectoryName.ToString() + "\\schema.ini"); } } }
private void onBrowseExec(object _param) { try { Microsoft.Win32.OpenFileDialog _dlg = new Microsoft.Win32.OpenFileDialog(); _dlg.Multiselect = false; _dlg.Filter = "Text documents CSV|*.csv"; Nullable <bool> result = _dlg.ShowDialog(); if (result == true) { FileNameImport = _dlg.FileName; using (StreamReader reader = new StreamReader(FileNameImport)) { _lstColumn = reader.ReadLine().Trim(); } } } catch { FirstFloor.ModernUI.Windows.Controls.ModernDialog mdd = new FirstFloor.ModernUI.Windows.Controls.ModernDialog(); mdd.Buttons = new System.Windows.Controls.Button[] { mdd.CloseButton }; mdd.CloseButton.TabIndex = 0; mdd.CloseButton.Content = App.Current.FindResource("close").ToString(); mdd.Height = 200; mdd.Title = App.Current.FindResource("notification").ToString(); mdd.Content = App.Current.FindResource("file_err_open").ToString(); mdd.CloseButton.Focus(); mdd.ShowDialog(); } }
private void action_button_Click(object sender, RoutedEventArgs e) { TimeLoggerController.GetInstance().Log(new LogItem(String.Format("{0};{1};{2}", (DateTime)this.datetimepicker.SelectedDate, this.txtbox_start.Text, this.txtbox_end.Text))); //action_button.Foreground = Brushes.LightGreen; FirstFloor.ModernUI.Windows.Controls.ModernDialog dialog = new FirstFloor.ModernUI.Windows.Controls.ModernDialog() { Content = "Eintrag erfolgreich gespeichert!", Title = "Speichervorgang" }; dialog.ShowDialog(); }
static void ThrowException(Exception error, bool selectError = false, bool queryError = false) { HasSqlSelectException = selectError; var t = string.Empty; if (selectError) { t = $"SQL SELECT Query Exception"; } if (queryError) { t = $"SQL EXECUTE Exception"; } var v = new FirstFloor.ModernUI.Windows.Controls.ModernDialog { Title = $"{t} (pewpew lazers rule)", Content = error.Message }; //v.OkButton.Click += new RoutedEventHandler((o,a)=>{ MessageBox.Show("ok was clicked"); }); v.Buttons = new Button[] { v.OkButton, v.CancelButton }; var r = v.ShowDialog(); }
private async void onOkImportExec(object _param) { if (string.IsNullOrEmpty(FileNameImport)) { ShowError = App.Current.FindResource("sel_2_import").ToString(); IsVisError = System.Windows.Visibility.Visible; return; } else if (_lstColumn != _strColumnName) { ShowError = App.Current.FindResource("content_file_invalid").ToString(); IsVisError = System.Windows.Visibility.Visible; return; } else { ShowError = string.Empty; IsVisError = System.Windows.Visibility.Collapsed; } FirstFloor.ModernUI.Windows.Controls.ModernDialog mdd = new FirstFloor.ModernUI.Windows.Controls.ModernDialog(); mdd.Buttons = new System.Windows.Controls.Button[] { mdd.OkButton, mdd.CancelButton, }; mdd.OkButton.TabIndex = 0; mdd.OkButton.Content = App.Current.FindResource("ok").ToString(); mdd.CancelButton.TabIndex = 1; mdd.CancelButton.Content = App.Current.FindResource("cancel").ToString(); mdd.TabIndex = -1; mdd.Height = 200; mdd.Title = App.Current.FindResource("notification").ToString(); mdd.Content = App.Current.FindResource("confirm_import").ToString(); mdd.OkButton.Focus(); mdd.ShowDialog(); if (mdd.MessageBoxResult == System.Windows.MessageBoxResult.OK) { IsShowProgress = true; IsVisibleButton = System.Windows.Visibility.Collapsed; string _fileImport = FileNameImport; _getColumnName = getListColumnName(_tblName).Replace(", ", ",").Substring(12); string _isBackup = (StaticClass.GeneralClass.flag_database_type_general) ? _AutoBackupRestoreSqlServer(BackupRestore.backup, CashierRegisterDAL.ConnectionDB.getSqlServerDataBaseName()) : _AutoBackupRestoreSqlite(BackupRestore.backup); if ("Success" == _isBackup) { var slowTask = Task <string> .Factory.StartNew(() => this._ImportFromCSV(Path.GetFileNameWithoutExtension(_fileImport), _fileImport)); await slowTask; IsShowProgress = false; IsVisibleButton = System.Windows.Visibility.Visible; if (slowTask.Result.ToString() == "Success") { string _strText = App.Current.FindResource("import_success").ToString().Replace("$$", App.Current.FindResource("cash_register").ToString()); System.Windows.MessageBox.Show(_strText, "Successfull"); FileInfo fi = new System.IO.FileInfo(_fileImport); File.Delete(fi.DirectoryName.ToString() + "\\schema.ini"); StaticClass.GeneralClass.app_settings["appIsRestart"] = true; Model.UpgradeDatabase.updateAppSetting(StaticClass.GeneralClass.app_settings); System.Diagnostics.Process.Start(System.Windows.Application.ResourceAssembly.Location); System.Windows.Application.Current.Shutdown(); } else { System.Windows.MessageBox.Show(App.Current.FindResource("cannot_import").ToString() + " \t\t\t\t", "Error"); string _rs = (StaticClass.GeneralClass.flag_database_type_general) ? _AutoBackupRestoreSqlServer(BackupRestore.restore, CashierRegisterDAL.ConnectionDB.getSqlServerDataBaseName()) : _AutoBackupRestoreSqlite(BackupRestore.restore); if (_rs != "Success") { System.Windows.MessageBox.Show(App.Current.FindResource("import_err_restore_err").ToString(), "Error"); } FileInfo fi = new System.IO.FileInfo(_fileImport); File.Delete(fi.DirectoryName.ToString() + "\\schema.ini"); } } else { IsShowProgress = false; IsVisibleButton = System.Windows.Visibility.Visible; System.Windows.MessageBox.Show(App.Current.FindResource("error_before_import").ToString(), "Error"); } } }