private void btnSubmit_Click(object sender, EventArgs e) { if (txtFirstName.Text.Length > 0) { // Create client item Information newClientInfo = new Information { FirstName = txtFirstName.Text, MiddleName = txtMiddleName.Text, LastName = txtLastName.Text, Address1 = txtAddress1.Text, Address2 = txtAddress2.Text, City = txtCity.Text, Province = txtProvince.Text, PostalCode = txtPostalCode.Text, Country = txtCountry.Text, Phone = txtPhone.Text, Email = txtEmail.Text }; App.ViewModel.AddClientInfoItem(newClientInfo); MessageBox.Show("Data Added Successfully!"); btnClear_Click(sender, e); } }
// Remove a client info item from the database and collection public void DeleteClientInfoItem(Information clientInfoForDelete) { // Remove the client info item from the "all" observable collection. AllClientInfoItems.Remove(clientInfoForDelete); // Remove the client info item from the data context. clientInfoDB.Clients.DeleteOnSubmit(clientInfoForDelete); // Save changes to the database. clientInfoDB.SubmitChanges(); }
// Add Client Information Item to the database and collection public void AddClientInfoItem(Information newClientInfoItem) { // Add a client info item to the data context. clientInfoDB.Clients.InsertOnSubmit(newClientInfoItem); // Save changes to the database clientInfoDB.SubmitChanges(); // Add a client info item to the "all" observable collection. AllClientInfoItems.Add(newClientInfoItem); }