private void button1_Click(object sender, RoutedEventArgs e) { ConnSQL connSQL = new ConnSQL(); bool success = connSQL.authentication(UsernameTextbox.Text, passwordBox1.Password); if (success == true) { MessageBox.Show("Authentication succeded.", "Talk2Me", MessageBoxButton.OK, MessageBoxImage.Exclamation); TechnicalSupport ts = new TechnicalSupport(); ts.UsernameTextBlock.Text = UsernameTextbox.Text; this.Hide(); ts.Show(); } else MessageBox.Show("Authentication failed.", "Talk2Me", MessageBoxButton.OK, MessageBoxImage.Stop); }
public TechnicalSupport() { InitializeComponent(); // dataGrid1.ItemsSource = new ObservableCollection<Object[]>(); // dataGrid1.ItemsSource. user_list = new List<string>(); ConnSQL connSQL = new ConnSQL(); string users = connSQL.getUsers(); listBox1.Items.Clear(); string[] str = null;// user.GroupsFriends; string delimit = "|"; Label newlabel; str = users.Split(delimit.ToCharArray()); for (int i = 0; i < str.Length; i++) { newlabel = new Label(); newlabel.HorizontalAlignment = HorizontalAlignment.Center; newlabel.FontSize = 14; newlabel.Content = str[i]; newlabel.ContextMenu = new ContextMenu(); MenuItem mi = new MenuItem(); mi.Header = "Remove user"; mi.Click += new RoutedEventHandler(MiRemoveUser_Click); newlabel.ContextMenu.Items.Add(mi); newlabel.Height = 40; newlabel.HorizontalAlignment = HorizontalAlignment.Center; newlabel.Width = 234; newlabel.MouseEnter += new MouseEventHandler(newlabel_MouseEnter); listBox1.Items.Add(newlabel); user_list.Add(str[i]); } }
void MiRemoveUser_Click(object sender, RoutedEventArgs e) { ConnSQL connSQL = new ConnSQL(); connSQL.deleteUser(this.selectedlabel.Content.ToString()); user_list.Remove(this.selectedlabel.Content.ToString()); updateContactListBox(); }