private void txtChanged(object sender, EventArgs e) // Testing Generic Length Checker { if (ActiveControl == txt_Forename || ActiveControl == txt_Surname || ActiveControl == txt_Forename_Edit || ActiveControl == txt_Surname_Edit) { if (!(MyValidation.validLength(ActiveControl.Text, 2, 30))) { ActiveControl.BackColor = Color.LightGray; errP.SetError(ActiveControl, "Needs to have between 2 and 20 letters"); } else { ActiveControl.BackColor = Color.White; errP.Clear(); } } if (ActiveControl == txt_Postcode || ActiveControl == txt_Postcode_Edit) { if (!(MyValidation.postcodeChk(ActiveControl.Text))) { ActiveControl.BackColor = Color.LightGray; errP.SetError(ActiveControl, "Must Be [a-z][a-z][0-9][0-9][SPACE][0-9][a-z][a-z]"); } else { ActiveControl.BackColor = Color.White; errP.Clear(); } } if (ActiveControl == txt_Email || ActiveControl == txt_Email_Edit) { if (!(MyValidation.validEmail(ActiveControl.Text))) { ActiveControl.BackColor = Color.LightGray; errP.SetError(ActiveControl, "Must Be a valid email address like '*****@*****.**' "); } else { ActiveControl.BackColor = Color.White; errP.Clear(); } } }
private void txt_FindSur_TextChanged(object sender, EventArgs e) { if (txt_FindName.Text == "") { lb_AvailClients.Visible = false; lb_AvailClients.Items.Clear(); } else { lb_AvailClients.Height = 17; lb_AvailClients.Visible = true; lb_AvailClients.Items.Clear(); lb_AvailClients.BackColor = Color.White; foreach (DataRow dr in dsNWRC_HairBeauty.Tables["Client"].Rows) { String searchInput = MyValidation.firstlettertoUpper(txt_FindName.Text); if (dr["Forename"].ToString().StartsWith(searchInput)) /// changed search from surname to forename { if (!(lb_AvailClients.Items.Contains(dr["Surname"].ToString()))) { lb_AvailClients.Items.Add(dr["Forename"].ToString() + " " + dr["Surname"].ToString()); } } } // Make textbox the size of all clients only lb_AvailClients.Height = lb_AvailClients.Height * lb_AvailClients.Items.Count; } if (lb_AvailClients.Items.Count == 0) { lbl_NoClient.Visible = true; btn_AddNewClient.Visible = true; } else { lbl_NoClient.Visible = false; btn_AddNewClient.Visible = false; } }