public static string ConvertPersonallyIdentifiableInformationToString(PersonallyIdentifiableInformation personallyIdentifiableInformation) { string result = ""; StringBuilder sb = null; if (personallyIdentifiableInformation != null) { sb = new StringBuilder(); sb.Append("Id: "); sb.Append(personallyIdentifiableInformation.Id.ToString()); sb.Append(" "); sb.Append("Type: "); sb.Append(personallyIdentifiableInformation.Type); sb.Append(" "); sb.Append("First Name: "); sb.Append(personallyIdentifiableInformation.FirstName); sb.Append(" "); sb.Append("Last Name: "); sb.Append(personallyIdentifiableInformation.LastName); sb.Append(" "); sb.Append("Date of Birth: "); sb.Append(personallyIdentifiableInformation.DateOfBirth.ToString("MM/dd/yyyy")); sb.Append(" "); sb.Append("Gender: "); sb.Append(personallyIdentifiableInformation.Gender); result = sb.ToString(); } return(result); }
public static PersonallyIdentifiableInformation ConvertPersonallyIdentifiableInformation(string line, char delim) { PersonallyIdentifiableInformation personallyIdentifiableInformation = null; string[] words = null; Guid id = Guid.Empty; DateTime dt = DateTime.MinValue; Int32 val = 0; CultureInfo culture; DateTimeStyles styles = DateTimeStyles.None; culture = CultureInfo.CreateSpecificCulture("en-US"); if (string.IsNullOrEmpty(line) == false) { words = line.Split(delim); if (words != null) { if (words.Length == 6) { personallyIdentifiableInformation = new PersonallyIdentifiableInformation(); personallyIdentifiableInformation.Type = words[0]; if (Guid.TryParse(words[1], out id) == true) { personallyIdentifiableInformation.Id = id; } personallyIdentifiableInformation.FirstName = words[2]; personallyIdentifiableInformation.LastName = words[3]; if (DateTime.TryParse(words[4], culture, styles, out dt) == true) { personallyIdentifiableInformation.DateOfBirth = dt; } if (Int32.TryParse(words[5], out val) == true) { if ((val == 0) || (val == 1)) { personallyIdentifiableInformation.Gender = val; } } } } } return(personallyIdentifiableInformation); }
private bool checkInputs() { bool result = false; int count = 0; personallyIdentifiableInformation = new PersonallyIdentifiableInformation(); if (string.IsNullOrEmpty(firstNameTextbox.Text) == true) { count++; this.errorProvider1.SetError(firstNameTextbox, "First Name is a required input!"); } else { personallyIdentifiableInformation.FirstName = firstNameTextbox.Text; } if (string.IsNullOrEmpty(lastNameTextbox.Text) == true) { count++; this.errorProvider1.SetError(lastNameTextbox, "Last Name is a required input!"); } else { personallyIdentifiableInformation.LastName = lastNameTextbox.Text; } if ((maleRadioButton.Checked == false) && (femaleRadioButton.Checked == false)) { count++; this.errorProvider1.SetError(genderGroupBox, "Gender is a required input!"); } else { if (maleRadioButton.Checked == true) { personallyIdentifiableInformation.Gender = 0; } if (femaleRadioButton.Checked == true) { personallyIdentifiableInformation.Gender = 1; } } if (string.IsNullOrEmpty(datePicker1.Text) == true) { count++; this.errorProvider1.SetError(datePicker1, "Date Of Birth is a required input!"); } else { personallyIdentifiableInformation.DateOfBirth = datePicker1.Value; } if (count == 0) { result = true; } else { personallyIdentifiableInformation = null; } return(result); }
private void LoadPII() { StringBuilder stringBuilder = null; string messageText = ""; Exception exceptionDetails = null; string path = MS539_final_project_roderick_devalcourt.Properties.Settings.Default.DefaultPath; string fileName = MS539_final_project_roderick_devalcourt.Properties.Settings.Default.FileName; try { readFileLogic = new ReadFileLogic(); if (readFileLogic != null) { readFileLogic.PathName = path; readFileLogic.FileName = fileName; readFileLogic.GetFormattedFileName(); if (File.Exists(readFileLogic.FilePathName) == true) { readFileLogic.ReadFile(); readFileLogic.SetupListsByDay(); firstNameTextbox.Text = readFileLogic.personallyIdentifiableInformation.FirstName; lastNameTextbox.Text = readFileLogic.personallyIdentifiableInformation.LastName; switch (readFileLogic.personallyIdentifiableInformation.Gender) { case 0: maleRadioButton.Checked = true; femaleRadioButton.Checked = false; break; case 1: maleRadioButton.Checked = false; femaleRadioButton.Checked = true; break; } datePicker1.Value = readFileLogic.personallyIdentifiableInformation.DateOfBirth; personallyIdentifiableInformation = new PersonallyIdentifiableInformation(readFileLogic.personallyIdentifiableInformation); } } } catch (ArgumentOutOfRangeException oops) { // do nothing } catch (Exception exception) { stringBuilder = new StringBuilder(); exceptionDetails = exception; while (exceptionDetails != null) { messageText = "\r\nMessage: " + exceptionDetails.Message + "\r\nSource: " + exceptionDetails.Source + "\r\nStack Trace: " + exceptionDetails.StackTrace + "\r\n----------\r\n"; stringBuilder.Append(messageText); exceptionDetails = exceptionDetails.InnerException; } messageText = stringBuilder.ToString(); System.Diagnostics.Debug.WriteLine(messageText); MessageBox.Show(this, messageText, "Error"); } }