protected void GridViewTherapists2_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     GridViewTherapists2.PageIndex  = e.NewPageIndex;
     GridViewTherapists2.DataSource = ViewState["GridViewTherapists2"];
     GridViewTherapists2.DataBind();
     UpdatePanelPatient.Update();
 }
        protected void GridViewTherapists_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("AddEmergencyTherapist"))
            {
                string patientNRIC = ViewState["GridViewAccountsSelectedNRIC"].ToString();

                try
                {
                    string therapistNRIC = e.CommandArgument.ToString();

                    accountBLL.AddEmergencyTherapist(patientNRIC, therapistNRIC);
                    string therapistTerm = TextboxSearchTherapist.Text.Trim().ToLower();
                    Bind_GridViewTherapists(patientNRIC, therapistTerm);
                    Bind_GridViewTherapists2(patientNRIC);
                    UpdatePanelPatient.Update();
                    ScriptManager.RegisterStartupScript(this, GetType(), "alert", "toastr['success']('Emergency Therapist, " + therapistNRIC + ", has been assigned to " + patientNRIC + ".');", true);
                }
                catch
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "alert", "toastr['error']('Error occured when assigning emergency Therapist to " + patientNRIC + ".');", true);
                }
            }
        }
        //protected void GridViewAccounts_RowDeleting(object sender, GridViewDeleteEventArgs e)
        //{
        //    string nric = GridViewAccounts.DataKeys[e.RowIndex].Values["nric"].ToString();

        //    try
        //    {
        //        accountBLL.DeleteAccount(nric);
        //        ScriptManager.RegisterStartupScript(this, GetType(), "alert", "toastr['success']('Account, \"" + nric + "\", was Deleted successfully');", true);
        //    }
        //    catch
        //    {
        //        ScriptManager.RegisterStartupScript(this, GetType(), "alert", "toastr['error']('Error occured when Deleting an Account');", true);
        //    }

        //    GridViewAccounts.EditIndex = -1;

        //    string term = TextboxSearch.Text.Trim().ToLower();

        //    Bind_GridViewAccounts(term);
        //}
        protected void GridViewAccounts_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string nric = e.CommandArgument.ToString();

            if (e.CommandName.Equals("ViewPersonal"))
            {
                try
                {
                    Classes.Entity.Account account = accountBLL.GetPersonalInformation(nric);
                    labelPersonalNRIC.Text            = nric;
                    inputPersonalNRIC.Value           = account.nric;
                    inputPersonalDoB.Value            = account.dateOfBirth.ToString("dd/MM/yyyy");
                    inputPersonalFirstName.Value      = account.firstName;
                    inputPersonalLastName.Value       = account.lastName;
                    inputPersonalCountryofBirth.Value = account.countryOfBirth;
                    inputPersonalNationality.Value    = account.nationality;
                    inputPersonalSex.Value            = account.sex;
                    inputPersonalGender.Value         = account.gender;
                    inputPersonalMaritalStatus.Value  = account.maritalStatus;

                    UpdatePanelPersonal.Update();
                    ScriptManager.RegisterStartupScript(this, GetType(), "Open Personal Modal", "$('#modalPersonal').modal('show');", true);
                }
                catch
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "alert", "toastr['error']('Error viewing Personal Information of " + nric + ".');", true);
                }
            }
            if (e.CommandName.Equals("ViewContact"))
            {
                try
                {
                    Classes.Entity.Account account = accountBLL.GetContactInformation(nric);
                    labelContactNRIC.Text    = nric;
                    inputAddress.Value       = account.address;
                    inputPostalCode.Value    = account.addressPostalCode;
                    inputEmailAddress.Value  = account.email;
                    inputContactNumber.Value = account.contactNumber;

                    UpdatePanelContact.Update();
                    ScriptManager.RegisterStartupScript(this, GetType(), "Open Contact Modal", "$('#modalContact').modal('show');", true);
                }
                catch
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "alert", "toastr['error']('Error viewing Contact Information of " + nric + ".');", true);
                }
            }
            if (e.CommandName.Equals("ViewPatient"))
            {
                try
                {
                    Classes.Entity.Account account = accountBLL.GetPatientInformation(nric);
                    // Just info
                    labelPatientNRIC.Text        = nric;
                    inputPatientNokName.Value    = account.nokName;
                    inputPatientNokContact.Value = account.nokContact;

                    //Emergency
                    ViewState["GridViewAccountsSelectedNRIC"] = nric;
                    string therapistTerm = TextboxSearchTherapist.Text.Trim().ToLower();
                    Bind_GridViewTherapists(nric, therapistTerm);
                    Bind_GridViewTherapists2(nric);

                    UpdatePanelPatient.Update();
                    ScriptManager.RegisterStartupScript(this, GetType(), "Open Patient Modal", "$('#modalPatient').modal('show');", true);
                }
                catch
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "alert", "toastr['error']('Error viewing Patient Information of " + nric + ".');", true);
                }
            }
            if (e.CommandName.Equals("ViewTherapist"))
            {
                try
                {
                    ViewState["GridViewAccountsSelectedNRIC"] = nric;
                    inputTherapistJobTitle.Attributes.Add("class", "form-control form-control-sm");
                    inputTherapistDepartment.Attributes.Add("class", "form-control form-control-sm");
                    spanMessageTherapistDetailsUpdate.Visible = false;
                    RefreshTherapistModal(nric);
                    ScriptManager.RegisterStartupScript(this, GetType(), "Open Therapist Modal", "$('#modalTherapist').modal('show');", true);
                }
                catch
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "alert", "toastr['error']('Error viewing Therapist Information of " + nric + ".');", true);
                }
            }
            if (e.CommandName.Equals("ViewResearcher"))
            {
                try
                {
                    ViewState["GridViewAccountsSelectedNRIC"] = nric;
                    inputResearcherJobTitle.Attributes.Add("class", "form-control form-control-sm");
                    inputResearcherDepartment.Attributes.Add("class", "form-control form-control-sm");
                    spanMessageResearcherUpdate.Visible = false;
                    RefreshResearcherModal(nric);
                    ScriptManager.RegisterStartupScript(this, GetType(), "Open Researcher Modal", "$('#modalResearcher').modal('show');", true);
                }
                catch
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "alert", "toastr['error']('Error viewing Researcher Information of " + nric + ".');", true);
                }
            }
            if (e.CommandName.Equals("ViewStatus"))
            {
                try
                {
                    ViewState["GridViewAccountsSelectedNRIC"] = nric;

                    RefreshStatusModal(nric);
                    ScriptManager.RegisterStartupScript(this, GetType(), "Open Status Modal", "$('#modalStatus').modal('show');", true);
                }
                catch
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "alert", "toastr['error']('Error viewing Status Information of " + nric + ".');", true);
                }
            }

            string term = TextboxSearch.Text.Trim().ToLower();

            Bind_GridViewAccounts(term);
        }