private void frmConsultationHistory_FormClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         frmConsultationDetails frm = new frmConsultationDetails(1, 2);
         frm.MdiParent   = this.Owner;
         frm.WindowState = FormWindowState.Maximized;
         frm.Show();
     }
     catch (Exception ex)
     {
         CommonLogger.Info("frmConsultationDetails\r\n" + ex.ToString());
     }
 }
 private void ViewDetails(int app_id, int pat_id)
 {
     try
     {
         if (Application.OpenForms.OfType <frmConsultationDetails>().Count() == 1)
         {
             Application.OpenForms.OfType <frmConsultationDetails>().First().Close();
         }
         frmConsultationDetails frm = new frmConsultationDetails(app_id, pat_id);
         frm.MdiParent = this.ParentForm;
         frm.Show();
     }
     catch (Exception ex)
     {
         CommonLogger.Info(ex.ToString());
     }
 }
        private void dgvApptHistory_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                switch (dgvApptHistory.Columns[e.ColumnIndex].Name)
                {
                case "btnHistSelect":
                    ShowProceduresHistory(e.RowIndex);
                    ShowInvestigationsHistory(e.RowIndex);
                    break;

                case "btnDetails":
                    int aptid = Convert.ToInt32(dgvApptHistory.Rows[Convert.ToInt32(e.RowIndex)].Cells["colHistID"].Value);
                    int patid = Convert.ToInt32(txtPatientID.Text.Trim());
                    frmConsultationDetails frm = new frmConsultationDetails(aptid, patid);
                    if (Application.OpenForms.OfType <frmConsultationDetails>().Count() == 1)
                    {
                        Application.OpenForms.OfType <frmConsultationDetails>().First().BringToFront();
                    }
                    else
                    {
                        frm.MdiParent   = this.Owner;
                        frm.WindowState = FormWindowState.Normal;     // Change to maximized when issue fixed
                        frm.Show();
                        frm.BringToFront();
                    }
                    this.Close();

                    break;
                }
            }
            catch (Exception ex)
            {
                CommonLogger.Info(ex.ToString());
            }
        }