public LabResponseModel GetLabRecordFromLabId(int xLabId) { LabResponseModel model = new LabResponseModel(); using (connection = new MySqlConnection(conString)) { string xQry = "select * from billing_lab where lab_id = " + xLabId + ""; connection.Open(); MySqlCommand comm = new MySqlCommand(xQry, connection); MySqlDataReader reader = comm.ExecuteReader(); while (reader.Read()) { model = new LabResponseModel() { PatientId = Convert.ToInt32(reader.GetInt32("patient_id")), DoctorId = Convert.ToInt32(reader.GetInt32("doctor_id")), BillDate = reader.GetDateTime("created_on") }; } connection.Close(); } return(model); }
private void btnEdit_Click(object sender, EventArgs e) { if (txtLabId.Text == "") { MessageBox.Show("Please Enter Lab Id"); txtLabId.Focus(); return; } LabResponseModel labResponse = xDb.GetLabRecordFromLabId(Convert.ToInt32(txtLabId.Text)); PatientResponseModel patientResponse = xDb.GetPatientFromPatientId(labResponse.PatientId); DoctorResponseModel doctorResponse = xDb.GetDoctorFromDoctorId(labResponse.DoctorId); txtBillDate.Text = labResponse.BillDate.ToString(); txtPatientId.Text = patientResponse.PatientId.ToString(); txtPatientName.Text = patientResponse.PatientName.ToString(); txtUhid.Text = patientResponse.UHID.ToString(); txtDoctorName.Text = doctorResponse.DoctorName; string xQry = "select bld.lab_id,bld.test_id,ltf.test_name as TestName, " + " ltf.test_description as TestDescription, " + " bld.patient_test_details as PatientTestDetails " + " from billing_lab_details bld, " + " m_lab_test_fees ltf, billing_lab bl" + " where bld.test_id = ltf.lab_test_fees_id " + " and bl.lab_id = bld.lab_id and bld.lab_id= " + txtLabId.Text; xDb.LoadGrid(xQry, dataGridView1); dataGridView1.Columns[0].Visible = false; dataGridView1.Columns[1].Visible = false; dataGridView1.Columns[2].Width = 200; txtLabId.Enabled = false; btnUpdate.Enabled = true; btnView.Enabled = true; }