/// <summary> /// Persists the user PII data to the database /// </summary> private void PersistData() { try { Person person; Char[] splitter = new Char[] { ',' }; String tableName, dataBaseName; //Get the table name and datatbase name from the configuration file tableName = Configurations.TableName; dataBaseName = Configurations.DatabaseName; //Check if the data is valid if (!ValidateData()) return; person = new Person { Volunteer = lblName.Text.Trim(), Children = txtChildren.Text.Trim().Split(splitter), GrandChildren = txtGrandChildren.Text.Trim().Split(splitter), City = txtCity.Text, CurrentEmployers = txtCurrentEmployer.Text.Trim().Split(splitter), MonthOfBirth = drpMonth.SelectedValue, DayOfBirth = drpDay.SelectedValue, YearOfBirth = drpYear.SelectedValue, EmailAddress = txtEmail.Text.Trim(), FullName = txtName.Text.Trim(), PastEmployers = txtPastEmployer.Text.Trim().Split(splitter), PhoneNumber = txtPhone1.Text.Trim() + "-" + txtPhone2.Text.Trim() + "-" + txtPhone3.Text.Trim(), SpouseName = txtSpouse.Text.Trim(), State = txtState.Text.Trim(), StreetAddress = txtStreet.Text.Trim(), Zip = txtZip.Text.Trim(), LastUpdatedOn = DateTime.Now.ToShortDateString() }; //Insert the data to database DBUtility dbUtility = new DBUtility(); dbUtility.UpdateData(dataBaseName, tableName, person); DisplayMessage("Successfully updated your data"); } catch (Exception ex) { DisplayMessage("Unable to update your data"); Logger.Log("PersistData: " + ex.Message); } }
/// <summary> /// Persists the website data to the database /// </summary> private void PersistData() { //Declaratoins DBUtility dbUtility = new DBUtility(); String dbName = Configurations.DatabaseName; String tableName = Configurations.Websites; try { //Check if the data is valid if (!ValidateData()) return; Website website = new Website(); website.Name = txtName.Text; website.URL = txtURL.Text; website.IsActive = true; website.LastUpdatedOn = DateTime.Now.ToShortDateString(); //Update the data dbUtility.UpdateData(dbName, tableName, website); //Clear the textboxes txtName.Text = String.Empty; txtURL.Text = String.Empty; } catch (Exception ex) { DisplayMessage("Unable to update your data"); Logger.Log("PersistData: " + ex.Message); } }