private void DeleteLabel_MouseDown(object sender, MouseButtonEventArgs e) { TextBlock tb = sender as TextBlock; Reseller res = tb.Tag as Reseller; //System.Windows.Forms.MessageBox.Show("You have selected " + res.Name); MessageBoxResult result = MessageBox.Show("Are you sure you want to delete " + res.Name, "Delete", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No); if (result == MessageBoxResult.Yes) { ResellerXml.DeleteReseller(res); ResellerNameTextBox.Text = ""; } e.Handled = true; }
async private void AddButton_Click(object sender, RoutedEventArgs e) { AddButton.IsEnabled = false; ErrorLabel.Text = ""; string name = ResellerNameTextBox.Text.ToLowerInvariant(); string pass = ResellerPassTextBox.Text; if (!name.Contains("ahkvoip")) { ErrorLabel.Text = "Reseller not working with this program."; return; } try { bool resellerCreated = await ResellerAPI.CheckReseller(name, pass); if (resellerCreated) { ResellerXml.AddReseller(name, pass); ResellerNameTextBox.Text = ""; ResellerPassTextBox.Text = ""; App.CustomersDB.AddReseller(new Reseller(name, pass)); } else { ErrorLabel.Text = "Wrong password,try again later"; AddButton.IsEnabled = true; } } catch (NoInternetException) { ErrorLabel.Text = "No Internet Connection!"; AddButton.IsEnabled = true; } catch (Exception ex) { ErrorLabel.Text = ex.Message; } }
private void Application_Startup(object sender, StartupEventArgs e) { //bool ownsMutex = false; //Mutex = new Mutex(true, "EuroTransferMutex", out ownsMutex); //GC.KeepAlive(Mutex); //// If the application owns the Mutex it can continue to execute; //// otherwise, the application should exit. //if (!ownsMutex) //{ var currentProcess = Process.GetCurrentProcess(); var processes = Process.GetProcessesByName(currentProcess.ProcessName); var process = processes.FirstOrDefault(p => p.Id != currentProcess.Id); if (process != null) { SetForegroundWindow(process.MainWindowHandle); this.Shutdown(); } //} ResellerXml.InitializeFile(); if (Resellers.Count == 0) { this.StartupUri = new Uri("Dialogs/ResellerWindow.xaml", UriKind.Relative); } else { foreach (Reseller res in Resellers) { CustomersDB.GetCustomers(res); res.UpdateCustomers(); } this.StartupUri = new Uri("MainWindow.xaml", UriKind.Relative); } }