private void ImmunizationNoTextBox_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Enter) { if (ImmunizationNoTextBox.Text == String.Empty) { MessageBox.Show("Cannot Be Empty"); return; } if (!ops.ReadImmuHeader(connect, ImmunizationNoTextBox.Text)) { ImmunizationNoTextBox.Clear(); MessageBox.Show("Immunization Number already in file"); return; } ImmunizationPatientCodeTextBox.Focus(); } }
//Immunize No. private void ImmunizationNoTextBox_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Enter) { bool unique = false; if (ImmunizationNoTextBox.Text == "") { MessageBox.Show("PLS... FILL UP"); } else { con.Open(); OleDbCommand command = con.CreateCommand(); command.CommandText = "SELECT IMMHIMMUNO FROM IMMUNIZATIONHEADERFILE"; OleDbDataReader thisreader = command.ExecuteReader(); while (thisreader.Read()) { if (thisreader["IMMHIMMUNO"].ToString() == ImmunizationNoTextBox.Text) { MessageBox.Show("Immunization Number Already in the file"); ImmunizationNoTextBox.Clear(); unique = false; break; } else { unique = true; } } thisreader.Close(); con.Close(); if (unique) { SendKeys.Send("{TAB}"); } } } }