public static PatientInformation getPatient(int pid) { PatientInformation pi = new PatientInformation(); MySqlCommand command; MySqlDataReader dataReader; string query = "select * from patientinfo where pid=@pid"; connection.Open(); command = new MySqlCommand(query, connection); command.Parameters.AddWithValue("@pid", pid); dataReader = command.ExecuteReader(); while (dataReader.Read()) { pi.pid = pid; pi.date = (string)dataReader["date"]; pi.name = (string)dataReader["name"]; pi.gender = (string)dataReader["gender"]; pi.age = (int)dataReader["age"]; pi.address = (string)dataReader["address"]; pi.disease = (string)dataReader["disease"]; } dataReader.Close(); command.Dispose(); connection.Close(); return(pi); }
public static void addPatient(PatientInformation patient) { // insert patient to database patient info table. string query = "insert into patientinfo(pid,date,name,gender,age,address,disease) values(@PID,@Date,@Name,@Gender,@Age,@Address,@Disease)"; modifyPatient(patient, query); }
private void btnupdate(object sender, EventArgs e) { PatientInformation patient = patientInfoFromForm(); DatabaseHelper.updatePatient(patient); MessageBox.Show("Patient updated successfully"); }
private void btnsubmit_Click(object sender, EventArgs e) { PatientInformation patient = patientInfoFromForm(); DatabaseHelper.addPatient(patient); MessageBox.Show("Patient Resistered successfully"); }
private void btnfetch_Click(object sender, EventArgs e) { PatientInformation pi = DatabaseHelper.getPatient(Convert.ToInt32(textPID.Text)); roomInformation r = DatabaseHelper.getRoom(Convert.ToInt32(textPID.Text)); b.pid = pi.pid; b.name = pi.name; b.Roomno = r.Roomno; b.RoomRent = r.Price; textptname.Text = b.name; txtroomno.Text = Convert.ToString(b.Roomno); txtroomrent.Text = Convert.ToString(b.RoomRent); }
private static void modifyPatient(PatientInformation patient, string query) { connection.Open(); MySqlCommand command = new MySqlCommand(query, connection); command.Parameters.AddWithValue("@PID", patient.pid); command.Parameters.AddWithValue("@Date", patient.date); command.Parameters.AddWithValue("@Name", patient.name); command.Parameters.AddWithValue("@Gender", patient.gender); command.Parameters.AddWithValue("@Age", patient.age); command.Parameters.AddWithValue("@Address", patient.address); command.Parameters.AddWithValue("@Disease", patient.disease); command.ExecuteNonQuery(); command.Dispose(); connection.Close(); }
private PatientInformation patientInfoFromForm() { PatientInformation patient = new PatientInformation(); patient.pid = Convert.ToInt32(txtpid.Text); patient.date = textBox2.Text; patient.name = txtname.Text; if (rbnmale.Checked) { patient.gender = rbnmale.Text; } else { patient.gender = rbnfemale.Text; } patient.age = Convert.ToInt32(txtage.Text); patient.address = rtaddress.Text; patient.disease = txtdisease.Text; return(patient); }
private void btnfetch(object sender, EventArgs e) { PatientInformation pi = DatabaseHelper.getPatient(Convert.ToInt32(txtpid.Text)); textBox2.Text = pi.date; txtname.Text = pi.name; switch (pi.gender) { case "Male": rbnmale.Checked = true; break; case "Female": rbnfemale.Checked = true; break; } txtage.Text = Convert.ToString(pi.age); rtaddress.Text = pi.address; txtdisease.Text = pi.disease; }
public static void updatePatient(PatientInformation patient) { string query = "update patientinfo set date=@Date,name=@Name,gender=@Gender,age=@Age,address=@Address,disease=@Disease where pid=@PID"; modifyPatient(patient, query); }