//Reaction private void ReactionTextBox_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Enter) { if (ReactionTextBox.Text == "") { MessageBox.Show("PLS... FILL UP"); } else { if (totalshot <= numshot && vaccineCode != "" && ShotNumberTextBox.Text != "") { VaccinedataGridView.Rows.Add(vaccineCode, vaccineName, vaccinedesc, ShotNumberTextBox.Text, ReactionTextBox.Text); VaccineCodeTextBox.Clear(); ShotNumberTextBox.Clear(); ReactionTextBox.Clear(); vaccineCode = ""; vaccineName = ""; vaccinedesc = ""; SendKeys.Send("{TAB}"); } else { MessageBox.Show("Pls. Complete All Details!!"); } } } }
//Shot Number private void ShotNumberTextBox_KeyPress(object sender, KeyPressEventArgs e) { totalshot = 0; vacpatshotnum = 0; bool firstTime = true; if (e.KeyChar == (char)Keys.Enter) { if (ShotNumberTextBox.Text == "") { MessageBox.Show("PLS... FILL UP"); } else { try { con.Open(); OleDbCommand command = con.CreateCommand(); command.CommandText = "SELECT * FROM VACCINEPATIENTFILE"; OleDbDataReader thisreader = command.ExecuteReader(); while (thisreader.Read()) { if (thisreader["VACVCODE"].ToString() == vaccineCode && thisreader["VACPCODE"].ToString() == PatientCodeTextBox.Text) { vacpatshotnum = Convert.ToInt32(thisreader["VACPATSHOTNUM"]); firstTime = false; break; } } thisreader.Close(); con.Close(); totalshot = vacpatshotnum + Convert.ToInt32(ShotNumberTextBox.Text); if (totalshot > numshot) { MessageBox.Show("Shot Number Already reaches its limit"); ShotNumberTextBox.Clear(); } else if (firstTime) { MessageBox.Show("He/She is first Time in this vaccine"); InsertVaPatFile(); SendKeys.Send("{TAB}"); } else { SendKeys.Send("{TAB}"); } } catch { MessageBox.Show("Invalid Input"); } } } }