protected void btnCreateUserAcc_Click(object sender, EventArgs e)
    {
        hideDIV();

        //Employee Data
        Employee employee = new Employee();

        //validate fields , set value and check if all madatory values are set.
        Boolean allMandatoryFieldsSet = validateAndSetEmployeeData(employee);

        //First is first, check if Employee ID is duplicate or not. 
        EmployeeManager employeeManager = new EmployeeManager(employee);
        Boolean isEmployeeDuplicate = employeeManager.isEmployeeAlreadyExist();
        displayEmployeeDuplicateMessage(isEmployeeDuplicate, employee.EmpID);


        //Check if all mandatory fields are set and Employee is not duplicate.
        if (allMandatoryFieldsSet && !isEmployeeDuplicate)
        {
            //I think here we have to check wether Employee ID is in database or not
            // else user is created here and when we need to correct Employee ID and click create user it displays username already exist.
            MembershipCreateStatus createStatus;
            MembershipUser newUser = Membership.CreateUser(employee.UserName, "cbe@123", employee.UserName + "@cbe.com.et", "what", "what", true, out createStatus);

            switch (createStatus)
            {
                case MembershipCreateStatus.Success:
                    //set userID for the employee.
                    employee.UserID = (Guid)newUser.ProviderUserKey;

                    //manage Employee transaction using EMployee manager.
                    TransactionResponse response = employeeManager.storeEmployee();

                    //Transaction is successful 
                    if (response.isSuccessful())
                    {
                        //show sucessfull message.
                        msgPanel.Visible = true;
                        SucessDIV.Visible = true;

                        lblSuccessMessage.Text = "The user account is successfully created! " + "Employee ID: "
                            + employee.EmpID + " user name: " + employee.UserName;

                        btnCreateUserAcc.Visible = false;
                        btnAddNew.Visible = true;
                        //resetComponents();
                    }
                    else
                    {
                        //display this message to the user.
                        hideDIV();
                        msgPanel.Visible = true;
                        ErroroDIV.Visible = true;
                        lblErrorMsg.Text = response.getMessage() + "(" + response.getErrorCode() + ") ";
                    }
                    break;
                case MembershipCreateStatus.DuplicateUserName:

                    hideDIV();
                    msgPanel.Visible = true;
                    WarnDIV.Visible = true;
                    lblWarningMsg.Text = "There already exists a user with this username.";
                    break;
                case MembershipCreateStatus.DuplicateEmail:

                    hideDIV();
                    msgPanel.Visible = true;
                    WarnDIV.Visible = true;
                    lblWarningMsg.Text = "There already exists a user with this email address.";
                    break;
                case MembershipCreateStatus.InvalidEmail:
                    hideDIV();
                    msgPanel.Visible = true;
                    WarnDIV.Visible = true;
                    lblWarningMsg.Text = "There email address you provided in invalid.";
                    break;
                case MembershipCreateStatus.InvalidAnswer:
                    hideDIV();
                    msgPanel.Visible = true;
                    WarnDIV.Visible = true;
                    lblWarningMsg.Text = "There security answer was invalid.";
                    break;
                case MembershipCreateStatus.InvalidPassword:
                    hideDIV();
                    msgPanel.Visible = true;
                    WarnDIV.Visible = true;
                    lblWarningMsg.Text = "The password you provided is invalid. It must be seven characters long and have at least one non-alphanumeric character.";
                    break;
                default:
                    hideDIV();
                    msgPanel.Visible = true;
                    WarnDIV.Visible = true;
                    lblWarningMsg.Text = "There was an unknown error; the user account was NOT created.";
                    break;
            }
        }
    }
    protected void btnRegExtrenal_Click(object sender, EventArgs e)
    {
        clearlabels();

        bool isAllValidate = true;
        string FirstName = null;
        string MiddleName = null;
        string currentBranch = null;
        string Jobtitle = null;
        string JGrade = null;
        string vacancyInfo = null;
        string EduLevel = null;
        string qualification = null;

        if (txtOtherEmpID.Text != "")
        {
            Employee employee = new Employee();
            employee.EmpID = txtOtherEmpID.Text;

            EmployeeManager employeeManager = new EmployeeManager(employee);
            isAllValidate = !(employeeManager.isEmployeeAlreadyExist());

            //TODO, display about the duplicate warning  message getting from TransactionResponse
            //This method should not return boolean but TransactionResponse containing a boolean about the duplicate !!! 
            if (!isAllValidate)
            {
                msgPanel.Visible = true;
                String districtName = (String)PageAccessManager.getDistrictSettingValue(PageConstants.DISTRCT_NAME).Data;

                ErroroDIV.Visible = true;
                lblErrorMsg.Text = DBOperationErrorConstants.M_EMPLOYEE_ALREAD_IEXISTS + " in " +  districtName;
                isAllValidate = false;
                //No need to continue, we canstop the flow here. 
                return;
            }
        }
        else
        {
            isAllValidate = false;
            lblOtherEmp.Visible = true;
        }

        if (txtOtherFName.Text != "")
        {
            FirstName = txtOtherFName.Text;
        }
        else
        {
            isAllValidate = false;
            lblOtherFName.Visible = true;
        }

        if (txtOtherMName.Text != "")
        {
            MiddleName = txtOtherMName.Text;
        }
        else
        {
            isAllValidate = false;
            lblOtherMName.Visible = true;
        }

        if (DropDownOtherbranch.SelectedValue != "-1")
        {
            currentBranch = DropDownOtherbranch.SelectedValue;
        }
        else
        {
            isAllValidate = false;
            lblOtherBranch.Visible = true;
        }

        if (txtOtherJobtitle.Text != "")
        {
            Jobtitle = txtOtherJobtitle.Text;
        }
        else
        {
            isAllValidate = false;
            lblOtherJTitle.Visible = true;
        }

        if (DropDownOtherJGrade.SelectedValue != "-1")
        {
            JGrade = DropDownOtherJGrade.SelectedValue;
        }
        else
        {
            isAllValidate = false;
            lblOtherJGrade.Visible = true;
        }

        if (DropDownOtherVacancyNo.SelectedValue != "-1")
        {
            vacancyInfo = DropDownOtherVacancyNo.SelectedValue;
        }
        else
        {
            isAllValidate = false;
            lblOtherVacNo.Visible = true;
        }

        if (DropDownOthereduLevel.SelectedValue != "-1")
        {
            EduLevel = DropDownOthereduLevel.SelectedValue;
        }
        else
        {
            isAllValidate = false;
            lblOtherELevel.Visible = true;
        }

        if (txtOtherQual.Text != "")
        {
            qualification = txtOtherQual.Text;
        }
        else
        {
            isAllValidate = false;
            lblOtherQualification.Visible = true;
        }

        if (!isAllValidate)
        {
            return;
        }

        string[] splitter = new string[] { ">>" };

        string[] VacancyInfoTosplit = vacancyInfo.Split(splitter, StringSplitOptions.RemoveEmptyEntries);
        string vacancyNo = VacancyInfoTosplit[0];
        string VacancyDate = VacancyInfoTosplit[1];

        VacancyApplicant vacancyAppilcant = new VacancyApplicant();

        vacancyAppilcant.EmpId = txtOtherEmpID.Text;
        vacancyAppilcant.FirstName = FirstName;
        vacancyAppilcant.MiddleName = MiddleName;
        vacancyAppilcant.LastName = txtOtherLName.Text;

        vacancyAppilcant.CurrentBranch = currentBranch;
        vacancyAppilcant.JobTitle = txtOtherJobtitle.Text;
        vacancyAppilcant.CurrentJGrade = JGrade;
        vacancyAppilcant.VacancyNo = vacancyNo;
        vacancyAppilcant.VacancyDate = VacancyDate;
        vacancyAppilcant.EducLevel = EduLevel;
        vacancyAppilcant.Qualification = qualification;

        VacancyRegistrationAndEvaluationManager vacancyRegEvaluationManager = new VacancyRegistrationAndEvaluationManager(vacancyAppilcant);
        TransactionResponse response = vacancyRegEvaluationManager.registerApplicants(false, false); 

        if (response.isSuccessful())
        {
            msgPanel.Visible = true;
            SucessDIV.Visible = true;
            lblSuccessMessage.Text = response.getMessage();
            btnRegExtrenal.Visible = false;
            btnCancelExtrenal.Visible = true;
        }
        else
        {
            msgPanel.Visible = true;
            ErroroDIV.Visible = true;
            lblErrorMsg.Text = response.getErrorCode() + response.getMessage();
            btnRegExtrenal.Visible = false;
            btnCancelExtrenal.Visible = true;
        }
    }