public void DatabaseTests() { DatabaseManager database = new DatabaseManager(); List<Contact> contactList; //Contact List Populated contactList = database.retrieveContacts(); Assert.IsNotNull(contactList); foreach (Contact contact in contactList) { Assert.IsNotNull(contact); } }
private void buttonAdd_Click(object sender, EventArgs e) { DatabaseManager database = new DatabaseManager(); try { database.add(textBoxLastName.Text, textBoxFirstName.Text, textBoxEmail.Text, checkBoxPreviousContact.Checked); MessageBox.Show("Contact added."); } catch (Exception excep) { MessageBox.Show("Error: Contact already exists.", "Duplicate Contact", MessageBoxButtons.OK, MessageBoxIcon.Error); using (StreamWriter writer = new StreamWriter("errorlog.txt")) { writer.WriteLine(excep); } } closeDialog(); }
private void loadContacts() { DatabaseManager database = new DatabaseManager(); contactList = database.retrieveContacts(); updateGridView(); }
private void textBoxSearch_KeyUp(object sender, KeyEventArgs e) { clearContacts(); if (textBoxSearch.Text == "") { loadContacts(); return; } DatabaseManager dbase = new DatabaseManager(); contactList = dbase.retrieveByLastName(textBoxSearch.Text); updateGridView(); }
private void buttonDeleteSelected_Click(object sender, EventArgs e) { string message = "Are you sure you want to " + "delete the selected contact(s)"; string caption = "Confirmation"; DialogResult res; res = MessageBox.Show(message, caption, MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); if (res == DialogResult.OK) { string delContact = ""; DatabaseManager database = new DatabaseManager(); foreach (DataGridViewRow row in dataGridViewContactList.SelectedRows) { delContact = row.Cells[2].Value.ToString(); database.delete(delContact); } message = "Contact(s) Deleted"; MessageBox.Show(message, "", MessageBoxButtons.OK); clearContacts(); loadContacts(); } }