private void btnRegister_Click(object sender, EventArgs e) { DatabaseConnertor databaseConnertor = new DatabaseConnertor(); databaseConnertor.connect(); addPatient addPatient = new addPatient(); addPatient.P_firstName = firstNameTB.Text; addPatient.P_lastName = lastNameTB.Text; addPatient.P_age = int.Parse(ageLabel.Text); addPatient.P_dob = this.dobDTP.Value; addPatient.P_contact = int.Parse(contactTB.Text); addPatient.P_emergencyContact = int.Parse(emergencyContactTB.Text); addPatient.P_gender = genderCB.Text; addPatient.P_address = addressTB.Text; addPatient.P_floor = tbFloor.Text; addPatient.P_bedNum = int.Parse(tbBed.Text); addPatient.P_admission = this.dtpAdmission.Value; addPatientHandler addPatientHandler = new addPatientHandler(); int recordCnt = addPatientHandler.addNewPatient(databaseConnertor.getconn(), addPatient); MessageBox.Show(recordCnt + " record has been inserted !!"); }
public List <addPatient> getAllPatient(MySqlConnection conn) { List <addPatient> listLabr = new List <addPatient>(); string sql = "SELECT * FROM addpatient"; MySqlCommand sqlComm = new MySqlCommand(sql, conn); MySqlDataReader myReader; myReader = sqlComm.ExecuteReader(); while (myReader.Read()) { addPatient aLabr = new addPatient(); aLabr.P_id = (int)myReader.GetValue(0); aLabr.P_firstName = (string)myReader.GetValue(1); aLabr.P_lastName = (string)myReader.GetValue(2); aLabr.P_age = (int)myReader.GetValue(3); aLabr.P_dob = (DateTime)myReader.GetValue(4); aLabr.P_contact = (int)myReader.GetValue(5); aLabr.P_emergencyContact = (int)myReader.GetValue(6); aLabr.P_gender = (string)myReader.GetValue(7); aLabr.P_address = (string)myReader.GetValue(8); aLabr.P_bedNum = (int)myReader.GetValue(9); aLabr.P_floor = (string)myReader.GetValue(10); aLabr.P_admission = (DateTime)myReader.GetValue(11); listLabr.Add(aLabr); } return(listLabr); }
private void btnSave_Click(object sender, EventArgs e) { DatabaseConnertor databaseConnertor = new DatabaseConnertor(); databaseConnertor.connect(); addPatient addPatient = new addPatient(); addPatient.P_firstName = tbFN.Text; addPatient.P_lastName = tbLN.Text; addPatient.P_age = int.Parse(lbAge.Text); addPatient.P_dob = this.dtpDob.Value; addPatient.P_contact = int.Parse(tbContact.Text); addPatient.P_emergencyContact = int.Parse(tbEmergency.Text); addPatient.P_gender = cbGender.Text; addPatient.P_address = tbAddress.Text; addPatient.P_bedNum = int.Parse(tbBed.Text); addPatient.P_floor = tbFloor.Text; addPatient.P_admission = dtpAdmission.Value; addPatientHandler addPatientHandler = new addPatientHandler(); int recordCnt = addPatientHandler.addNewPatient(databaseConnertor.getconn(), addPatient); MessageBox.Show(recordCnt + " record has been inserted !!"); }
public int addNewPatient(MySqlConnection conn, addPatient addPatient) { string sql = "INSERT INTO addPatient (p_firstName, p_lastName, p_age, p_dob, p_contact, p_emergencyContact, p_gender, p_address, p_bedNum, p_floor, p_admission)" + " VALUES ('" + addPatient.P_firstName + "', '" + addPatient.P_lastName + " ', " + addPatient.P_age + ", '" + addPatient.P_dob.ToString("yyyy-MM-dd") + " ', " + addPatient.P_contact + " , " + addPatient.P_emergencyContact + " , '" + addPatient.P_gender + " ', '" + addPatient.P_address + " ', " + addPatient.P_bedNum + " , '" + addPatient.P_floor + "' , '" + addPatient.P_admission + "')"; MySqlCommand sqlComm = new MySqlCommand(sql, conn); return(sqlComm.ExecuteNonQuery()); }