protected void GridSearchName_SelectedIndexChanged(object sender, EventArgs e)
    {
        patientId = Int32.Parse(GridSearchName.Rows[GridSearchName.SelectedIndex].Cells[1].Text);
        Session["ptId"] = patientId;
        mr = new MedicalRecord();

        patientData = mr.GetValuesConsultation(patientId.ToString());
        Session["PatientData"] = patientData;

        if (patientData.Rows.Count > 0)
        {
            foreach (DataRow dr in patientData.Rows)
            {
                txtlname.Text = dr["PatientLName"].ToString().Trim();
                txtfname.Text = dr["PatientFName"].ToString().Trim();
                txtmname.Text = dr["PatientMName"].ToString().Trim();
                txtPhilhealthNum.Text = dr["PatientFaxNumber"].ToString().Trim();
                
                txtDatepick.Text = dr["PatientBirthdate"].ToString().Trim();
                txtAddress.Text = dr["PatientAddress"].ToString().Trim();
                ddlBarangay.Text = dr["PatientBarangay"].ToString().Trim();
                txtAddress.ReadOnly = true;
                txtlname.ReadOnly = true;
                txtfname.ReadOnly = true;
                txtmname.ReadOnly = true;
                txtPhilhealthNum.ReadOnly = true;



                DateTime bdate = DateTime.Parse(dr["PatientBirthdate"].ToString().Trim());
                calcAge a = new calcAge();
                txtAge.Text = a.GetAge(bdate);
            //    txtAge.Text = (Int32.Parse(DateTime.Now.ToString("yyyy")) - Int32.Parse(ddlYear.Text)).ToString();
                txtAge.ReadOnly = true;
            }
        }

    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        mr = new MedicalRecord();

        patientData = mr.GetValuesConsultation(patientId.ToString());
        Session["PatientData"] = patientData;

        if (patientData.Rows.Count > 0)
        {
            foreach (DataRow dr in patientData.Rows)
            {
                
                txtlname.Text = dr["PatientLName"].ToString().Trim();
                txtfname.Text = dr["PatientFName"].ToString().Trim();
                txtmname.Text = dr["PatientMName"].ToString().Trim();
                txtPhilhealthNum.Text = dr["PatientFaxNumber"].ToString().Trim();

                txtDatepick.Text = dr["PatientBirthdate"].ToString().Trim();
                
                txtAddress.Text = dr["PatientAddress"].ToString().Trim();
                ddlBarangay.Text = dr["PatientBarangay"].ToString().Trim();
                txtAddress.ReadOnly = true;
                txtlname.ReadOnly = true;
                txtfname.ReadOnly = true;
                txtmname.ReadOnly = true;
                txtPhilhealthNum.ReadOnly = true;
                
                ddlBarangay.Enabled = false;


                DateTime bdate = DateTime.Parse(dr["PatientBirthdate"].ToString().Trim());
                calcAge a = new calcAge();
                txtAge.Text = a.GetAge(bdate);
                txtAge.ReadOnly = true;
                
            }
        }
    }
    protected void ButtonProceed_Click(object sender, EventArgs e)
    {
        string Patient_id = patientId.ToString();

        mr = new MedicalRecord();

        patientData = mr.GetValuesConsultation(Patient_id);
        Session["PatientData"] = patientData;

        if (patientData.Rows.Count > 0)
        {
            foreach (DataRow dr in patientData.Rows)
            {
                //txtlname.Text = dr["PatientLName"].ToString().Trim();
                txtlname.Text = dr["PatientLName"].ToString().Trim();
                txtfname.Text = dr["PatientFName"].ToString().Trim();
                txtmname.Text = dr["PatientMName"].ToString().Trim();
                txtPhilhealthNum.Text = dr["PatientFaxNumber"].ToString().Trim();


                txtDatepick.Text = dr["PatientBirthdate"].ToString().Trim();
                txtAddress.Text = dr["PatientAddress"].ToString().Trim();
                ddlBarangay.Text = dr["PatientBarangay"].ToString().Trim();
                txtAddress.ReadOnly = true;
                txtlname.ReadOnly = true;
                txtfname.ReadOnly = true;
                txtmname.ReadOnly = true;
                txtPhilhealthNum.ReadOnly = true;




                DateTime bdate = DateTime.Parse(dr["PatientBirthdate"].ToString().Trim());
                calcAge a = new calcAge();
                txtAge.Text = a.GetAge(bdate);
              //  txtAge.Text = (Int32.Parse(DateTime.Now.ToString("yyyy")) - Int32.Parse(ddlYear.Text)).ToString();
                txtAge.ReadOnly = true;
            }
        }
       
    }