private void CspExtendedConfigClick(object sender, RoutedEventArgs e) { if (DataContext is SelectedPage.ViewModel viewModel) { var editor = new TextEditor(); AvalonExtension.SetInitialized(editor, true); AvalonExtension.SetMode(editor, AvalonEditMode.Ini); editor.Document = new TextDocument(viewModel.SelectedObject.CspExtraConfig ?? ""); var dialog = new ModernDialog { Title = "Edit CSP config", SizeToContent = SizeToContent.Manual, ResizeMode = ResizeMode.CanResizeWithGrip, LocationAndSizeKey = ".serverCspConfigEditor", MinWidth = 400, MinHeight = 240, Width = 800, Height = 640, MaxWidth = 99999, MaxHeight = 99999, Content = editor, Resources = new ResourceDictionary { Source = new Uri("/AcManager.Controls;component/Assets/TextEditor.xaml", UriKind.Relative) } }; dialog.Buttons = MessageDialogButton.OKCancel.GetButtons(dialog); if (dialog.ShowDialog() == true) { viewModel.SelectedObject.CspExtraConfig = editor.Text.Trim(); } if (!string.IsNullOrWhiteSpace(viewModel.SelectedObject.CspExtraConfig)) { viewModel.SelectedObject.RequiredCspVersion = Math.Max(viewModel.SelectedObject.RequiredCspVersion ?? 0, 1266); } } }
private void AddRouteActions(object obj) { var cnt = new Ship.BrowseRoute(); var dlg = new ModernDialog() { Title = "Ports", ResizeMode = System.Windows.ResizeMode.CanResizeWithGrip, Content = cnt }; dlg.ShowDialog(); if (cnt.SelectedItem != null && obj != null) { var stackpanel = (WrapPanel)obj; stackpanel.Children.Add(new RouteView(cnt.SelectedItem.Name)); this.Ports.Add(new Portview { Number = 1, Name = cnt.SelectedItem.Name }); } }
private static MessageBoxResult ShowMessageInner(string text, string title, MessageDialogButton button, ShowMessageCallbacks doNotAskAgainLoadSave, Window owner = null) { var value = doNotAskAgainLoadSave?.Item1?.Invoke(); if (value != null) { return(value.Value); } FrameworkElement content = new SelectableBbCodeBlock { Text = text, Margin = new Thickness(0, 0, 0, 8) }; CheckBox doNotAskAgainCheckbox; if (doNotAskAgainLoadSave != null) { doNotAskAgainCheckbox = new CheckBox { Content = new Label { Content = "Don’t ask again" } }; content = new SpacingStackPanel { Spacing = 8, Children = { content, doNotAskAgainCheckbox } }; } else { doNotAskAgainCheckbox = null; } var dlg = new ModernDialog { Title = title, Content = new ScrollViewer { Content = content, MaxWidth = 640, MaxHeight = 520, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled }, MinHeight = 0, MinWidth = 0, MaxHeight = 640, MaxWidth = 800 }; if (owner != null) { dlg.Owner = owner; } dlg.Buttons = button.GetButtons(dlg); dlg.ShowDialog(); if (doNotAskAgainCheckbox != null) { doNotAskAgainLoadSave.Item2.Invoke(doNotAskAgainCheckbox.IsChecked == true ? dlg.MessageBoxResult : (MessageBoxResult?)null); } return(dlg.MessageBoxResult); }
//get salesperson private void GetSalesperson(string condition) { if (thread_content != null && thread_content.ThreadState == ThreadState.Running) { } else { thread_content = new Thread(() => { try { list_ec_tb_salesperson.Clear(); this.Dispatcher.Invoke((Action)(() => { this.mpr.IsActive = true; this.chkCheckAll.IsChecked = false; this.dtgSalesperson.Items.Refresh(); this.dtgSalesperson.Visibility = System.Windows.Visibility.Hidden; })); using (DataTable dt_salesperson = bus_tb_salesperson.GetSalesPerson(condition)) { int no = 0; foreach (DataRow dr in dt_salesperson.Rows) { no++; EC_tb_SalesPerson ec_tb_salasperson = new EC_tb_SalesPerson(); ec_tb_salasperson.No = no; ec_tb_salasperson.SalespersonID = Convert.ToInt32(dr["SalespersonID"].ToString()); ec_tb_salasperson.Name = dr["Name"].ToString(); ec_tb_salasperson.Birthday = dr["Birthday"].ToString(); ec_tb_salasperson.Address = dr["Address"].ToString(); ec_tb_salasperson.Email = dr["Email"].ToString(); ec_tb_salasperson.Password = dr["Password"].ToString(); ec_tb_salasperson.Active = Convert.ToInt32(dr["Active"].ToString()); ec_tb_salasperson.CheckDel = false; ec_tb_salasperson.ImageUrl = @"pack://application:,,,/Resources/edit.png"; list_ec_tb_salesperson.Add(ec_tb_salasperson); } } this.Dispatcher.Invoke((Action)(() => { tblTotal.Text = FindResource("total").ToString() + "(" + list_ec_tb_salesperson.Count + ")"; dtgSalesperson.Items.Refresh(); })); Thread.Sleep(500); this.mpr.Dispatcher.Invoke((Action)(() => { this.mpr.Visibility = System.Windows.Visibility.Hidden; this.mpr.IsActive = false; })); this.dtgSalesperson.Dispatcher.Invoke((Action)(() => { this.dtgSalesperson.Visibility = System.Windows.Visibility.Visible; })); } catch (Exception ex) { this.Dispatcher.Invoke((Action)(() => { ModernDialog md = new ModernDialog(); md.CloseButton.Content = FindResource("close").ToString(); md.Title = FindResource("notification").ToString(); md.Content = ex.Message; md.ShowDialog(); })); } }); thread_content.Start(); } }
void buttonGraphics_Click(object sender, RoutedEventArgs e) { if (arrDrowingGroup == 0) { if (errorMessage.DialogResult == false) { var errorMessage1 = new ModernDialog { Title = "Ошибка", Content = "Сначала сформируйте исходный массив." }; errorMessage1.ShowDialog(); } else { errorMessage.Content = "Сначала сформируйте исходный массив."; errorMessage.ShowDialog(); } } else { double x1 = image.Width / arrDrowingGroup; double y1 = Math.Sqrt(image.Height) / arrDrowingGroup; double y2 = Math.Sqrt(stop1.ElapsedTicks) / arrDrowingGroup; double y3 = Math.Sqrt(stop2.ElapsedTicks) / arrDrowingGroup; double z = 0; double z2 = 0; double z3 = 0; double n = 0; double n2 = 0; double n3 = 0; GeometryGroup geometry1 = new GeometryGroup(); GeometryGroup geometry2 = new GeometryGroup(); GeometryGroup geometry3 = new GeometryGroup(); for (int i = 0; i < arrDrowingGroup; i++) { z = i * i * y1 * y1; z2 = i * i * y2 * y2; z3 = i * i * y3 * y3; LineGeometry line_sort1 = new LineGeometry(new Point(i * x1, -n), new Point((i + 1) * x1, -z)); LineGeometry line_sort2 = new LineGeometry(new Point(i * x1, -n2), new Point((i + 1) * x1, -z2)); LineGeometry line_sort3 = new LineGeometry(new Point(i * x1, -n3), new Point((i + 1) * x1, -z3)); geometry1.Children.Add(line_sort1); geometry2.Children.Add(line_sort2); geometry3.Children.Add(line_sort3); n = z; n2 = z2; n3 = z3; } GeometryDrawing geometry1_draw = new GeometryDrawing(); geometry1_draw.Geometry = geometry1; geometry1_draw.Pen = new Pen(Brushes.Red, 3); draw.Children.Add(geometry1_draw); GeometryDrawing geometry2_draw = new GeometryDrawing(); geometry2_draw.Geometry = geometry2; geometry2_draw.Pen = new Pen(Brushes.Blue, 3); draw.Children.Add(geometry2_draw); GeometryDrawing geometry3_draw = new GeometryDrawing(); geometry3_draw.Geometry = geometry3; geometry3_draw.Pen = new Pen(Brushes.Green, 3); draw.Children.Add(geometry3_draw); } }
/// <summary> /// Function to control the first launch install. /// </summary> public async void FirstInstall() { VersionCheck.GetLatestGameVersionName(); await VersionCheck.UpdateLatestVersions(); //Get the current root path and prepare the installation var targetDir = GameInstallation.GetRootPath(); var applicationDir = System.IO.Path.Combine(GameInstallation.GetRootPath(), "patch"); var patchPath = VersionCheck.GamePatchPath; var patchVersion = VersionCheck.GetLatestGameVersionName(); //Create an empty var containing the progress report from the patcher var progress = new Progress <DirectoryPatcherProgressReport>(); var cancellationTokenSource = new System.Threading.CancellationTokenSource(); Task task = RxPatcher.Instance.ApplyPatchFromWeb(patchPath, targetDir, applicationDir, progress, cancellationTokenSource.Token, VersionCheck.InstructionsHash); //Create the update window var window = new ApplyUpdateWindow(task, RxPatcher.Instance, progress, patchVersion, cancellationTokenSource, ApplyUpdateWindow.UpdateWindowType.Install); window.Owner = this; //Show the dialog and wait for completion window.Show(); while (!task.IsCompleted) { await Task.Delay(1000); if (cancellationTokenSource.IsCancellationRequested) { task.Dispose(); } } RxLogger.Logger.Instance.Write($"Install complete, task state isCompleted = {task.IsCompleted}"); if (task?.IsCompleted == true && task?.Status != TaskStatus.Canceled) { VersionCheck.UpdateGameVersion(); //Create the UE3 redist dialog RxLogger.Logger.Instance.Write("Creating the UE3 Redist package dialog"); ModernDialog ueRedistDialog = new ModernDialog(); ueRedistDialog.Title = "UE3 Redistributable"; ueRedistDialog.Content = MessageRedistInstall; ueRedistDialog.Buttons = new Button[] { ueRedistDialog.OkButton, ueRedistDialog.CancelButton }; ueRedistDialog.ShowDialog(); RxLogger.Logger.Instance.Write($"Did the user want to install the UE3 Redist? - {ueRedistDialog.DialogResult.Value}"); if (ueRedistDialog.DialogResult.Value == true) { bool downloadSuccess = false; var bestPatchServer = RxPatcher.Instance.UpdateServerHandler.SelectBestPatchServer(); Uri RedistServer = bestPatchServer.Uri; //Create new URL based on the patch url (Without the patch part) String redistUrl = RedistServer + "redists/UE3Redist.exe"; string systemPath = GameInstallation.GetRootPath() + "Launcher\\Redist\\UE3Redist.exe"; //Create canceltokens to stop the downloaderthread if neccesary CancellationTokenSource downloaderTokenSource = new CancellationTokenSource(); CancellationToken downloaderToken = downloaderTokenSource.Token; //Redist downloader statuswindow GeneralDownloadWindow redistWindow = new GeneralDownloadWindow(downloaderTokenSource, "UE3Redist download"); redistWindow.Show(); //Start downloading redist RxLogger.Logger.Instance.Write($"Downloading UE3 Redist from {RedistServer.AbsoluteUri}"); downloadSuccess = await DownloadRedist(redistUrl, systemPath, downloaderToken, (received, size) => { redistWindow.UpdateProgressBar(received, size); }); RxLogger.Logger.Instance.Write("UE3 Redist Download Complete"); redistWindow.Close(); if (downloadSuccess) { //When done, execute the UE3Redist here try { using (Process ue3Redist = Process.Start(systemPath)) { ue3Redist.WaitForExit(); if (ue3Redist.ExitCode != 0)//If redist install fails, notify the user { MessageBox.Show("Error while installing the UE3 Redist."); } else//Everything done! save installed flag and restart { Properties.Settings.Default.Installed = true; Properties.Settings.Default.Save(); try { System.IO.File.Delete(systemPath); System.IO.Directory.Delete(GameInstallation.GetRootPath() + "Launcher\\Redist\\"); } catch (Exception) { MessageBox.Show("Could not cleanup the redist file. This won't hinder the game."); } } } } catch { MessageBox.Show("Error while executing the UE3 Redist."); } finally { //Restart launcher System.Diagnostics.Process.Start(Application.ResourceAssembly.Location); Application.Current.Shutdown(); } } if (downloadSuccess == false) { MessageBox.Show("Unable to download the UE3 Redist (corrupt download)"); } } else { ModernDialog notInstalledDialog = new ModernDialog(); notInstalledDialog.Title = "UE3 Redistributable"; notInstalledDialog.Content = MessageNotInstalled; notInstalledDialog.Buttons = new Button[] { notInstalledDialog.OkButton }; notInstalledDialog.ShowDialog(); //Shutdown launcher Application.Current.Shutdown(); } } else { Application.Current.Shutdown(); } }
//btnSaveInvoice_Click private void btnSaveInvoice_Click(object sender, RoutedEventArgs e) { ModernDialog mdd = new ModernDialog(); mdd.Buttons = new Button[] { mdd.OkButton, mdd.CancelButton, }; mdd.OkButton.TabIndex = 0; mdd.OkButton.Content = FindResource("ok").ToString(); mdd.CancelButton.TabIndex = 1; mdd.CancelButton.Content = FindResource("cancel").ToString(); mdd.TabIndex = -1; mdd.Height = 200; mdd.Title = FindResource("save_invoice").ToString(); mdd.Content = FindResource("really_want_save_invoice").ToString(); mdd.OkButton.Focus(); mdd.ShowDialog(); if (mdd.MessageBoxResult == System.Windows.MessageBoxResult.OK) { if (thread_saveinvoice != null && thread_saveinvoice.ThreadState == ThreadState.Running) { } else { thread_saveinvoice = new Thread(() => { try { this.btnSaveInvoice.Dispatcher.Invoke((Action)(() => { this.btnSaveInvoice.Visibility = System.Windows.Visibility.Hidden; })); this.btnSaveSendEmail.Dispatcher.Invoke((Action)(() => { this.btnSaveSendEmail.IsEnabled = false; })); this.btnClose.Dispatcher.Invoke((Action)(() => { this.btnClose.IsEnabled = false; })); this.mprSaveInvoice.Dispatcher.Invoke((Action)(() => { this.mprSaveInvoice.Visibility = System.Windows.Visibility.Visible; this.mprSaveInvoice.IsActive = true; })); if (PayOrder() == true) { StaticClass.GeneralClass.flag_paycash = true; btnpayother_delegate(true); this.Dispatcher.Invoke((Action)(() => { this.Close(); })); } else { this.Dispatcher.Invoke((Action)(() => { ModernDialog md = new ModernDialog(); md.CloseButton.Content = FindResource("close").ToString(); md.Content = FindResource("error_insert").ToString(); md.Title = FindResource("notification").ToString(); md.ShowDialog(); })); } this.mprSaveInvoice.Dispatcher.Invoke((Action)(() => { this.mprSaveInvoice.Visibility = System.Windows.Visibility.Hidden; this.mprSaveInvoice.IsActive = false; this.btnSaveInvoice.Visibility = System.Windows.Visibility.Visible; this.btnSaveSendEmail.IsEnabled = true; this.btnClose.IsEnabled = true; })); } catch (Exception ex) { this.Dispatcher.Invoke((Action)(() => { ModernDialog md = new ModernDialog(); md.CloseButton.Content = FindResource("close").ToString(); md.Content = ex.Message; md.Title = FindResource("notification").ToString(); md.ShowDialog(); })); } }); thread_saveinvoice.Start(); } } }
/// <summary> /// Shows dialog with all information about shared entry and offers a choise to user what to do with it. /// </summary> /// <param name="shared">Shared entry.</param> /// <param name="additionalButton">Label of additional button.</param> /// <param name="saveable">Can be saved.</param> /// <param name="applyable">Can be applied.</param> /// <param name="appliableWithoutSaving">Can be applied without saving.</param> /// <returns>User choise.</returns> private Choise ShowDialog(SharedEntry shared, string additionalButton = null, bool saveable = true, bool applyable = true, bool appliableWithoutSaving = true) { var description = string.Format(AppStrings.Arguments_SharedMessage, shared.Name ?? AppStrings.Arguments_SharedMessage_EmptyValue, shared.EntryType == SharedEntryType.Weather ? AppStrings.Arguments_SharedMessage_Id : AppStrings.Arguments_SharedMessage_For, shared.Target ?? AppStrings.Arguments_SharedMessage_EmptyValue, shared.Author ?? AppStrings.Arguments_SharedMessage_EmptyValue); var dlg = new ModernDialog { Title = shared.EntryType.GetDescription().ToTitle(), Content = new ScrollViewer { Content = new BbCodeBlock { BbCode = description + '\n' + '\n' + ( saveable ? AppStrings.Arguments_Shared_ShouldApplyOrSave : AppStrings.Arguments_Shared_ShouldApply), Margin = new Thickness(0, 0, 0, 8) }, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled }, MinHeight = 0, MinWidth = 0, MaxHeight = 480, MaxWidth = 640 }; dlg.Buttons = new[] { applyable&& saveable?dlg.CreateCloseDialogButton( appliableWithoutSaving?AppStrings.Arguments_Shared_ApplyAndSave : AppStrings.Arguments_Shared_SaveAndApply, true, false, MessageBoxResult.Yes) : null, appliableWithoutSaving&& applyable ? dlg.CreateCloseDialogButton(saveable ? AppStrings.Arguments_Shared_ApplyOnly : AppStrings.Arguments_Shared_Apply, true, false, MessageBoxResult.OK) : null, saveable ? dlg.CreateCloseDialogButton( applyable && appliableWithoutSaving ? AppStrings.Arguments_Shared_SaveOnly : AppStrings.Toolbar_Save, true, false, MessageBoxResult.No) : null, additionalButton == null ? null : dlg.CreateCloseDialogButton(additionalButton, true, false, MessageBoxResult.None), dlg.CancelButton }.NonNull(); dlg.ShowDialog(); switch (dlg.MessageBoxResult) { case MessageBoxResult.None: return(Choise.Extra); case MessageBoxResult.OK: return(Choise.Apply); case MessageBoxResult.Cancel: return(Choise.Cancel); case MessageBoxResult.Yes: return(Choise.ApplyAndSave); case MessageBoxResult.No: return(Choise.Save); default: throw new ArgumentOutOfRangeException(); } }
private void GetUser() { if (thread_content != null && thread_content.ThreadState == ThreadState.Running) { } else { thread_content = new Thread(() => { try { this.grContent.Dispatcher.Invoke((Action)(() => { dtgUser.ItemsSource = null; this.dtgUser.Visibility = System.Windows.Visibility.Hidden; })); this.mpr.Dispatcher.Invoke((Action)(() => { this.mpr.Visibility = System.Windows.Visibility.Visible; this.mpr.IsActive = true; })); tb_user.Clear(); list_ec_tb_user.Clear(); tb_user = bus_tb_user.GetUser(""); foreach (DataRow datarow in tb_user.Rows) { EC_tb_User ec_tb_user = new EC_tb_User(); ec_tb_user.ID = Convert.ToInt32(datarow["ID"].ToString()); ec_tb_user.Name = datarow["Name"].ToString(); ec_tb_user.Email = datarow["Email"].ToString(); ec_tb_user.Address = datarow["Address"].ToString(); ec_tb_user.Password = datarow["Password"].ToString(); ec_tb_user.Question = datarow["Question"].ToString(); ec_tb_user.Answer = datarow["Answer"].ToString(); ec_tb_user.EditImage = @"pack://application:,,,/Resources/edit.png"; list_ec_tb_user.Add(ec_tb_user); } this.tblTotal.Dispatcher.Invoke((Action)(() => { tblTotal.Text = FindResource("total").ToString() + "(" + list_ec_tb_user.Count.ToString() + ")"; })); this.dtgUser.Dispatcher.Invoke((Action)(() => { dtgUser.ItemsSource = list_ec_tb_user; })); Thread.Sleep(500); this.mpr.Dispatcher.Invoke((Action)(() => { this.mpr.Visibility = System.Windows.Visibility.Hidden; this.mpr.IsActive = false; })); this.grContent.Dispatcher.Invoke((Action)(() => { this.dtgUser.Visibility = System.Windows.Visibility.Visible; })); } catch (Exception ex) { this.Dispatcher.Invoke((Action)(() => { ModernDialog md = new ModernDialog(); md.CloseButton.Content = FindResource("close").ToString(); md.Title = FindResource("notification").ToString(); md.Content = ex.Message; md.ShowDialog(); })); } }); thread_content.Start(); } }
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 { showError = string.Empty; IsVisError = System.Windows.Visibility.Collapsed; } bool _isExec = true; 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; } if (OptionsImport == TypeImport.Overwrite) { ModernDialog mdd = new 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_choose_del").ToString(); mdd.OkButton.Focus(); mdd.ShowDialog(); if (mdd.MessageBoxResult != System.Windows.MessageBoxResult.OK) { _isExec = false; } } else { ModernDialog mdd = new 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) { _isExec = false; } System.Data.DataTable _dt = bus_tb_category.GetCatagorySetting(""); if (_dt.Rows.Count > 0) { foreach (System.Data.DataRow _dr in _dt.Rows) { _lstCat.Add(_dr["CategoryName"].ToString()); } } } if (_isExec) { IsShowProgress = true; IsVisibleButton = System.Windows.Visibility.Collapsed; string _fileImport = FileNameImport; var slowTask = Task <string> .Factory.StartNew(() => this._ImportFromCSV(System.IO.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"); } } }
//ModernDialog_KeyDown private void ModernDialog_KeyDown(object sender, KeyEventArgs e) { ShellOutModel msShellout = (ShellOutModel)lstShellOut.Items[lstShellOut.SelectedIndex]; string _strId = msShellout.PaymentId.ToString(); if (_strId.Length >= 3) { _strId = _strId.Remove(2); } if (Convert.ToInt32(_strId) == 11) { return; } ShellOutModel _default = (ShellOutModel)lstShellOut.Items[0]; string _strSeparator = (StaticClass.GeneralClass.app_settings["decimalSeparator"].ToString() == "0") ? "." : ","; string strVal = msShellout.PaymentBalance.ToString(); string strkey = GetCharFromKey(e.Key).ToString(); if (GetCharFromKey(e.Key).ToString() == _strSeparator) { if (!msShellout.PaymentBalance.Trim().Contains(strkey)) { strVal += GetCharFromKey(e.Key).ToString(); } msShellout.PaymentBalance = strVal; isEnableInvoice(); } try { int num; if (int.TryParse(GetCharFromKey(e.Key).ToString(), out num)) { string _strCompare = Convert.ToString(StaticClass.GeneralClass.ConverStringToDecimal(strVal)) + strkey; if (Convert.ToDouble(_strCompare) < 999999999.99) { if (msShellout.PaymentId == 1) { if (StaticClass.GeneralClass.ConverStringToDecimal(strVal) == 0) { strVal = GetCharFromKey(e.Key).ToString(); } else { int ind = strVal.IndexOf(_strSeparator); if (ind > 0) { string _strNumberDecimalSeparator = strVal.Substring(ind + 1); if (_strNumberDecimalSeparator.Length < 2) { strVal += GetCharFromKey(e.Key).ToString(); } } else { strVal += GetCharFromKey(e.Key).ToString(); } } int _ind = strVal.IndexOf(_strSeparator); if (_ind > 0) { string _strNumberDecimalSeparator = strVal.Substring(_ind + 1); msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), _strNumberDecimalSeparator.Length); } else { msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), 0); } isEnableInvoice(); } else if (CalculateTotalBalance(msShellout.PaymentId, StaticClass.GeneralClass.ConverStringToDecimal(strVal + strkey)) <= StaticClass.GeneralClass.ConverStringToDecimal(_default.PaymentBalance)) { if (StaticClass.GeneralClass.ConverStringToDecimal(strVal) == 0) { strVal = GetCharFromKey(e.Key).ToString(); } else { int ind = strVal.IndexOf(_strSeparator); if (ind > 0) { string _strNumberDecimalSeparator = strVal.Substring(ind + 1); if (_strNumberDecimalSeparator.Length < 2) { strVal += GetCharFromKey(e.Key).ToString(); } } else { strVal += GetCharFromKey(e.Key).ToString(); } } int _ind = strVal.IndexOf(_strSeparator); if (_ind > 0) { string _strNumberDecimalSeparator = strVal.Substring(_ind + 1); msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), _strNumberDecimalSeparator.Length); } else { msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), 0); } isEnableInvoice(); } else { ModernDialog md = new ModernDialog(); md.CloseButton.FindResource("close").ToString(); md.Content = App.Current.FindResource("payment_balance_less_cash_balance").ToString(); md.Title = App.Current.FindResource("notification").ToString(); md.ShowDialog(); } } } //enter key press if (e.Key.ToString() == "Return") { //btnEnter_Click(null, null); } //back key press if (e.Key.ToString() == "Back") { string _strVal = msShellout.PaymentBalance.ToString(); if (_strVal.Length == 1) { msShellout.PaymentBalance = "0"; } else { _strVal = _strVal.Remove(_strVal.Length - 1, 1); decimal _tmpDec = StaticClass.GeneralClass.ConverStringToDecimal(_strVal); _strVal = Convert.ToString(_tmpDec); int _ind = _strVal.IndexOf(_strSeparator); if (_ind > 0) { string _strNumberDecimalSeparator = _strVal.Substring(_ind + 1); msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(_tmpDec, _strNumberDecimalSeparator.Length); } else { msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(_tmpDec, 0); } } isEnableInvoice(); } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } }
private void btnSaveInvoice_Click(object sender, RoutedEventArgs e) { string _strBalance = (StaticClass.GeneralClass.app_settings["decimalSeparator"].ToString() == "0") ? tblCashBalance.Text.Replace(", ", "") : tblCashBalance.Text.Replace(".", ""); if (Convert.ToDecimal(_strBalance.Trim(), StaticClass.GeneralClass.app_settings["decimalSeparator"].ToString() == "0" ? new CultureInfo("en-US") : new CultureInfo("fr-FR")) < 0) { ModernDialog md = new ModernDialog(); md.CloseButton.Content = FindResource("close").ToString(); md.Title = FindResource("notification").ToString(); md.Content = FindResource("paycash_greater_total").ToString(); md.CloseButton.Focus(); md.ShowDialog(); return; } else { ModernDialog mdd = new ModernDialog(); mdd.Buttons = new Button[] { mdd.OkButton, mdd.CancelButton, }; mdd.OkButton.TabIndex = 0; mdd.OkButton.Content = FindResource("ok").ToString(); mdd.CancelButton.TabIndex = 1; mdd.CancelButton.Content = FindResource("cancel").ToString(); mdd.TabIndex = -1; mdd.Height = 200; mdd.Title = FindResource("save_invoice").ToString(); mdd.Content = FindResource("really_want_save_invoice").ToString(); mdd.OkButton.Focus(); mdd.ShowDialog(); if (mdd.MessageBoxResult == System.Windows.MessageBoxResult.OK) { if (thread_saveinvoice != null && thread_saveinvoice.ThreadState == ThreadState.Running) { } else { thread_saveinvoice = new Thread(() => { try { this.mprSaveInvoice.Dispatcher.Invoke((Action)(() => { this.btnSaveInvoice.Visibility = System.Windows.Visibility.Hidden; this.btnSaveSendEmail.IsEnabled = false; this.btnClose.IsEnabled = false; this.mprSaveInvoice.Visibility = System.Windows.Visibility.Visible; this.mprSaveInvoice.IsActive = true; })); if (PayOrder() == true) { StaticClass.GeneralClass.flag_paycash = true; btnpaycash_delegate(true); this.Dispatcher.Invoke((Action)(() => { this.Close(); })); } else { this.Dispatcher.Invoke((Action)(() => { ModernDialog md = new ModernDialog(); md.CloseButton.Content = FindResource("close").ToString(); md.Content = FindResource("error_insert").ToString(); md.Title = FindResource("notification").ToString(); md.ShowDialog(); })); } this.mprSaveInvoice.Dispatcher.Invoke((Action)(() => { this.mprSaveInvoice.Visibility = System.Windows.Visibility.Hidden; this.mprSaveInvoice.IsActive = false; this.btnSaveInvoice.Visibility = System.Windows.Visibility.Visible; this.btnSaveSendEmail.IsEnabled = true; this.btnClose.IsEnabled = true; })); } catch (Exception ex) { this.Dispatcher.Invoke((Action)(() => { ModernDialog md = new ModernDialog(); md.CloseButton.FindResource("close").ToString(); md.Content = ex.Message; md.Title = FindResource("notification").ToString(); md.ShowDialog(); })); } }); thread_saveinvoice.Start(); } } } }
private void btnNum_Click(object sender, RoutedEventArgs e) { ShellOutModel _shell = (ShellOutModel)lstShellOut.SelectedItem; string _strId = _shell.PaymentId.ToString(); if (_strId.Length >= 3) { _strId = _strId.Remove(2); } if (Convert.ToInt32(_strId) == 11) { return; } ShellOutModel _default = (ShellOutModel)lstShellOut.Items[0]; string _strVal = _shell.PaymentBalance + (sender as Button).Uid; string _strCompare = Convert.ToString(StaticClass.GeneralClass.ConverStringToDecimal(_strVal)); string strVal = _shell.PaymentBalance; if (Convert.ToDouble(_strCompare) < 999999999.99) { string _strSeparator = (StaticClass.GeneralClass.app_settings["decimalSeparator"].ToString() == "0") ? "." : ","; int ind = strVal.IndexOf(_strSeparator); decimal _totalBalance = StaticClass.GeneralClass.ConverStringToDecimal(tblCashBalance.Text); if (_shell.PaymentId == 1) { if (strVal != "0") { if (ind > 0) { string _strNumberDecimalSeparator = strVal.Substring(ind + 1); if (_strNumberDecimalSeparator.Length < 2) { strVal += (sender as Button).Uid; } } else { strVal += (sender as Button).Uid; } } else if ((sender as Button).Uid != "0") { strVal = (sender as Button).Uid; } int _ind = strVal.IndexOf(_strSeparator); if (_ind > 0) { string _strNumberDecimalSeparator = strVal.Substring(_ind + 1); _shell.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), _strNumberDecimalSeparator.Length); } else { _shell.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), 0); } isEnableInvoice(); } else if (CalculateTotalBalance(_shell.PaymentId, StaticClass.GeneralClass.ConverStringToDecimal(_strVal)) <= StaticClass.GeneralClass.ConverStringToDecimal(_default.PaymentBalance)) { if (strVal != "0") { if (ind > 0) { string _strNumberDecimalSeparator = strVal.Substring(ind + 1); if (_strNumberDecimalSeparator.Length < 2) { strVal += (sender as Button).Uid; } } else { strVal += (sender as Button).Uid; } } else if ((sender as Button).Uid != "0") { strVal = (sender as Button).Uid; } int _ind = strVal.IndexOf(_strSeparator); if (_ind > 0) { string _strNumberDecimalSeparator = strVal.Substring(_ind + 1); _shell.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), _strNumberDecimalSeparator.Length); } else { _shell.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), 0); } isEnableInvoice(); } else { ModernDialog md = new ModernDialog(); md.CloseButton.FindResource("close").ToString(); md.Content = App.Current.FindResource("payment_balance_less_cash_balance").ToString(); md.Title = App.Current.FindResource("notification").ToString(); md.ShowDialog(); } } }
public void ShowDialog() { Dialog.ShowDialog(); }
public void rdbSingleUserBoards() { try { objBoardsManager.rdbSingleUserBoards = true; objBoardsManager.rdbMultipleUserBoards = false; btnBoardUrl_Boards_Browse.Visibility = Visibility.Hidden; //btnBoardName_Board_Browse.Visibility = Visibility.Hidden; btnMessage_Board_Browse.Visibility = Visibility.Hidden; txtBoardUrl.Visibility = Visibility.Hidden; //txtBoardName.IsReadOnly = false; txtMessage.Visibility = Visibility.Hidden; lblBoardUrlToRepinFrom_Boards.Visibility = Visibility.Hidden; lblMessage_Boards.Visibility = Visibility.Hidden; lblHints_Boards.Visibility = Visibility.Hidden; ClGlobul.CommentNicheMessageList.Clear(); ClGlobul.lstListOfBoardNames.Clear(); ClGlobul.lstBoardRepinMessage.Clear(); #region BoardUrl try { UserControl_SingleUser obj = new UserControl_SingleUser(); obj.UserControlHeader.Text = "Enter BoardName and BoardUrl Here "; obj.txtEnterSingleMessages.ToolTip = "Format :- Niche::BoardName::BoardUrl"; var window = new ModernDialog { Content = obj }; window.ShowInTaskbar = true; window.MinWidth = 100; window.MinHeight = 300; Button customButton = new Button() { Content = "SAVE" }; customButton.Click += (ss, ee) => { closeEvent(); window.Close(); }; window.Buttons = new Button[] { customButton }; window.ShowDialog(); MessageBoxButton btnC = MessageBoxButton.YesNo; var result = ModernDialog.ShowMessage("Are you sure want to save ?", "Message Box", btnC); if (result == MessageBoxResult.Yes) { TextRange textRange = new TextRange(obj.txtEnterSingleMessages.Document.ContentStart, obj.txtEnterSingleMessages.Document.ContentEnd); if (!string.IsNullOrEmpty(textRange.Text)) { string enterText = textRange.Text; string[] arr = Regex.Split(enterText, "\r\n"); foreach (var arr_item in arr) { if (!string.IsNullOrEmpty(arr_item) || !arr_item.Contains("")) { ClGlobul.lstListOfBoardNames.Add(arr_item); } } } GlobusLogHelper.log.Info(" => [ BoardName and BoardUrl with Niche Loaded : " + ClGlobul.lstListOfBoardNames.Count + " ]"); GlobusLogHelper.log.Debug("BoardName and BoardUrl with Niche : " + ClGlobul.lstListOfBoardNames.Count); } } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } #endregion SingleUserMessage(); } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } }
//muiBtnUndo_Click private void muiBtnUndo_Click(object sender, RoutedEventArgs e) { if (current_folder_undo != "") { ModernDialog md = new ModernDialog(); md.Buttons = new Button[] { md.YesButton, md.CloseButton, }; md.Title = FindResource("notification").ToString(); md.Content = FindResource("are_you_sure").ToString(); md.YesButton.Content = FindResource("yes").ToString(); md.CloseButton.Content = FindResource("no").ToString(); md.YesButton.Focus(); bool result = md.ShowDialog().Value; if (result == true) { //if database type is sqlite if (StaticClass.GeneralClass.flag_database_type_general == false) { //close connect ConnectionDB.CloseConnect(); if (System.IO.File.Exists(current_directory + @"\DBRES_Local\" + current_folder_undo + @"\CheckOut.db") == true) { System.IO.File.Copy(current_directory + @"\DBRES_Local\" + current_folder_undo + @"\CheckOut.db", current_directory + @"\Databases\CheckOut.db", true); //restart app System.Diagnostics.Process.Start(Application.ResourceAssembly.Location); Application.Current.Shutdown(); } //open connect ConnectionDB.OpenConnect(); } //if database type is sql server else { //System.IO.Directory.CreateDirectory(current_directory + @"\DBRESSer_Local\" + __current_time); string _restoreFile = current_directory + @"\DBRESSer_Local\" + current_folder_undo.Replace("/", ".").Replace(":", "..") + @"\CheckOut.bak"; if (System.IO.File.Exists(_restoreFile)) { System.Diagnostics.Debug.WriteLine(_restoreFile); SqlConnection sqlConnect = ConnectionDB.getSQLConnection(); var query = String.Format("BACKUP DATABASE [{0}] TO DISK='{1}' WITH NOFORMAT, NOINIT, NAME = N'data-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10", ConnectionDB.getSqlServerDataBaseName(), current_directory + @"\DBRESSer_Local\" + current_folder_undo.Replace("/", ".").Replace(":", "..") + @"\" + ConnectionDB.getSqlServerDataBaseName() + ".bak"); using (var command = new SqlCommand(query, sqlConnect)) { //command.ExecuteNonQuery(); command.CommandText = "Use Master"; command.ExecuteNonQuery(); command.CommandText = "ALTER DATABASE " + ConnectionDB.getSqlServerDataBaseName() + " SET SINGLE_USER WITH ROLLBACK IMMEDIATE;"; command.ExecuteNonQuery(); command.CommandText = "RESTORE DATABASE " + ConnectionDB.getSqlServerDataBaseName() + " FROM DISK = '" + @_restoreFile + "' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10; "; command.ExecuteNonQuery(); command.CommandText = "Use Master"; command.ExecuteNonQuery(); command.CommandText = "ALTER DATABASE " + ConnectionDB.getSqlServerDataBaseName() + " SET MULTI_USER;"; command.ExecuteNonQuery(); command.CommandText = "Use " + ConnectionDB.getSqlServerDataBaseName(); command.ExecuteNonQuery(); } } else if (System.IO.File.Exists(current_directory + @"\DBRESSer_Local\" + current_folder_undo + @"\CheckOut.sql") == true) { //get connection info System.IO.StreamReader stream_reader = StaticClass.GeneralClass.DecryptFileGD(current_directory + @"\sqltype", StaticClass.GeneralClass.key_register_general); stream_reader.ReadLine(); server = stream_reader.ReadLine().Split(':')[1].ToString(); id = stream_reader.ReadLine().Split(':')[1].ToString(); password = stream_reader.ReadLine().Split(':')[1].ToString(); stream_reader.Close(); //connection to server string connection_string = "server = " + server + "; user id = " + id + "; password = "******"; integrated security = true"; SqlConnection sql_connection = new SqlConnection(); sql_connection.ConnectionString = connection_string; sql_connection.Open(); //insert data System.IO.StreamReader stream_reader_insert = StaticClass.GeneralClass.DecryptFileGD(current_directory + @"\DBRESSer_Local\" + current_folder_undo + @"\CheckOut.sql", StaticClass.GeneralClass.key_register_general); string _line; StringBuilder _strImport = new StringBuilder(); while ((_line = stream_reader_insert.ReadLine()) != null) { if (!string.IsNullOrEmpty(_line) && _line.Substring(0, 3) != "-- ") { if (_line.Contains("INSERT INTO")) { string _strTemp = _line.Substring(0, _line.IndexOf("(")); _strTemp = _strTemp.Substring("insert into ".Length).Trim().Replace("[", "").Replace("]", ""); _line = _line.Replace("')", @"\u0066").Replace("''", @"\u0055").Replace("','", @"\u0022").Replace("', '", @"\u0099").Replace(",'", @"\u0033").Replace(", '", @"\u0077").Replace("',", @"\u0044").Replace("' ,", @"\u0088").Replace("'", "''"); _line = _line.Replace(@"\u0066", "')").Replace(@"\u0055", "''").Replace(@"\u0022", "',N'").Replace(@"\u0099", "', N'").Replace(@"\u0033", ",N'").Replace(@"\u0077", ", N'").Replace(@"\u0044", "',").Replace(@"\u0088", "' ,"); _line = "if exists (select column_id from sys.columns where object_id = OBJECT_ID('" + _strTemp + "', 'U') and is_identity = 1) begin SET IDENTITY_INSERT " + _strTemp + " ON; " + _line + " SET IDENTITY_INSERT " + _strTemp + " OFF; end else " + _line; } _strImport.AppendLine(_line); } } if (!string.IsNullOrEmpty(_strImport.ToString())) { SqlTransaction tr = null; SqlCommand sql_command = null; try { using (tr = sql_connection.BeginTransaction()) { using (sql_command = sql_connection.CreateCommand()) { sql_command.Transaction = tr; sql_command.CommandText = _strImport.ToString(); sql_command.ExecuteNonQuery(); } tr.Commit(); } tr.Dispose(); sql_command.Dispose(); } catch (SqlException ex) { if (tr != null) { try { tr.Rollback(); } catch (ObjectDisposedException ex2) { } finally { tr.Dispose(); } } } } sql_connection.Close(); //restart app System.Diagnostics.Process.Start(Application.ResourceAssembly.Location); Application.Current.Shutdown(); } } } } }
//GetDatabase private void GetDatabase() { try { if (thread_getdatabase != null && thread_getdatabase.ThreadState == ThreadState.Running) { } else { thread_getdatabase = new Thread(() => { try { this.mpr.Dispatcher.Invoke((Action)(() => { mpr.IsActive = true; dtgDatabase.ItemsSource = null; })); list_tb_database.Clear(); //UserCredential user_credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = client_id, ClientSecret = client_secret, }, new[] { DriveService.Scope.Drive }, "user", CancellationToken.None, new FileDataStore("TuanNguyen.GoogleDrive.Auth.Store")).Result; UserCredential user_credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = GeneralClass.client_id, ClientSecret = GeneralClass.client_secret, }, new[] { DriveService.Scope.DriveFile }, "user", CancellationToken.None, new FileDataStore("TuanNguyen.GoogleDrive.Auth.Store")).Result; //create the drive service var driveservice = new DriveService(new BaseClientService.Initializer() { HttpClientInitializer = user_credential, ApplicationName = "Get database backup" }); this.Dispatcher.Invoke((Action)(() => { this.muiBtnBackup.Visibility = System.Windows.Visibility.Visible; })); //get file from gdrive string str_condition = "Backup_CashierRegister_"; try { FileList file_list = driveservice.Files.List().Execute(); string client_folderid_lc = ""; string client_folderid_gd = ""; string client_foldername_gd = ""; //if database type is sqlite if (StaticClass.GeneralClass.flag_database_type_general == false) { client_foldername_gd = "CashierRegister_Backup"; } else { client_foldername_gd = "CashierRegister_Ser_Backup"; } //if ClientFolderInfo file isn't existed if (!System.IO.File.Exists("ClientFolderInfo")) { bool flag_exist_client_folderid = false; for (int i = 0; i < file_list.Items.Count; i++) { //if local ClientFolderInfo file is't exist and CashierRegister_Backup is existed if ((file_list.Items[i].Title == client_foldername_gd) && (file_list.Items[i].MimeType == "application/vnd.google-apps.folder") && (file_list.Items[i].ExplicitlyTrashed == false)) { //create ClientFolderInfo file System.IO.StreamWriter streamwriter = new System.IO.StreamWriter("ClientFolder"); //if database type is sqlite if (StaticClass.GeneralClass.flag_database_type_general == false) { streamwriter.WriteLine("FolderID:" + file_list.Items[i].Id.ToString()); streamwriter.WriteLine("FolderID:"); } //if database tupe is sqlserver else { streamwriter.WriteLine("FolderID:"); streamwriter.WriteLine("FolderID:" + file_list.Items[i].Id.ToString()); } streamwriter.Close(); StaticClass.GeneralClass.EncryptFileGD("ClientFolder", "ClientFolderInfo", StaticClass.GeneralClass.key_register_general); client_folderid_lc = file_list.Items[i].Id; client_folderid_gd = file_list.Items[i].Id; flag_exist_client_folderid = true; break; } } //if local ClientFolderInfo file isn't existed and drive ClientFolderInfo isn't existed if (flag_exist_client_folderid == false) { File folder_client = new File(); //if database type is sqlite if (StaticClass.GeneralClass.flag_database_type_general == false) { folder_client.Title = "CashierRegister_Backup"; } //if database type is sqlserver else { folder_client.Title = "CashierRegister_Ser_Backup"; } folder_client.Description = "This folder using for backup database"; folder_client.MimeType = "application/vnd.google-apps.folder"; //insert folder File response_folder = driveservice.Files.Insert(folder_client).Execute(); if (response_folder != null) { System.IO.StreamWriter streamwriter = new System.IO.StreamWriter("ClientFolder"); //if database type is sqlite if (StaticClass.GeneralClass.flag_database_type_general == false) { streamwriter.WriteLine("FolderID:" + response_folder.Id.ToString()); streamwriter.WriteLine("FolderID:"); } //if database tupe is sqlserver else { streamwriter.WriteLine("FolderID:"); streamwriter.WriteLine("FolderID:" + response_folder.Id.ToString()); } streamwriter.Close(); StaticClass.GeneralClass.EncryptFileGD("ClientFolder", "ClientFolderInfo", StaticClass.GeneralClass.key_register_general); client_folderid_gd = response_folder.Id; client_folderid_lc = response_folder.Id; } } } //if local ClientFolderInfo file is existed else { bool flag_exist_client_folderid = false; System.IO.StreamReader streamreader_folder = StaticClass.GeneralClass.DecryptFileGD("ClientFolderInfo", StaticClass.GeneralClass.key_register_general); if (streamreader_folder != null) { //if database type is sqlite if (StaticClass.GeneralClass.flag_database_type_general == false) { client_folderid_lc = streamreader_folder.ReadLine().Split(':')[1]; } //if database type is sqlserver else { streamreader_folder.ReadLine(); client_folderid_lc = streamreader_folder.ReadLine().Split(':')[1]; } streamreader_folder.Close(); } //if client_folderid_lc isn't null if (!String.IsNullOrWhiteSpace(client_folderid_lc)) { for (int i = 0; i < file_list.Items.Count; i++) { //if local ClientFolderInfo file is exist and drive ClientFolderInfo is existed if ((file_list.Items[i].MimeType == "application/vnd.google-apps.folder") && (file_list.Items[i].ExplicitlyTrashed == false) && (file_list.Items[i].Id == client_folderid_lc)) { client_folderid_gd = file_list.Items[i].Id; flag_exist_client_folderid = true; break; } } } else { for (int i = 0; i < file_list.Items.Count; i++) { if ((file_list.Items[i].Title == client_foldername_gd) && (file_list.Items[i].MimeType == "application/vnd.google-apps.folder") && (file_list.Items[i].ExplicitlyTrashed == false)) { client_folderid_gd = file_list.Items[i].Id; flag_exist_client_folderid = true; System.IO.StreamWriter streamwriter = new System.IO.StreamWriter("ClientFolder"); //get FolderID System.IO.StreamReader stream_reader_temp = StaticClass.GeneralClass.DecryptFileGD(current_directory + @"\ClientFolderInfo", StaticClass.GeneralClass.key_register_general); //if database type is sqlite if (StaticClass.GeneralClass.flag_database_type_general == false) { streamwriter.WriteLine("FolderID:" + file_list.Items[i].Id); stream_reader_temp.ReadLine(); streamwriter.WriteLine("FolderID:" + stream_reader_temp.ReadLine().Split(':')[1].ToString()); } //if database tupe is sqlserver else { streamwriter.WriteLine("FolderID:" + stream_reader_temp.ReadLine().Split(':')[1].ToString()); streamwriter.WriteLine("FolderID:" + file_list.Items[i].Id); } //close stream_reader_temp if (stream_reader_temp != null) { stream_reader_temp.Close(); } streamwriter.Close(); StaticClass.GeneralClass.EncryptFileGD("ClientFolder", "ClientFolderInfo", StaticClass.GeneralClass.key_register_general); client_folderid_gd = file_list.Items[i].Id; client_folderid_lc = file_list.Items[i].Id; break; } } } //if local ClientFolderInfo file is existed and drive ClientFolderInfo isn't existed if (flag_exist_client_folderid == false) { File folder_client = new File(); //if database type is sqlite if (StaticClass.GeneralClass.flag_database_type_general == false) { folder_client.Title = "CashierRegister_Backup"; } //if database type is sqlserver else { folder_client.Title = "CashierRegister_Ser_Backup"; } folder_client.Description = "This folder using for backup database"; folder_client.MimeType = "application/vnd.google-apps.folder"; //insert folder File response_folder = driveservice.Files.Insert(folder_client).Execute(); if (response_folder != null) { System.IO.StreamWriter streamwriter = new System.IO.StreamWriter("ClientFolder"); //get FolderID System.IO.StreamReader stream_reader_temp = StaticClass.GeneralClass.DecryptFileGD(current_directory + @"\ClientFolderInfo", StaticClass.GeneralClass.key_register_general); //if database type is sqlite if (StaticClass.GeneralClass.flag_database_type_general == false) { streamwriter.WriteLine("FolderID:" + response_folder.Id.ToString()); stream_reader_temp.ReadLine(); streamwriter.WriteLine("FolderID:" + stream_reader_temp.ReadLine().Split(':')[1].ToString()); } //if database tupe is sqlserver else { streamwriter.WriteLine("FolderID:" + stream_reader_temp.ReadLine().Split(':')[1].ToString()); streamwriter.WriteLine("FolderID:" + response_folder.Id.ToString()); } //close stream_reader_temp if (stream_reader_temp != null) { stream_reader_temp.Close(); } streamwriter.Close(); StaticClass.GeneralClass.EncryptFileGD("ClientFolder", "ClientFolderInfo", StaticClass.GeneralClass.key_register_general); client_folderid_gd = response_folder.Id; client_folderid_lc = response_folder.Id; } } } int no = 0; for (int i = 0; i < file_list.Items.Count; i++) { if (file_list.Items[i].Title.Length > 23) { if (file_list.Items[i].Parents.Count > 0) { if ((file_list.Items[i].Parents[0].Id == client_folderid_lc) && (file_list.Items[i].MimeType == "application/octet-stream") && (file_list.Items[i].Title.Substring(0, 23) == str_condition) && (file_list.Items[i].ExplicitlyTrashed == false)) { EC_tb_Database ec_tb_database = new EC_tb_Database(); ec_tb_database.Id = ++no; ec_tb_database.IdDatabase = file_list.Items[i].Id.ToString(); ec_tb_database.DownloadUrl = file_list.Items[i].DownloadUrl; ec_tb_database.BackupDate = file_list.Items[i].CreatedDate.ToString(); ec_tb_database.FileSize = (file_list.Items[i].FileSize / 1000).ToString() + "KB"; ec_tb_database.BitmapImage_Restore = bitmapimage_restore; ec_tb_database.BitmapImage_Delete = bitmapimage_delete; _lstExt.Add(file_list.Items[i].FileExtension.ToString()); list_tb_database.Add(ec_tb_database); } } } } } catch (System.Net.Http.HttpRequestException) { this.Dispatcher.Invoke((Action)(() => { ModernDialog md = new ModernDialog(); md.Title = FindResource("notification").ToString(); md.Content = FindResource("internet_problem").ToString(); md.CloseButton.Content = FindResource("close").ToString(); md.ShowDialog(); })); } this.Dispatcher.Invoke((Action)(() => { tblTotal.Text = FindResource("checkout").ToString() + "(" + list_tb_database.Count.ToString() + ")"; dtgDatabase.ItemsSource = list_tb_database; mpr.IsActive = false; dtgDatabase.Visibility = System.Windows.Visibility.Visible; })); //get email address string email_address = driveservice.About.Get().Execute().User.EmailAddress.ToString(); this.Dispatcher.Invoke((Action)(() => { this.tblEmailAddress.Visibility = System.Windows.Visibility.Visible; this.tblEmailAddress.Text = driveservice.About.Get().Execute().User.EmailAddress; //set login logout this.tblLogout.Visibility = System.Windows.Visibility.Visible; this.tblLogin.Visibility = System.Windows.Visibility.Hidden; })); } catch (AggregateException) { this.Dispatcher.Invoke((Action)(() => { ModernDialog md = new ModernDialog(); md.Title = FindResource("notification").ToString(); md.Content = FindResource("have_not_access").ToString(); md.ShowDialog(); })); } }); thread_getdatabase.Start(); } } catch (Exception ex) { this.Dispatcher.Invoke((Action)(() => { ModernDialog md = new ModernDialog(); FindResource("notification").ToString(); md.Content = ex.Message; md.ShowDialog(); })); } }
private void GetYear() { try { this.Dispatcher.Invoke((Action)(() => { this.stpYearRevenueProfittMonth.Children.Clear(); })); list_ec_tb_year.Clear(); tb_year.Clear(); total_year = -1; uid_img = -1; tb_year = bus_tb_order.GetYearFromOrder("", StaticClass.GeneralClass.flag_database_type_general); foreach (DataRow datarow in tb_year.Rows) { EC_tb_Charting ec_tb_charting = new EC_tb_Charting(); ec_tb_charting.Year = datarow["Year"].ToString(); list_ec_tb_year.Add(ec_tb_charting); //create new image year total_year++; uid_img++; this.Dispatcher.Invoke((Action)(() => { Image img = new Image() { Width = 40, Height = 40, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(5, 0, 0, 5), Name = "img" + ec_tb_charting.Year, Uid = "uid" + uid_img.ToString() }; if (total_year == 0) { img.Source = bitmapimage_circle_focus_year; GetDataFollowYear(ec_tb_charting.Year, ""); } else { img.Source = bitmapimage_circle_year; } Grid grd = new Grid(); grd.MouseDown += new MouseButtonEventHandler(grd_MouseDown); TextBlock tbl = new TextBlock() { Text = ec_tb_charting.Year, Foreground = System.Windows.Media.Brushes.White, FontWeight = FontWeights.Medium, Margin = new Thickness(5, 0, 0, 5), VerticalAlignment = System.Windows.VerticalAlignment.Center, HorizontalAlignment = System.Windows.HorizontalAlignment.Center, }; grd.Children.Add(img); grd.Children.Add(tbl); stpYearRevenueProfittMonth.Children.Add(grd); })); } if (total_year == -1) { list_ec_tb_revenue_profit_month.Clear(); this.Dispatcher.Invoke((Action)(() => { ctcRevenueMonth.ItemsSource = null; ctlProfitMonth.ItemsSource = null; })); } } catch (Exception ex) { this.Dispatcher.Invoke((Action)(() => { ModernDialog md = new ModernDialog(); md.Title = FindResource("notification").ToString(); md.Content = ex.Message; md.ShowDialog(); })); } }
//btnSaveSendEmail_Click private void btnSaveSendEmail_Click(object sender, RoutedEventArgs e) { ModernDialog mdd = new ModernDialog(); mdd.Buttons = new Button[] { mdd.OkButton, mdd.CancelButton, }; mdd.OkButton.TabIndex = 0; mdd.OkButton.Content = FindResource("ok").ToString(); mdd.CancelButton.TabIndex = 1; mdd.CancelButton.Content = FindResource("cancel").ToString(); mdd.TabIndex = -1; mdd.Height = 200; mdd.Title = FindResource("save_invoice").ToString(); mdd.Content = FindResource("really_want_save_invoice").ToString(); mdd.OkButton.Focus(); mdd.ShowDialog(); if (mdd.MessageBoxResult == System.Windows.MessageBoxResult.OK) { if (thread_savesendemail != null && thread_savesendemail.ThreadState == ThreadState.Running) { } else { thread_savesendemail = new Thread(() => { try { this.btnSaveSendEmail.Dispatcher.Invoke((Action)(() => { this.btnSaveSendEmail.Visibility = System.Windows.Visibility.Hidden; })); this.btnSaveInvoice.Dispatcher.Invoke((Action)(() => { this.btnSaveInvoice.IsEnabled = false; })); this.btnClose.Dispatcher.Invoke((Action)(() => { this.btnClose.IsEnabled = false; })); this.mprSaveSendEmail.Dispatcher.Invoke((Action)(() => { this.mprSaveSendEmail.Visibility = System.Windows.Visibility.Visible; this.mprSaveSendEmail.IsActive = true; })); if (PayOrder() == true) { StaticClass.GeneralClass.flag_paycash = true; btnpayother_delegate(true); this.Dispatcher.Invoke((Action)(() => { SendEmail page = new SendEmail(); page.ShowInTaskbar = false; var m = Application.Current.MainWindow; page.Owner = m; if (m.RenderSize.Width > StaticClass.GeneralClass.width_screen_general) { page.Width = StaticClass.GeneralClass.width_screen_general * 90 / 100; } if (m.RenderSize.Height > System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Bottom) { page.Height = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Bottom; } else { page.Height = m.RenderSize.Height; page.Width = m.RenderSize.Width * 90 / 100; } page.orderid = bus_tb_order.GetMaxOrderID(""); page.WindowStartupLocation = WindowStartupLocation.CenterOwner; page.ShowDialog(); })); this.Dispatcher.Invoke((Action)(() => { this.Close(); })); } else { this.Dispatcher.Invoke((Action)(() => { ModernDialog md = new ModernDialog(); md.CloseButton.Content = FindResource("close").ToString(); md.Content = FindResource("error_insert").ToString(); md.Title = FindResource("notification").ToString(); md.ShowDialog(); })); } this.mprSaveSendEmail.Dispatcher.Invoke((Action)(() => { this.mprSaveSendEmail.Visibility = System.Windows.Visibility.Hidden; this.mprSaveSendEmail.IsActive = false; })); this.btnSaveSendEmail.Dispatcher.Invoke((Action)(() => { this.btnSaveInvoice.Visibility = System.Windows.Visibility.Visible; })); this.btnSaveInvoice.Dispatcher.Invoke((Action)(() => { this.btnSaveInvoice.IsEnabled = true; })); this.btnClose.Dispatcher.Invoke((Action)(() => { this.btnClose.IsEnabled = true; })); } catch (Exception ex) { this.Dispatcher.Invoke((Action)(() => { ModernDialog md = new ModernDialog(); md.CloseButton.Content = FindResource("close").ToString(); md.Content = ex.Message; md.Title = FindResource("notification").ToString(); md.ShowDialog(); })); } }); thread_savesendemail.Start(); } } }
private void GetDataFollowYear(string _str_year, string condition) { try { this.Dispatcher.Invoke((Action)(() => { this.ctRevenueProfitMonth.Title = FindResource("revenue_and_profit_in").ToString() + " " + _str_year + " (" + FindResource("unit").ToString() + ": " + StaticClass.GeneralClass.currency_setting_general + ")"; //using for revenue year this.ctcRevenueMonth.ItemsSource = null; this.ctlProfitMonth.ItemsSource = null; })); tb_revenue_year.Clear(); list_ec_tb_revenue_profit_month.Clear(); tb_revenue_year = bus_tb_orderdetail.GetTotalRevenueYear(_str_year, condition, StaticClass.GeneralClass.flag_database_type_general); for (int m = 1; m <= 12; m++) { EC_tb_Charting ec_tb_charting = new EC_tb_Charting(); if (m >= 10) { ec_tb_charting.Month = m.ToString(); } else { if (StaticClass.GeneralClass.flag_database_type_general == false) { ec_tb_charting.Month = "0" + m.ToString(); } else { ec_tb_charting.Month = m.ToString(); } } list_ec_tb_revenue_profit_month.Add(ec_tb_charting); } foreach (DataRow dr in tb_revenue_year.Rows) { for (int i = 0; i < list_ec_tb_revenue_profit_month.Count; i++) { if (list_ec_tb_revenue_profit_month[i].Month == dr["RevenueMonth"].ToString()) { list_ec_tb_revenue_profit_month[i].Revenue = Convert.ToDouble(dr["TotalRevenueMonth"].ToString()); break; } } } //using for profit year tb_capital_year.Clear(); tb_capital_year = bus_tb_orderdetail.GetTotalCapitalYear(_str_year, condition, StaticClass.GeneralClass.flag_database_type_general); foreach (DataRow dr in tb_capital_year.Rows) { for (int i = 0; i < list_ec_tb_revenue_profit_month.Count; i++) { if (list_ec_tb_revenue_profit_month[i].Month == dr["CapitalMonth"].ToString()) { double profit = list_ec_tb_revenue_profit_month[i].Revenue - Convert.ToDouble(dr["TotalCapitalMoth"].ToString()); list_ec_tb_revenue_profit_month[i].Profit = profit; break; } } } this.Dispatcher.Invoke((Action)(() => { this.ctcRevenueMonth.ItemsSource = list_ec_tb_revenue_profit_month; this.ctlProfitMonth.ItemsSource = list_ec_tb_revenue_profit_month; })); //add data to the table of revenue and profit in month this.Dispatcher.Invoke((Action)(() => { tblRevenueMonth.Text = FindResource("revenue").ToString() + "(" + StaticClass.GeneralClass.currency_setting_general.Trim() + ")"; tblProfitMonth.Text = FindResource("profit").ToString() + "(" + StaticClass.GeneralClass.currency_setting_general.Trim() + ")"; grdTableRevenueProfitMonth.ColumnDefinitions.Clear(); grdTableRevenueProfitMonth.Children.Clear(); })); for (int i = 0; i < 12; i++) { this.Dispatcher.Invoke((Action)(() => { ColumnDefinition cd = new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }; grdTableRevenueProfitMonth.ColumnDefinitions.Add(cd); Border bd = new Border() { BorderBrush = new BrushConverter().ConvertFromString("#FF212121") as Brush, BorderThickness = new Thickness(1, 0, 0, 0) }; Grid.SetRowSpan(bd, 3); Grid.SetColumn(bd, i); grdTableRevenueProfitMonth.Children.Add(bd); TextBlock tblMonth = new TextBlock() { Text = list_ec_tb_revenue_profit_month[i].Month, Style = FindResource("textBlockValue") as Style, HorizontalAlignment = HorizontalAlignment.Center, }; Grid.SetColumn(tblMonth, i); grdTableRevenueProfitMonth.Children.Add(tblMonth); TextBlock tblRevenue = new TextBlock() { Text = list_ec_tb_revenue_profit_month[i].Revenue == 0 ? FindResource("null").ToString() : GeneralClass.GetNumFormatDisplay((decimal)list_ec_tb_revenue_profit_month[i].Revenue), Style = FindResource("textBlockValue") as Style }; if (list_ec_tb_revenue_profit_month[i].Revenue == 0) { tblRevenue.Foreground = new BrushConverter().ConvertFromString("#FF212121") as Brush; } Grid.SetColumn(tblRevenue, i); Grid.SetRow(tblRevenue, 1); grdTableRevenueProfitMonth.Children.Add(tblRevenue); TextBlock tblProfit = new TextBlock() { Text = list_ec_tb_revenue_profit_month[i].Profit == 0 ? FindResource("null").ToString() : GeneralClass.GetNumFormatDisplay((decimal)list_ec_tb_revenue_profit_month[i].Profit), Style = FindResource("textBlockValue") as Style }; if (list_ec_tb_revenue_profit_month[i].Profit == 0) { tblProfit.Foreground = new BrushConverter().ConvertFromString("#FF212121") as Brush; } Grid.SetColumn(tblProfit, i); Grid.SetRow(tblProfit, 2); grdTableRevenueProfitMonth.Children.Add(tblProfit); })); } this.Dispatcher.Invoke((Action)(() => { Separator sp1 = new Separator() { VerticalAlignment = VerticalAlignment.Bottom, Background = new BrushConverter().ConvertFromString("#FF616161") as Brush, }; Grid.SetColumnSpan(sp1, list_ec_tb_revenue_profit_month.Count); grdTableRevenueProfitMonth.Children.Add(sp1); Separator sp2 = new Separator() { VerticalAlignment = VerticalAlignment.Bottom, Background = new BrushConverter().ConvertFromString("#FF616161") as Brush, }; Grid.SetColumnSpan(sp2, list_ec_tb_revenue_profit_month.Count); Grid.SetRow(sp2, 1); grdTableRevenueProfitMonth.Children.Add(sp2); })); } catch (Exception ex) { this.Dispatcher.Invoke((Action)(() => { ModernDialog md = new ModernDialog(); md.MaxWidth = 9999; md.Title = FindResource("notification").ToString(); md.Content = ex.Message; md.ShowDialog(); })); } }
public async void Open() { var selected = (CameraObject)cameraList.SelectedItem; if (selected == null) { var dlg = new ModernDialog { Title = "None selected", Content = "Please select a USB camera", }; var okButton = dlg.OkButton; okButton.Content = "Ok"; dlg.Buttons = new Button[] { okButton }; dlg.MinWidth = 400; dlg.MinHeight = 0; dlg.SizeChanged += (s, e) => { double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; double windowWidth = e.NewSize.Width; double windowHeight = e.NewSize.Height; dlg.Left = (screenWidth / 2) - (windowWidth / 2); dlg.Top = (screenHeight / 2) - (windowHeight / 2); }; dlg.ShowDialog(); } else if (Session.HasSourceOpen(selected.Name)) { var dlg = new ModernDialog { Title = "USB Cam already open", Content = "USB Cam is already open. Please choose new USB Cam to open.", }; var okButton = dlg.OkButton; okButton.Content = "Ok"; dlg.Buttons = new Button[] { okButton }; dlg.MinWidth = 400; dlg.MinHeight = 0; dlg.SizeChanged += (s, e) => { double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; double windowWidth = e.NewSize.Width; double windowHeight = e.NewSize.Height; dlg.Left = (screenWidth / 2) - (windowWidth / 2); dlg.Top = (screenHeight / 2) - (windowHeight / 2); }; dlg.ShowDialog(); } else if ((OutputResult.IsChecked ?? false) && !Directory.Exists(Path.GetFullPath(OutputFilename.Text))) { var dlg = new ModernDialog { Title = "File output is empty", Content = "Please input the file output.", }; var okButton = dlg.OkButton; okButton.Content = "Ok"; dlg.Buttons = new Button[] { okButton }; dlg.MinWidth = 400; dlg.MinHeight = 0; dlg.SizeChanged += (s, e) => { double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; double windowWidth = e.NewSize.Width; double windowHeight = e.NewSize.Height; dlg.Left = (screenWidth / 2) - (windowWidth / 2); dlg.Top = (screenHeight / 2) - (windowHeight / 2); }; dlg.ShowDialog(); } else { Datastore.GeneralSetValue("usb_cam_last", selected.Name); var session = await Session.Start(selected, selected.Name, (OutputResult.IsChecked ?? false)?OutputFilename.Text : null); var window = new InstanceWindow(session); window.Show(); } }
//LoadData private void LoadData() { if (thread_revenue_profit != null && (thread_revenue_profit.ThreadState == ThreadState.Running || thread_revenue_profit.ThreadState == ThreadState.WaitSleepJoin)) { } else { thread_revenue_profit = new Thread(() => { try { this.Dispatcher.Invoke((Action)(() => { //using for revenue and profit month this.imgSaveRevenueProfitMonthPNG.Visibility = Visibility.Hidden; this.grdRevenueProfitMonthPar.Visibility = System.Windows.Visibility.Hidden; this.mprRevenueProfitMonth.IsActive = false; this.mprRevenueProfitMonth.Visibility = System.Windows.Visibility.Hidden; //using for revenue and profit year this.imgSaveRevenueProfitYearPNG.Visibility = Visibility.Hidden; this.grdRevenueProfitYear.Visibility = System.Windows.Visibility.Hidden; this.ctRevenueProfitYear.Title = FindResource("revenue_and_profit").ToString() + " (" + FindResource("unit").ToString() + ": " + StaticClass.GeneralClass.currency_setting_general + ")"; this.mprRevenueProfitYear.Visibility = System.Windows.Visibility.Visible; this.mprRevenueProfitYear.IsActive = true; })); GetRevenueProfitAll(); this.Dispatcher.Invoke((Action)(() => { //using for revenue and profit year this.mprRevenueProfitYear.Visibility = System.Windows.Visibility.Hidden; this.mprRevenueProfitYear.IsActive = false; this.grdRevenueProfitYear.Visibility = System.Windows.Visibility.Visible; this.imgSaveRevenueProfitYearPNG.Visibility = Visibility.Visible; //using for revenue and profit month this.mprRevenueProfitMonth.Visibility = Visibility.Visible; this.mprRevenueProfitMonth.IsActive = true; })); children_previous = 0; GetYear(); Thread.Sleep(500); this.Dispatcher.Invoke((Action)(() => { this.mprRevenueProfitMonth.Visibility = System.Windows.Visibility.Hidden; this.mprRevenueProfitMonth.IsActive = false; grdRevenueProfitMonthPar.Visibility = System.Windows.Visibility.Visible; ctRevenueProfitMonth.Visibility = System.Windows.Visibility.Visible; this.imgSaveRevenueProfitMonthPNG.Visibility = Visibility.Visible; })); } catch (Exception ex) { this.Dispatcher.Invoke((Action)(() => { ModernDialog md = new ModernDialog(); md.CloseButton.Content = FindResource("close").ToString(); md.Content = ex.Message; md.Title = FindResource("notification").ToString(); md.ShowDialog(); })); } }); thread_revenue_profit.Start(); } }
//GetDatabase private void GetDatabase() { try { if (thread_getdatabase != null && thread_getdatabase.ThreadState == ThreadState.Running) { } else { thread_getdatabase = new Thread(() => { try { this.dtgDatabase.Dispatcher.Invoke((Action)(() => { dtgDatabase.Visibility = System.Windows.Visibility.Hidden; dtgDatabase.ItemsSource = null; })); this.mpr.Dispatcher.Invoke((Action)(() => { this.mpr.Visibility = System.Windows.Visibility.Visible; this.mpr.IsActive = true; })); list_tb_database.Clear(); //if database type is sqlite if (StaticClass.GeneralClass.flag_database_type_general == false) { //create folder when not exist if (!System.IO.Directory.Exists(current_directory + @"\DBRES_Local")) { System.IO.Directory.CreateDirectory(current_directory + @"\DBRES_Local"); } directory = System.IO.Directory.GetDirectories(current_directory + @"\DBRES_Local"); } // if database type is sqlserver else { //create folder when not exist if (!System.IO.Directory.Exists(current_directory + @"\DBRESSer_Local")) { System.IO.Directory.CreateDirectory(current_directory + @"\DBRESSer_Local"); } directory = System.IO.Directory.GetDirectories(current_directory + @"\DBRESSer_Local"); } string directory_name = ""; string _directory_name = ""; string __directory_name = ""; int id = 0; bool flag = false; for (int i = 0; i < directory.Length; i++) { flag = false; id++; directory_name = System.IO.Path.GetFileName(directory[i]); _directory_name = directory_name.Replace("..", ":"); __directory_name = _directory_name.Replace(".", "/"); //if database type is sqlite if (StaticClass.GeneralClass.flag_database_type_general == false) { //check exist for database in folder if (System.IO.File.Exists(directory[i] + @"\CheckOut.db") == true) { file_info = new System.IO.FileInfo(directory[i] + @"\CheckOut.db"); if (file_info.Length == 0) { System.IO.Directory.Delete(directory[i], true); flag = true; } } else { System.IO.Directory.Delete(directory[i], true); flag = true; } } //if database type is sqlserver else { //check exist for database in folder if (System.IO.File.Exists(directory[i] + @"\CheckOut.sql") == true) { file_info = new System.IO.FileInfo(directory[i] + @"\CheckOut.sql"); if (file_info.Length == 0) { System.IO.Directory.Delete(directory[i], true); flag = true; } } else if (System.IO.File.Exists(directory[i] + @"\" + CashierRegisterDAL.ConnectionDB.getSqlServerDataBaseName() + ".bak") == true) { file_info = new System.IO.FileInfo(directory[i] + @"\" + CashierRegisterDAL.ConnectionDB.getSqlServerDataBaseName() + ".bak"); if (file_info.Length == 0) { System.IO.Directory.Delete(directory[i], true); flag = true; } } else { System.IO.Directory.Delete(directory[i], true); flag = true; } } if (flag == false) { EC_tb_Database ec_tb_database = new EC_tb_Database(); ec_tb_database.Id = id; ec_tb_database.BackupDate = __directory_name; //get file info //if database type is sqlite if (StaticClass.GeneralClass.flag_database_type_general == false) { file_info = new System.IO.FileInfo(directory[i] + @"\CheckOut.db"); } //if database type is sqlserver else { if (System.IO.File.Exists(directory[i] + @"\" + CashierRegisterDAL.ConnectionDB.getSqlServerDataBaseName() + ".bak") == true) { file_info = new System.IO.FileInfo(directory[i] + @"\" + CashierRegisterDAL.ConnectionDB.getSqlServerDataBaseName() + ".bak"); } else { file_info = new System.IO.FileInfo(directory[i] + @"\CheckOut.sql"); } } ec_tb_database.FileSize = (file_info.Length / 1000).ToString() + "KB"; ec_tb_database.BitmapImage_Delete = bitmapimage_delete; ec_tb_database.BitmapImage_Restore = bitmapimage_restore; list_tb_database.Add(ec_tb_database); } } Thread.Sleep(500); this.mpr.Dispatcher.Invoke((Action)(() => { this.mpr.Visibility = System.Windows.Visibility.Hidden; this.mpr.IsActive = false; })); this.dtgDatabase.Dispatcher.Invoke((Action)(() => { dtgDatabase.Visibility = System.Windows.Visibility.Visible; dtgDatabase.ItemsSource = list_tb_database; })); this.tblTotal.Dispatcher.Invoke((Action)(() => { this.tblTotal.Text = FindResource("total").ToString() + "(" + list_tb_database.Count.ToString() + ")"; })); } catch (Exception) { this.Dispatcher.Invoke((Action)(() => { ModernDialog md = new ModernDialog(); md.Title = FindResource("notification").ToString(); md.Content = FindResource("have_not_access").ToString(); md.ShowDialog(); })); } }); thread_getdatabase.Start(); } } catch (Exception ex) { this.Dispatcher.Invoke((Action)(() => { ModernDialog md = new ModernDialog(); md.Title = FindResource("notification").ToString(); md.Content = ex.Message; md.ShowDialog(); })); } }
public void SingleUserRepin() { try { lblRepinNo.Visibility = Visibility.Hidden; txtRepinNo_Repin.Visibility = Visibility.Hidden; btnRepinUrlUplaod.Visibility = Visibility.Hidden; lblMessage_Repin.Visibility = Visibility.Hidden; txtRepinMessage_Repin.Visibility = Visibility.Hidden; Brow_Repin_Messge.Visibility = Visibility.Hidden; ClGlobul.RepinMessagesList.Clear(); ClGlobul.lstRepinUrl.Clear(); if (rbo_RepinUserRepin.IsChecked == true) { try { MessageRepin(); } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } } if (rdo_UsePinNo.IsChecked == true) { try { UserControl_SingleUser obj = new UserControl_SingleUser(); obj.UserControlHeader.Text = "Enter Pin Here "; //obj.txtEnterSingleMessages.ToolTip = "Format :- Niche::Keyword 1 ,Keyword 2"; var window = new ModernDialog { Content = obj }; window.ShowInTaskbar = true; window.MinWidth = 100; window.MinHeight = 300; Button customButton = new Button() { Content = "SAVE" }; customButton.Click += (ss, ee) => { closeEvent(); window.Close(); }; window.Buttons = new Button[] { customButton }; window.ShowDialog(); MessageBoxButton btnC = MessageBoxButton.YesNo; var result = ModernDialog.ShowMessage("Are you sure want to save ?", "Message Box", btnC); if (result == MessageBoxResult.Yes) { TextRange textRange = new TextRange(obj.txtEnterSingleMessages.Document.ContentStart, obj.txtEnterSingleMessages.Document.ContentEnd); if (!string.IsNullOrEmpty(textRange.Text)) { string enterText = textRange.Text; string[] arr = Regex.Split(enterText, "\r\n"); foreach (var arr_item in arr) { if (!string.IsNullOrEmpty(arr_item) || !arr_item.Contains("")) { ClGlobul.lstRepinUrl.Add(arr_item); } } } GlobusLogHelper.log.Info(" => [ Pin Loaded : " + ClGlobul.lstRepinUrl.Count + " ]"); GlobusLogHelper.log.Debug("Pin : " + ClGlobul.lstRepinUrl.Count); } MessageRepin(); } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } } } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } }
public static async Task JoinInvitation([NotNull] string ip, int port, [CanBeNull] string password) { OnlineManager.EnsureInitialized(); var list = OnlineManager.Instance.List; var source = new FakeSource(ip, port); var wrapper = new OnlineSourceWrapper(list, source); ServerEntry server; using (var waiting = new WaitingDialog()) { waiting.Report(ControlsStrings.Common_Loading); await wrapper.EnsureLoadedAsync(); server = list.GetByIdOrDefault(source.Id); if (server == null) { throw new Exception(@"Unexpected"); } } if (password != null) { server.Password = password; } var content = new OnlineServer(server) { Margin = new Thickness(0, 0, 0, -38), ToolBar = { FitWidth = true }, // Values taken from ModernDialog.xaml // TODO: Extract them to some style? Title = { FontSize = 24, FontWeight = FontWeights.Light, Margin = new Thickness(6, 0, 0, 8) } }; content.Title.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Ideal); var dlg = new ModernDialog { ShowTitle = false, Content = content, MinHeight = 400, MinWidth = 450, MaxHeight = 99999, MaxWidth = 700, Padding = new Thickness(0), ButtonsMargin = new Thickness(8), SizeToContent = SizeToContent.Manual, ResizeMode = ResizeMode.CanResizeWithGrip, LocationAndSizeKey = @".OnlineServerDialog" }; dlg.SetBinding(Window.TitleProperty, new Binding { Path = new PropertyPath(nameof(server.DisplayName)), Source = server }); dlg.ShowDialog(); await wrapper.ReloadAsync(true); }
private void SingleUserAddUserToBoard() { try { objAddUsersToBoardManager.rdbSingleUserAddUserToBoard = true; objAddUsersToBoardManager.rdbMultipleUserAddUserToBoard = false; btnUserNames_AddUsersToBoard_Browse.Visibility = Visibility.Hidden; txtEmailOrUserNames.Visibility = Visibility.Hidden; lblEmailOrUsername.Visibility = Visibility.Hidden; ClGlobul.lstAddToBoardUserNames.Clear(); #region Email or Username try { UserControl_SingleUser obj = new UserControl_SingleUser(); obj.UserControlHeader.Text = "Enter Email or UserName Here "; //obj.txtEnterSingleMessages.ToolTip = "Format :- Niche:Board Name 1 , Board Name 2"; var window = new ModernDialog { Content = obj }; window.ShowInTaskbar = true; window.MinWidth = 100; window.MinHeight = 300; Button customButton = new Button() { Content = "SAVE" }; customButton.Click += (ss, ee) => { closeEvent(); window.Close(); }; window.Buttons = new Button[] { customButton }; window.ShowDialog(); MessageBoxButton btnC = MessageBoxButton.YesNo; var result = ModernDialog.ShowMessage("Are you sure want to save ?", "Message Box", btnC); if (result == MessageBoxResult.Yes) { TextRange textRange = new TextRange(obj.txtEnterSingleMessages.Document.ContentStart, obj.txtEnterSingleMessages.Document.ContentEnd); if (!string.IsNullOrEmpty(textRange.Text)) { string enterText = textRange.Text; string[] arr = Regex.Split(enterText, "\r\n"); foreach (var arr_item in arr) { if (!string.IsNullOrEmpty(arr_item) || !arr_item.Contains("")) { ClGlobul.lstAddToBoardUserNames.Add(arr_item); } } } else { GlobusLogHelper.log.Info("Please Upload Email or Username"); ModernDialog.ShowMessage("Please Upload Email or Username", "Upload Email or Username", MessageBoxButton.OK); return; } GlobusLogHelper.log.Info("Email or UserName Loaded : " + ClGlobul.lstAddToBoardUserNames.Count); GlobusLogHelper.log.Debug("Email or UserName Loaded : " + ClGlobul.lstAddToBoardUserNames.Count); } } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } #endregion } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } }
public SerialsPage() { InitializeComponent(); NameScope.SetNameScope(dgcm, NameScope.GetNameScope(this)); VM = MainViewModel.Default.SerialsViewModel; VM.ConfirmationShow = (s1, s2) => { var dialog = new ModernDialog { Title = s1, Content = s2 }; MessageBoxResult result = MessageBoxResult.Cancel; var yesButton = new Button() { Content = "Да", Margin = new Thickness(2, 0, 2, 0) }; yesButton.Click += (o, ea) => { result = MessageBoxResult.Yes; dialog.Close(); }; var noButton = new Button() { Content = "Нет", Margin = new Thickness(2, 0, 2, 0), FontWeight = FontWeights.Bold, IsDefault = true }; noButton.Click += (o, ea) => { result = MessageBoxResult.No; dialog.Close(); }; dialog.Buttons = new Button[] { yesButton, noButton }; dialog.ShowDialog(); if (result == MessageBoxResult.Yes) { return(true); } else { return(false); } }; VM.TextSearchStarted = () => { tbFilter.Focus(); Keyboard.Focus(tbFilter); }; dg.Focus(); Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.ContextIdle, new Action(() => Keyboard.Focus(dg))); dg.SyncSortWithView(); VM.Refreshed = () => dg.ScrollToCurrentItem(); DataContext = VM; }
private void GetOrders(int be_limit, int af_limit, string _con1, string _con2) { if (thread_order != null && thread_order.ThreadState == ThreadState.Running) { } else { thread_order = new Thread(() => { try { list_ec_tb_order.Clear(); this.Dispatcher.Invoke((Action)(() => { this.chkAll.IsChecked = false; this.mpr.Visibility = System.Windows.Visibility.Visible; this.mpr.IsActive = true; this.dtgOrders.Visibility = System.Windows.Visibility.Hidden; dtgOrders.Items.Refresh(); })); dt_orders.Clear(); int no = paging_number_previous - 1; using (dt_orders = bus_tb_order.GetOrderFollowPaging(be_limit, af_limit, _con1, _con2, StaticClass.GeneralClass.flag_database_type_general)) { foreach (DataRow dr in dt_orders.Rows) { _orderDate = string.Format(@"{0:" + StaticClass.GeneralClass.dateFromatSettings[StaticClass.GeneralClass.app_settings["dateFormat"]].ToString() + _orderTime + "}", Convert.ToDateTime(dr["OrderDate"].ToString())); no++; EC_tb_Order ec_tb_order = new EC_tb_Order(); ec_tb_order.No = no; ec_tb_order.OrderID = Convert.ToInt32(dr["OrderID"].ToString()); ec_tb_order.CustomerID = Convert.ToInt32(dr["CustomerID"].ToString()); ec_tb_order.CustomerName = dr["CustomerName"].ToString(); ec_tb_order.Quatity = Convert.ToInt32(dr["Quantity"].ToString()); ec_tb_order.OrderDate = _orderDate; //dr["OrderDate"].ToString(); ec_tb_order.SalesPersonID = Convert.ToInt32(dr["SalespersonID"].ToString()); ec_tb_order.SalesPersonName = dr["SalespersonName"].ToString(); ec_tb_order.PaymentID = Convert.ToInt32(dr["PaymentID"].ToString()); ec_tb_order.PaymentName = dr["PaymentName"].ToString(); ec_tb_order.DiscountType = Convert.ToInt32(dr["DiscountType"].ToString()); if (ec_tb_order.DiscountType == 1) { ec_tb_order.DisAmount = ""; ec_tb_order.DisPercent = "%"; } else { ec_tb_order.DisAmount = StaticClass.GeneralClass.currency_setting_general; ec_tb_order.DisPercent = ""; } ec_tb_order.Discount = Convert.ToDecimal(dr["Discount"].ToString()); ec_tb_order.StrDiscount = StaticClass.GeneralClass.GetNumFormatDisplay(ec_tb_order.Discount); ec_tb_order.TotalDiscount = Convert.ToDecimal(string.IsNullOrEmpty(dr["TotalDiscount"].ToString()) ? "0" : dr["TotalDiscount"].ToString()); ec_tb_order.StrTotalDiscount = StaticClass.GeneralClass.currency_setting_general + StaticClass.GeneralClass.GetNumFormatDisplay(ec_tb_order.TotalDiscount); ec_tb_order.TotalTax = Convert.ToDecimal(dr["TotalTax"].ToString()); ec_tb_order.StrTotalTax = StaticClass.GeneralClass.currency_setting_general + StaticClass.GeneralClass.GetNumFormatDisplay(ec_tb_order.TotalTax); ec_tb_order.TotalAmount = Convert.ToDecimal(dr["TotalAmount"].ToString()); ec_tb_order.StrTotalAmount = StaticClass.GeneralClass.currency_setting_general + StaticClass.GeneralClass.GetNumFormatDisplay(ec_tb_order.TotalAmount); ec_tb_order.ImageSource = @"pack://application:,,,/Resources/ViewDetails.png"; ec_tb_order.CheckDel = false; ec_tb_order.Currency = StaticClass.GeneralClass.currency_setting_general; list_ec_tb_order.Add(ec_tb_order); } } this.Dispatcher.Invoke((Action)(() => { tblTotal.Text = FindResource("total").ToString() + "(" + list_ec_tb_order.Count.ToString() + ")"; dtgOrders.Items.Refresh(); })); Thread.Sleep(500); this.Dispatcher.Invoke((Action)(() => { this.mpr.Visibility = System.Windows.Visibility.Hidden; this.mpr.IsActive = false; this.dtgOrders.Visibility = System.Windows.Visibility.Visible; })); //data statistic DataStatistic(); //set condition report order if (StaticClass.GeneralClass.flag_database_type_general == false) { StaticClass.GeneralClass.condition_report_order = "select * from [tb_Order] " + _con1 + " limit " + be_limit + ", " + af_limit; } else { StaticClass.GeneralClass.condition_report_order = "select top(" + af_limit + ") * from [tb_Order] where [OrderID] not in (select top(" + be_limit + ") [OrderID] from [tb_Order] " + _con1 + ") " + _con2; } } catch (Exception ex) { this.Dispatcher.Invoke((Action)(() => { ModernDialog md = new ModernDialog(); md.CloseButton.Content = FindResource("close").ToString(); md.Title = FindResource("notification").ToString(); md.Content = ex.Message; md.ShowDialog(); })); } }); thread_order.Start(); } }
public void rdbSingleUserLikeByKeyword() { try { objLikeByKeywordManager.rdbSingleUserLikeByKeyword = true; objLikeByKeywordManager.rdbMultipleUserLikeByKeyword = false; btnKeyword_LikeByKeyword_Browse.Visibility = Visibility.Hidden; lbKeyword_LikeByKeyword.Visibility = Visibility.Hidden; txt_KeywordLike.Visibility = Visibility.Hidden; lbHint_LikeByKeyword.Visibility = Visibility.Hidden; ClGlobul.lstLikeByKeyword.Clear(); try { UserControl_SingleUser obj = new UserControl_SingleUser(); obj.UserControlHeader.Text = "Enter Keyword Here "; obj.txtEnterSingleMessages.ToolTip = "Format :- Niche::Keyword"; var window = new ModernDialog { Content = obj }; window.ShowInTaskbar = true; window.MinWidth = 100; window.MinHeight = 300; Button customButton = new Button() { Content = "SAVE" }; customButton.Click += (ss, ee) => { closeEvent(); window.Close(); }; window.Buttons = new Button[] { customButton }; window.ShowDialog(); MessageBoxButton btnC = MessageBoxButton.YesNo; var result = ModernDialog.ShowMessage("Are you sure want to save ?", "Message Box", btnC); if (result == MessageBoxResult.Yes) { TextRange textRange = new TextRange(obj.txtEnterSingleMessages.Document.ContentStart, obj.txtEnterSingleMessages.Document.ContentEnd); if (!string.IsNullOrEmpty(textRange.Text)) { string enterText = textRange.Text; string[] arr = Regex.Split(enterText, "\r\n"); foreach (var arr_item in arr) { if (!string.IsNullOrEmpty(arr_item) || !arr_item.Contains("")) { ClGlobul.lstLikeByKeyword.Add(arr_item); } } } GlobusLogHelper.log.Info(" => [ Keyword Loaded : " + ClGlobul.lstLikeByKeyword.Count + " ]"); GlobusLogHelper.log.Debug("Keyword : " + ClGlobul.lstLikeByKeyword.Count); } } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } }
public async void Open() { if (Session.HasSourceOpen(IPCamLink.Text)) { var dlg = new ModernDialog { Title = "IP link already open", Content = "IP link provided is already open. Please provide new ip link.", }; var okButton = dlg.OkButton; okButton.Content = "Ok"; dlg.Buttons = new Button[] { okButton }; dlg.MinWidth = 400; dlg.MinHeight = 0; dlg.SizeChanged += (s, e) => { double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; double windowWidth = e.NewSize.Width; double windowHeight = e.NewSize.Height; dlg.Left = (screenWidth / 2) - (windowWidth / 2); dlg.Top = (screenHeight / 2) - (windowHeight / 2); }; dlg.ShowDialog(); } else if (!PingHost(IPCamLink.Text)) { var dlg = new ModernDialog { Title = "IP link error", Content = "IP link provided does not exist. Please select valid ip cam link.", }; var okButton = dlg.OkButton; okButton.Content = "Ok"; dlg.Buttons = new Button[] { okButton }; dlg.MinWidth = 400; dlg.MinHeight = 0; dlg.SizeChanged += (s, e) => { double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; double windowWidth = e.NewSize.Width; double windowHeight = e.NewSize.Height; dlg.Left = (screenWidth / 2) - (windowWidth / 2); dlg.Top = (screenHeight / 2) - (windowHeight / 2); }; dlg.ShowDialog(); } else if ((OutputResult.IsChecked ?? false) && !Directory.Exists(Path.GetFullPath(OutputFilename.Text))) { var dlg = new ModernDialog { Title = "File output is empty", Content = "Please input the file output.", }; var okButton = dlg.OkButton; okButton.Content = "Ok"; dlg.Buttons = new Button[] { okButton }; dlg.MinWidth = 400; dlg.MinHeight = 0; dlg.SizeChanged += (s, e) => { double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; double windowWidth = e.NewSize.Width; double windowHeight = e.NewSize.Height; dlg.Left = (screenWidth / 2) - (windowWidth / 2); dlg.Top = (screenHeight / 2) - (windowHeight / 2); }; dlg.ShowDialog(); } else { Datastore.GeneralSetValue("ip_cam_last", IPCamLink.Text); var session = await Session.Start(IPCamLink.Text, Path.GetFileName(IPCamLink.Text.Replace("//", ".")), (OutputResult.IsChecked ?? false)?OutputFilename.Text : null); var window = new InstanceWindow(session); window.Show(); } }