private void OnEditAccount() { if (listViewAccounts.SelectedItems.Count > 0) { ListViewItem item = listViewAccounts.SelectedItems[0]; EmailAccount a = (EmailAccount)item.Tag; AccountForm f = new AccountForm(a); while (f.ShowDialog() == DialogResult.OK) { string username = f.GetUsername(); if (string.IsNullOrEmpty(username)) { QMessageBox.ShowWarning("username can't be empty!"); } else if (!IsEmailAddress(username)) { QMessageBox.ShowWarning("email address is not valid!"); } else if (string.IsNullOrEmpty(f.GetPassword())) { QMessageBox.ShowWarning("password can't be empty!"); } else if (string.IsNullOrEmpty(f.GetNickname())) { QMessageBox.ShowWarning("nickname can't be empty!"); } else if (string.IsNullOrEmpty(f.GetServer())) { QMessageBox.ShowWarning("server can't be empty!"); } else { a.Username = f.GetUsername(); a.Password = f.GetPassword(); a.Nickname = f.GetNickname(); a.Server = f.GetServer(); a.Port = f.GetPort(); a.EnableSsl = f.EnabledSsl(); ShowAccount(item); listViewAccounts.Update(); BuildAccountsList(); break; } } } }
private void addAccountToolStripMenuItem_Click(object sender, EventArgs e) { AccountForm f = new AccountForm(); while (f.ShowDialog() == DialogResult.OK) { string username = f.GetUsername(); if (string.IsNullOrEmpty(username)) { QMessageBox.ShowWarning("username can't be empty!"); } else if (!IsEmailAddress(username)) { QMessageBox.ShowWarning("email address is not valid!"); } else if (string.IsNullOrEmpty(f.GetPassword())) { QMessageBox.ShowWarning("password can't be empty!"); } else if (string.IsNullOrEmpty(f.GetNickname())) { QMessageBox.ShowWarning("nickname can't be empty!"); } else if (string.IsNullOrEmpty(f.GetServer())) { QMessageBox.ShowWarning("server can't be empty!"); } else { EmailAccount a = f.GetAccount(); listViewAccounts.Items.Add(BuildListViewItem(a)); DataCenter.Instance.Add(a); BuildAccountsList(); break; } } }