protected void btnSearch_Click(object sender, EventArgs e)
    {
        clearMsgLabel();
        resetLabelControl();
        resetLabelControl();

        string ID = txtEmpID.Text;
        MatchCollection matchena = Regex.Matches(ID, @"\[.*?\]");
        string[] gettestID = matchena.Cast<Match>()
                                   .Select(m => m.Groups[0].Value.Trim(new char[] { '[', ']' }))
                                   .ToArray();
        try
        {
            EMPID = gettestID[0];
        }
        catch (Exception ex)
        {
            WAADEmployeePanel.Visible = false;
            msgPanel.Visible = true;
            ErroroDIV.Visible = true;
            lblErrorMsg.Text = "Invaild Input!";
            return;
        }

        //get Employee detail.
        Employee emply = new Employee();
        emply.EmpID = EMPID;
        EmployeeManager EmployeeManager = new EmployeeManager(emply);
        Employee employee = EmployeeManager.getEmployeeJobTitleAndBranchDetail();

        //The if there was a result        
        if (employee != null)
        {
            WAADEmployeePanel.Visible = true;
            UserID = employee.UserName;

            txtFName.Text = employee.FName + " " + employee.MName + " " + employee.LName;
            txtprevJob.Text = employee.PrevJob;
            txtJTittle.Text = employee.JobTitle;
            txtJGrade.Text = employee.JobGrade;
            txtSalary.Text = employee.Salary;
            txtDateEmp.Text = employee.Hdate;
            txtBranch.Text = employee.Branch;
            WAADEmployeePanel.Visible = true;

            btnReg.Visible = true;
            btnAddNewIntrenal.Visible = false;

            DropDownAllBranch.ClearSelection();
            DropDownBranch.ClearSelection();
            DropDownPost.ClearSelection();
            txtMinNo.Text = "";
            txtDateOfPromotion.Text = "";
        }
        //No employee is found with the EMPID
        else
        {
            WAADEmployeePanel.Visible = false;
            msgPanel.Visible = true;
            ErroroDIV.Visible = true;
            lblErrorMsg.Text = "Invaild Input!";
        }
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        clearLabel();
        btnReg.Enabled = true;
        txtDateOfBirth.Text = "";

        string ID = txtEmpID.Text;
        MatchCollection matchena = Regex.Matches(ID, @"\[.*?\]");
        string[] gettestID = matchena.Cast<Match>()
                                   .Select(m => m.Groups[0].Value.Trim(new char[] { '[', ']' }))
                                   .ToArray();
        try
        {
            EmpID = gettestID[0];
        }
        catch (Exception ex)
        {
            UserDetialPanel.Visible = false;
            //and dont continue. 
            return;
        }

        //get Employee detail.
        Employee emply = new Employee();
        emply.EmpID = EmpID;
        EmployeeManager EmployeeManager = new EmployeeManager(emply);
        Employee employee = EmployeeManager.getEmployeeJobTitleAndBranchDetail();

        if (employee != null)
        {
            txtFName.Text = employee.FName + " " + employee.MName + " " + employee.LName;
            txtprevJob.Text = employee.PrevJob;
            txtJTittle.Text = employee.JobTitle;
            txtJGrade.Text = employee.JobGrade;
            txtSalary.Text = employee.Salary;
            txtDateEmp.Text = employee.Hdate;
            txtDateOfBirth.Text = employee.DateOfBirth;

            if (txtDateOfBirth.Text.Trim() != "" && txtDateOfBirth.Text.Trim() != null)
            {
                txtDateOfBirth.Text = Convert.ToDateTime(employee.DateOfBirth).ToShortDateString();
            }
            else
            {
                txtDateOfBirth.Text = "Not set";
            }
            txtBranch.Text = employee.Branch;
            txtDistrict.Text = employee.District;
            UserDetialPanel.Visible = true;

            getAttendedTraining(EmpID);
            getEmployeeFileStatus(EmpID);
        }
        else
        {
            UserDetialPanel.Visible = false;
        }
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string ID = txtEmpID.Text;
        MatchCollection matchena = Regex.Matches(ID, @"\[.*?\]");
        string[] gettestID = matchena.Cast<Match>()
                                   .Select(m => m.Groups[0].Value.Trim(new char[] { '[', ']' }))
                                   .ToArray();
        try
        {
            EmpID = gettestID[0];
        }
        catch (Exception ex)
        {
            WAADEmployeePanel.Visible = false;
            lblmsg.Visible = true;
            //and dont continue. 
            return;
        }

        ClearControl();
        clearMsgPanel();

        //get Employee detail.
        Employee emply = new Employee();
        emply.EmpID = EmpID;
        EmployeeManager EmployeeManager = new EmployeeManager(emply);
        Employee employee = EmployeeManager.getEmployeeJobTitleAndBranchDetail();

        if (employee != null)
        {
            btnCancelIntrenal.Visible = false;
            btnRegInternal.Visible = true;

            txtWAADEmpID.Text = employee.EmpID;
            txtFName.Text = employee.FName;
            txtMName.Text = employee.MName;
            txtLName.Text = employee.LName;
            txtprevJob.Text = employee.PrevJob;
            txtJTittle.Text = employee.JobTitle;
            txtBranch.Text = employee.Branch;
            WAADEmployeePanel.Visible = true;
            lblmsg.Visible = false;
            msgPanel.Visible = false;
            btnRegInternal.Enabled = true;
        }
        else
        {
            WAADEmployeePanel.Visible = false;
            lblmsg.Visible = true;
        }


        //check whether the selected employee Education information in DB or not.
        //If Employee Educational information is in DB then disable Education level & Qualification controls
        //else premit the HR Clerk to enter the information

        isEduQualExist = false;
        //int counter = 0;
        //DataView dvSql = (DataView)EducLevelQualifSQL.Select(DataSourceSelectArguments.Empty);        

        DataTable dataTable = null;
        TransactionResponse response = null;

        response = VacancyRegistrationAndEvaluationManager.ApplicantEducationalQualifacation(EmpID);
        dataTable = (DataTable)response.Data;
        if (response.isSuccessful())
        {
            if (dataTable != null && dataTable.Rows.Count > 0)
            {
                isEduQualExist = true;

                DropDownEduLevel.Visible = false;
                txtQualif.Visible = false;
                DropDownListDBQual.Visible = true;

                DropDownListDBQual.Visible = true;
                DropDownListEduLevDB.Visible = true;

                trackEduLevel = false;
                trackQualification = false;

                DropDownListEduLevDB.DataSource = dataTable;
                DropDownListEduLevDB.DataValueField = "EducationLevel";
                DropDownListEduLevDB.DataTextField = "EducationLevel";
                DropDownListEduLevDB.DataBind();

                DropDownListDBQual.DataSource = dataTable;
                DropDownListDBQual.DataValueField = "Qualification";
                DropDownListDBQual.DataTextField = "Qualification";
                DropDownListDBQual.DataBind();

            }
            else
            {
                isEduQualExist = false;

                DropDownEduLevel.Visible = true;
                txtQualif.Visible = true;

                DropDownListDBQual.Visible = false;
                DropDownListEduLevDB.Visible = false;

                trackEduLevel = true;
                trackQualification = true;
            }
        }

    }