private void AddBrrwrBtn_Click(object sender, EventArgs e) { string Name = NameTxt.Text; string SSN = SSNTxt.Text; string Address = AddressTxt.Text; string Phone = PhoneTxt.Text; string Email = EmailTxt.Text; bool SSN_Unique = Check_SSN(SSN); if (!string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(SSN) && !string.IsNullOrEmpty(Address)) { SSN = Format_SSN(SSN); if (SSN_Unique == true) { Execute_Add_Borrower(Name, SSN, Address, Phone, Email); } else { MessageBox.Show("The SSN number provided is already in use. Please enter another SSN or update the existing record."); } } else { MessageBox.Show("The values for Name, SSN, and Address must be filled in."); } NameTxt.Clear(); SSNTxt.Clear(); AddressTxt.Clear(); PhoneTxt.Clear(); EmailTxt.Clear(); Load_Borrower_View(); }
private void CancelBtn_Click(object sender, EventArgs e) { NameTxt.Clear(); SSNTxt.Clear(); AddressTxt.Clear(); PhoneTxt.Clear(); EmailTxt.Clear(); }
private string Format_SSN(string SSN) { string NewSSN = ""; if (SSN.Length <= 11 && SSN.Length > 8) { if (SSN[3] != '-' && SSN[6] != '-' && SSN[5] != '-') { NewSSN = string.Join("-", SSN.Substring(0, 3), SSN.Substring(3, 2), SSN.Substring(5, 4)); } else if (SSN[3] == '-' && SSN[6] != '-') { NewSSN = string.Join("-", SSN.Substring(0, 6), SSN.Substring(6, 4)); } else if (SSN[3] != '-' && SSN[5] == '-') { NewSSN = string.Join("-", SSN.Substring(0, 3), SSN.Substring(3, 7)); } else if (SSN[3] == '-' && SSN[6] == '-') { NewSSN = SSN; } else { MessageBox.Show("The format for the SSN is not recognized please try again."); SSNTxt.Clear(); } } else if (SSN.Length > 11) { MessageBox.Show("The length of the SSN exceeds the maximum, please try again."); SSNTxt.Clear(); } else { MessageBox.Show("The length of the SSN is to short, please try again."); SSNTxt.Clear(); } return(NewSSN); }