CauseValidation error when click another Tab

2 posts, 0 answers
  1. Joe
    Joe avatar
    57 posts
    Member since:
    Mar 2013

    Posted 22 Jul 2013 Link to this post

    there are 5 tab in my application, i provide a "Back" and "Next" button to previous/next tab.

    i had used requiredfield validator for compulsory field, but i found that there is error that i cannot browse next tab even though i input all required field. the tab had been locked.

    I need to set causevalidation to "false" so that user can click next bitton and next tab.

    <%@ Page Title="" Language="VB" MasterPageFile="~/LRDB.master" AutoEventWireup="false" CodeFile="HR_employee_details.aspx.vb" Inherits="HR_HR_employee_details" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
            <style type="text/css">
           .table_photo
            {
                width: 100px;
                height: auto;
            }
            .table_header
            {
                width: 150px;
                height: 15px;
                background-color:#E7EEF6;
            }
          .table_content
          {
            /*  width: 527px;*/
              height: 15px;
          }
     
                 
                .style6
                {
                    width: 150px;
                    height: 15px;
                    background-color: #E7EEF6;
                    font-weight: bold;
                }
     
                 
           </style>
           <script type="text/javascript">
     
               function UpdateValidationGroup(sender, args) {
                   args.set_cancel(!Page_IsValid);
               
     
         
               function display_name() {
                   if (document.getElementById('<%=tb_middle_name.ClientID%>').value != "") {
                       document.getElementById('<%=tb_display_name.ClientID%>').value = document.getElementById('<%=tb_last_name.ClientID%>').value + ", " + document.getElementById('<%=tb_middle_name.ClientID%>').value + " " + document.getElementById('<%=tb_first_name.ClientID%>').value;
                       document.getElementById('<%=tb_username.ClientID%>').value = document.getElementById('<%=tb_first_name.ClientID%>').value.toLowerCase() + document.getElementById('<%=tb_last_name.ClientID%>').value.toLowerCase();
                   }
                   else {
                       document.getElementById('<%=tb_display_name.ClientID%>').value = document.getElementById('<%=tb_last_name.ClientID%>').value + ", " + document.getElementById('<%=tb_first_name.ClientID%>').value;
                       document.getElementById('<%=tb_username.ClientID%>').value = document.getElementById('<%=tb_first_name.ClientID%>').value.replace(/[^A-Za-z0-9]/g, "").toLowerCase() + document.getElementById('<%=tb_last_name.ClientID%>').value.replace(/[^A-Za-z0-9]/g, "").toLowerCase();
                   }
               }
     
               //    function ValidateChkList(source, arguments) {
               //        arguments.IsValid = IsCheckBoxChecked() ? true : false;
               //    }
               //   
               //    function IsCheckBoxChecked() {
               //        var isChecked = false;
               //        var list = document.getElementById('<%=CheckBoxList_RoleType.ClientID%>');
               //        if (list != null) {
               //            for (var i = 0; i < list.rows.length; i++) {
               //                for (var j = 0; j < list.rows[i].cells.length; j++) {
               //                    var listControl = list.rows[i].cells[j].childNodes[0];
               //                    if (listControl.checked) {
               //                        isChecked = true;
               //                    }
               //                }
     
               //            }
               //        }
               //        return isChecked;
               //    }
     
               function verifyCheckboxList(source, arguments) {
                   var val = document.getElementById("<%=CheckBoxList_RoleType.ClientID%>");
                   var col = val.getElementsByTagName("*");
                   if (col != null) {
                       for (i = 0; i < col.length; i++) {
                           if (col.item(i).tagName == "INPUT") {
                               if (col.item(i).checked) {
                                   arguments.IsValid = true; return;
                               }
                           }
                       }
                   }
                   arguments.IsValid = false;
               }
               function verifyCheckboxList2(source, arguments) {
                   var val = document.getElementById("<%=CheckBoxList_Language.ClientID%>");
                   var col = val.getElementsByTagName("*");
                   if (col != null) {
                       for (i = 0; i < col.length; i++) {
                           if (col.item(i).tagName == "INPUT") {
                               if (col.item(i).checked) {
                                   arguments.IsValid = true; return;
                               }
                           }
                       }
                   }
                   arguments.IsValid = false;
               }
        
           </script>
     
    </asp:Content>
     
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
     
        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
     
    <script type="text/javascript">
        var date = new Date();
        function RadDatePicker_SetMaxDateToCurrentDate(sender, args) {
            var arr = new Array(date.getFullYear(), date.getMonth() + 1, date.getDate());
            sender.set_rangeMaxDate(arr);
        }
     
        // on upload button click temporarily disables ajax to perform
        // upload actions
        function conditionalPostback(sender, args) {
            if (args.get_eventTarget() == "<%= RadButton1.UniqueID %>") {
                args.set_enableAjax(false);
            }
        }
     
     
     </script>
     </telerik:RadScriptBlock
     
        <telerik:RadToolBar ID="rtbMenu" runat="server" Width="100%" Skin="Windows7">
            <Items>
    <%--            <telerik:RadToolBarButton Value="New" Text="New" Width="80px"  CausesValidation="false" />
                <telerik:RadToolBarButton IsSeparator="true" />
    --%>            <telerik:RadToolBarButton Value="Search" Text="Search" Width="80px"  CausesValidation="false" Visible="false"/>
                <telerik:RadToolBarButton IsSeparator="true" Visible="false" />
                <telerik:RadToolBarButton Value="Delete" Text="Delete" Width="80px" Enabled="true"   CausesValidation="false"/>
                <telerik:RadToolBarButton IsSeparator="true" />
                <telerik:RadToolBarButton Value="Edit" Text="Edit" Width="80px" Enabled="true"   CausesValidation="false"/>
                <telerik:RadToolBarButton IsSeparator="true" />
                <telerik:RadToolBarButton Value="Save" Text="Save" Width="80px" Enabled="true"  />
                <telerik:RadToolBarButton IsSeparator="true" />
                <telerik:RadToolBarButton Value="Cancel" Text="Cancel" Width="80px" Visible="false" CausesValidation="false"  />
                <telerik:RadToolBarButton Value="Back" Text="Back" Width="80px" Visible="true" CausesValidation="false"/>
                <telerik:RadToolBarButton IsSeparator="true" />
                <telerik:RadToolBarButton Value="SIMPER" Text="SIMPER" Width="80px" Enabled="false" CausesValidation="false"  />
                <telerik:RadToolBarButton IsSeparator="true" />
                <telerik:RadToolBarButton Value="BackSeparator" IsSeparator="true" Visible="false" />
            </Items>
        </telerik:RadToolBar>
     
           <div style="margin-left:5px;">   
        <%--<telerik:RadAjaxPanel ID="Panel_content" runat="server" Enabled="false" clientevents-onrequeststart="conditionalPostback">--%>
                         
            <telerik:RadTabStrip ID="RadTabStrip1" runat="server"
                MultiPageID="RadMultiPage1" AutoPostBack="True"
                 ClickSelectedTab="True" SelectedIndex="0">
                <Tabs>
                    <telerik:RadTab runat="server" Text="Personal Info." PageViewID="Tab_personal" Selected="True"
                    CausesValidation="true" OnClientTabSelecting="UpdateValidationGroup" ValidationGroup="ValidatePersonal">
                    </telerik:RadTab>
                    <telerik:RadTab runat="server" Text="Job Particulars" PageViewID="Tab_job"
                    CausesValidation="true" OnClientTabSelecting="UpdateValidationGroup" ValidationGroup="ValidateJob">               
                    </telerik:RadTab>
                    <telerik:RadTab runat="server" Text="Other Info." PageViewID="Tab_Others"
                    CausesValidation="true" OnClientTabSelecting="UpdateValidationGroup" ValidationGroup="ValidateOthers">
                    </telerik:RadTab>
                    <telerik:RadTab runat="server" Text="License" PageViewID="Tab_license"
                    CausesValidation="true" OnClientTabSelecting="UpdateValidationGroup" ValidationGroup="ValidateLicense">
                    </telerik:RadTab>
                    <telerik:RadTab runat="server" Text="Training Course" PageViewID="Tab_training"
                    CausesValidation="true" OnClientTabSelecting="UpdateValidationGroup" ValidationGroup="ValidateTraining">
                    </telerik:RadTab>
                </Tabs>
            </telerik:RadTabStrip>
            <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0">
            <telerik:RadPageView ID="Tab_personal" runat="server">
     
            <telerik:RadAjaxPanel ID="Panel_personal" runat="server" Enabled="false" clientevents-onrequeststart="conditionalPostback">
     
                  <table cellpadding="1" width="1000" style="vertical-align:top">
                                                <tr>
                                                    <td align="left" valign="top" class="style6" >
                                                        Last Name</td>
                                                    <td align="left" valign="top" class="table_content">
                                                        <asp:TextBox ID="tb_last_name" runat="server" Width="300px" Enabled="true"
                                                            onkeyup="javascript:display_name();" TabIndex="1"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server"
                                                            ErrorMessage="Please enter Last Name." ControlToValidate="tb_last_name"
                                                            style="color: #FF0000"></asp:RequiredFieldValidator>
                                                         
                                                    </td>                                             
                                                    <td align="left" valign="top" rowspan="9" style="width:440px;">
                                             
    <div class="qsf-demo-canvas" id="qsfexWrapper">
     
     <telerik:RadBinaryImage runat="server" ID="RadBinaryImage1" ImageUrl="../images/blank_photo.jpg"
                   Width="100px" ResizeMode="Fit" AlternateText="No picture available" style="border-style:dotted;"
                   CssClass="preview" AutoAdjustImageControlSize="false"></telerik:RadBinaryImage>
     
              <div class="qsf-fb">              
               
                             <label>Upload a photo of employee:</label>
                             <telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" InitialFileInputsCount="1"
                                  MaxFileInputsCount="1" AllowedFileExtensions=".jpg,.jpeg,.png,.gif" MaxFileSize="10240000" PostbackTriggers="RadButton1">
                                  </telerik:RadAsyncUpload>
     
                 
                   <p class="buttons">
                        <asp:Button runat="server" ID="RadButton1" Text="Submit your picture"
                             OnClientClick="updatePictureAndInfo(); return false;" />
                             <br />
                             <asp:Label ID="Lb_upload" runat="server" Visible="false"></asp:Label>
                   </p>
              </div>
     
              
     
        </div>
     
        <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
              <script type="text/javascript">
              //<![CDATA[
                  function updatePictureAndInfo() {
                      var upload = $find("<%=RadAsyncUpload1.ClientID %>");
                      if (upload.getUploadedFiles().length > 0) {
                          __doPostBack('RadButton1', 'RadButton1Args');
                      }
                  }
              //]]>
              </script>
         </telerik:RadScriptBlock>   
     
      
                                                     </td>
                                                    <td align="left" valign="top" rowspan="9">
     
                                                             
     
     
     
     
     
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="left" valign="top" class="style6">
                                                        Middle Name</td>
                                                    <td align="left" valign="top" class="table_content">
                                                        <asp:TextBox ID="tb_middle_name" TabIndex="2" runat="server" Width="300px" Enabled="true" onkeyup="javascript:display_name();"></asp:TextBox>
                                                    </td>                                           
                                                    </tr>
                                                <tr>
                                                    <td align="left" valign="top" class="style6">
                                                        First Name</td>
                                                    <td align="left" valign="top" class="table_content">
                                                        <asp:TextBox ID="tb_first_name" runat="server" Width="300px" Enabled="true"
                                                            onkeyup="javascript:display_name();" TabIndex="3"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ErrorMessage="Please enter First Name." ControlToValidate="tb_first_name" style="color: #FF0000"></asp:RequiredFieldValidator>  
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="left" valign="top" class="style6">
                                                        Display Name</td>
                                                    <td align="left" valign="top" class="table_content">
                                                        <asp:TextBox ID="tb_display_name" runat="server" Width="300px" Enabled="true"
                                                            TabIndex="4"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Please enter Display Name." ControlToValidate="tb_display_name" style="color: #FF0000"></asp:RequiredFieldValidator>  
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="left" valign="top" class="style6">
                                                        Username</td>
                                                    <td align="left" valign="top" class="table_content">
                                                        <asp:TextBox ID="tb_username" runat="server" Width="300px" Enabled="true"
                                                            AutoPostBack="true" OnTextChanged="tb_username_OnTextChanged" TabIndex="5"></asp:TextBox>                                                   
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ErrorMessage="Please enter Username." ControlToValidate="tb_username" style="color: #FF0000"></asp:RequiredFieldValidator>  
                                                         <asp:Label ID="lb_message" runat="server" Visible="False"></asp:Label>
                                                    </td>
                                                </tr>                                            <tr>
                                                    <td align="left" valign="top" class="style6">
                                                        Gender</td>
                                                    <td align="left" valign="top" class="table_content">
                                                        <asp:RadioButtonList ID="rbl_gender" runat="server"
                                                            RepeatDirection="Horizontal">
                                                        <asp:ListItem Text="Male" Value="M"></asp:ListItem>
                                                        <asp:ListItem Text="Female" Value="F"></asp:ListItem>
                                                        </asp:RadioButtonList>
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="Please select a gender." ControlToValidate="rbl_gender" style="color: #FF0000"></asp:RequiredFieldValidator>  
                                                        <br />
                                                    </td>
                                                </tr>
                                                    <tr>
                                                    <td align="left" valign="top" class="style6">
                                                        Date of Birth</td>
                                                    <td align="left" valign="top" class="table_content">
                                                        <telerik:RadDatePicker ID="RadDatePicker_birthday" Runat="server" Enabled="true" MinDate="1900/1/1">
                                                        <DateInput ID="tb_birthday" runat="server" DateFormat="dd-MMM-yyyy" DisplayDateFormat="dd-MMM-yyyy" LabelWidth="" ></DateInput>                                                   
     
            <Calendar ID="Calendar2" runat="server"
                <SpecialDays
                    <telerik:RadCalendarDay Repeatable="Today" Date="" ItemStyle-CssClass="rcToday" /> 
                </SpecialDays
                <ClientEvents OnLoad="RadDatePicker_SetMaxDateToCurrentDate" /> 
            </Calendar>
     
                                                        </telerik:RadDatePicker>
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Please enter birthday." ControlToValidate="RadDatePicker_birthday" style="color: #FF0000"></asp:RequiredFieldValidator>  
     
                                                    </td>                                            </tr>
                                                <tr>
                                                    <td align="left" valign="top" class="style6">
                                                        Blood Type</td>
                                                    <td align="left" valign="top" class="table_content">
                                                        <asp:RadioButtonList ID="rbl_blood_type" runat="server" RepeatColumns="4"
                                                            RepeatDirection="Horizontal">
                                                        <asp:ListItem Text="O+" Value="O+"></asp:ListItem>
                                                        <asp:ListItem Text="A+" Value="A+"></asp:ListItem>
                                                        <asp:ListItem Text="B+" Value="B+"></asp:ListItem>
                                                        <asp:ListItem Text="AB+" Value="AB+"></asp:ListItem>
                                                        <asp:ListItem Text="O-" Value="O-"></asp:ListItem>
                                                        <asp:ListItem Text="A-" Value="A-"></asp:ListItem>
                                                        <asp:ListItem Text="B-" Value="B-"></asp:ListItem>
                                                        <asp:ListItem Text="AB-" Value="AB-"></asp:ListItem>
                                                        <asp:ListItem Text="Unknown" Value="Unknown"></asp:ListItem>
                                                        </asp:RadioButtonList>
                                                       <asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" ErrorMessage="Please select a blood type." ControlToValidate="rbl_blood_type" style="color: #FF0000"></asp:RequiredFieldValidator>  
     
                                                    </td>                                           
                                                    </tr>
                                                <tr>
                                                    <td align="left" valign="top" class="style6">
                                                        Email</td>
                                                    <td align="left" valign="top" class="table_content">
                                                    <asp:TextBox ID="tb_email" runat="server" Width="300px" Enabled="true"></asp:TextBox>                                           
                                                    <asp:RegularExpressionValidator ID="RequiredFieldValidator9" runat="server" Display="Dynamic"
                                                        ErrorMessage="Please, enter valid e-mail address." ValidationExpression="^[\w\.\-]+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*(\.[a-zA-Z]{2,3}){1,2}$"
                                                        ControlToValidate="tb_email" style="color: #FF0000"></asp:RegularExpressionValidator>   
                                                    </td></tr>
                                                <tr>
                                                    <td align="left" valign="top" class="style6">
                                                        Phone</td>
                                                    <td align="left" valign="top" >
                                                    <asp:TextBox ID="tb_phone" runat="server" Width="300px" Enabled="true"></asp:TextBox>
                                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" Display="Dynamic" ErrorMessage="Please, enter valid phone number." ValidationExpression="\d+" ControlToValidate="tb_phone" style="color: #FF0000"></asp:RegularExpressionValidator>
                                                    
                                                    </td>
                                                </tr><tr>
                                                    <td align="left" valign="top" class="style6">
                                                        Address</td>
                                                    <td align="left" valign="top"  colspan="2">
                                                        <asp:TextBox runat="server" ID="tb_addr" Width="639px" TextMode="MultiLine"
                                                          Enabled="true"></asp:TextBox>
                                                    </td>
                                                    <td align="left" valign="top">
                                                         </td>
                                                </tr>                                                                                                                                                                                             
        </table>
        </telerik:RadAjaxPanel>
                 
                <asp:Button ID="btnStep2" runat="server" Text="Next" OnClick="btnStep2_Click" CausesValidation="false" />
            </telerik:RadPageView>       
             
             
                 
            <telerik:RadPageView ID="Tab_job" runat="server">
     
                    <telerik:RadAjaxPanel ID="Panel_job" runat="server" Enabled="false" clientevents-onrequeststart="conditionalPostback">
     
            <table cellpadding="1" width="100%" style="vertical-align:top">
                                                        <tr>
                                                    <td align="left" valign="top" class="style6">
                                                        Location</td>
                                                    <td align="left" valign="top" class="table_content">
                                                        <asp:TextBox ID="tb_location" runat="server" Width="300px" Enabled="true" Visible="false"></asp:TextBox>
                                                        <telerik:RadDropDownList ID="RadDropDownList_location" runat="server"
                                                            DataSourceID="LDS_Location" DataTextField="Location" CausesValidation="true"
                                                            DataValueField="Location_ID" Enabled="true" DefaultMessage="Please Select...">
                                                        </telerik:RadDropDownList>
                                                       <asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ControlToValidate="RadDropDownList_location"
                                                        InitialValue="0" ErrorMessage="Please select a Location." style="color: #FF0000"></asp:RequiredFieldValidator>
                                                        <asp:LinqDataSource ID="LDS_Location" runat="server"
                                                            ContextTypeName="dcLRDBDataContext" EntityTypeName="" TableName="db_Locations">
                                                        </asp:LinqDataSource>
                                                    </td>                                           
                                                    </tr>
                                                    <tr>
                                                    <td align="left" valign="top" class="style6">
                                                        Department</td>
                                                    <td align="left" valign="top" class="table_content">
                                                        <asp:TextBox ID="tb_dept" runat="server" Width="300px" Enabled="true" Visible="false"></asp:TextBox>
                                                        <telerik:RadDropDownList ID="RadDropDownList_dept" runat="server"  AutoPostBack="true" CausesValidation="true"
                                                            DataSourceID="LDS_Dept" DataTextField="Department" DataValueField="DeptID" Enabled="true" DefaultMessage="Please Select..." OnSelectedIndexChanged="RadDropDownList_dept_OnSelectedIndexChanged">
                                                        </telerik:RadDropDownList>
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ControlToValidate="RadDropDownList_dept"
                                                         InitialValue="0" ErrorMessage="Please select a Department." style="color: #FF0000"></asp:RequiredFieldValidator>
                                                        <asp:LinqDataSource ID="LDS_Dept" runat="server"
                                                            ContextTypeName="dcLRDBDataContext" EntityTypeName=""
                                                            TableName="db_Departments">
                                                        </asp:LinqDataSource>
                                                    </td>                                            </tr>
                                                                                            <tr>
                                                    <td align="left" valign="top" class="style6">
                                                        Job Title</td>
                                                    <td align="left" valign="top" class="table_content">
                                                        <telerik:RadDropDownList ID="RadDropDownList_job_title" runat="server"
                                                        AutoPostBack="true" CausesValidation="true"
                                                            DataSourceID="LDS_job_title" DataTextField="Job_title" DataValueField="ID" Enabled="true" DefaultMessage="Please Select...">
                                                        </telerik:RadDropDownList>  
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="RadDropDownList_job_title"
                                                         InitialValue="0" ErrorMessage="Please select a Job Title." style="color: #FF0000"></asp:RequiredFieldValidator>
                                                        <asp:LinqDataSource ID="LDS_job_title" runat="server"
                                                            ContextTypeName="dcLRDBDataContext" EntityTypeName=""
                                                            TableName="db_dictionary_job_titles">
                                                        </asp:LinqDataSource>
                                                                                                        </td>                                            </tr>     
                                            <tr>
                                                    <td align="left" valign="top" class="style6">
                                                        Role Type</td>
                                                    <td align="left" valign="top" class="table_content">
                                                        <asp:TextBox ID="tb_roletype" runat="server" Width="300px" Enabled="true" Visible="false"></asp:TextBox>
                                                         
                                                        <asp:CheckBoxList ID="CheckBoxList_RoleType" runat="server" 
                                                            DataSourceID="LDS_RoleType" DataTextField="RoleName" AutoPostBack="True"
                                                            DataValueField="RoleTypeID" 
                                                             OnDataBound="CheckBoxList_RoleType_DataBound" RepeatColumns="6"
                                                            RepeatDirection="Horizontal" >
                                                        </asp:CheckBoxList>
                                                                <%--<asp:CustomValidator ID="CustomValidator1" ClientValidationFunction="ValidateChkList" runat="server" >Please select a Role Type</asp:CustomValidator>--%>
                                                                <asp:CustomValidator  OnServerValidate="RoleType_ServerValidation"  ID="valRoleType"  EnableClientScript="true"  ClientValidationFunction="verifyCheckboxList"  ErrorMessage="Please select a Role Type"  runat="server" style="color: #FF0000"></asp:CustomValidator>
     
                                                        <asp:ObjectDataSource ID="ODS_RoleType" runat="server"
                                                            SelectMethod="GetRoleTypeArrayByUserID" TypeName="LRDB">
                                                            <SelectParameters>
                                                                <asp:SessionParameter Name="id" SessionField="SelectedEmployeeID"
                                                                    Type="String" />
                                                            </SelectParameters>
                                                        </asp:ObjectDataSource>
     
                                                        <asp:LinqDataSource ID="LDS_RoleType" runat="server"
                                                            ContextTypeName="dcLRDBDataContext" EntityTypeName=""
                                                            Select="new (RoleName, RoleTypeID)" TableName="db_Dictionary_RoleTypes">
                                                        </asp:LinqDataSource>
                                                    </td>                                            </tr>                                       
                                                    <tr>
                                                    <td align="left" valign="top" class="style6">
                                                        Supervisor</td>
                                                    <td align="left" valign="top" class="table_content">
                                                        <telerik:RadDropDownList ID="RadDropDownList_supervisor" runat="server"
                                                             AutoPostBack="true" CausesValidation="true"
                                                            DefaultMessage="Please Select..." DataSourceID="ODS_Supervisor"
                                                            DataTextField="Employee_Display_Name" DataValueField="UserID"
                                                            >
                                                        </telerik:RadDropDownList>
                                                        <asp:ObjectDataSource ID="ODS_Supervisor" runat="server"
                                                            SelectMethod="GetSupervisorArrayByDeptID" TypeName="LRDB">
                                                            <SelectParameters>
                                                                <asp:ControlParameter ControlID="RadDropDownList_dept" Name="id"
                                                                    PropertyName="SelectedValue" Type="Int32" />
                                                                <asp:SessionParameter Name="pid" SessionField="SelectedPID" Type="Int32" />
                                                            </SelectParameters>
                                                        </asp:ObjectDataSource>
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator15" runat="server"
                                                            ControlToValidate="RadDropDownList_supervisor" InitialValue="0"
                                                            ErrorMessage="Please select a Supervisor." style="color: #FF0000"></asp:RequiredFieldValidator>
                                                    </td>                                            </tr>
                                                <tr>
                                                    <td align="left" valign="top" class="style6">
                                                        Point of Hire</td>
                                                    <td align="left" valign="top" class="table_content">
                                                        <asp:TextBox ID="tb_point_of_hire" runat="server" Width="300px" Enabled="true"></asp:TextBox>
                                                    </td>                                            </tr>
                                                <tr>
                                                    <td align="left" valign="top" class="style6">
                                                        Start Date</td>
                                                    <td align="left" valign="top" class="table_content">
                                                        <telerik:RadDatePicker ID="RadDatePicker_start_date" Runat="server" Enabled="true" MinDate="1900/1/1">
                                                        <DateInput ID="DateInput1" runat="server" DateFormat="dd-MMM-yyyy" DisplayDateFormat="dd-MMM-yyyy" LabelWidth=""></DateInput>
                                                                 
                                                        </telerik:RadDatePicker>
     
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="Please enter Start Date." ControlToValidate="RadDatePicker_start_date" style="color: #FF0000"></asp:RequiredFieldValidator>  
                                                    </td>                                            </tr>
                                                <tr>
                                                    <td align="left" valign="top" class="style6">
                                                        End Date</td>
                                                    <td align="left" valign="top" class="table_content">
                                                        <telerik:RadDatePicker ID="RadDatePicker_end_date" Runat="server" Enabled="true">
                                                        <DateInput ID="DateInput2" runat="server" DateFormat="dd-MMM-yyyy" DisplayDateFormat="dd-MMM-yyyy" LabelWidth=""></DateInput>
                                                           
                                                        </telerik:RadDatePicker>
                                                        <asp:CompareValidator ID="dateCompareValidator" runat="server" ControlToValidate="RadDatePicker_end_date" ControlToCompare="RadDatePicker_start_date"
                                        Operator="GreaterThanEqual" Type="Date" ErrorMessage="End date must be equal or greater than Start date - please correct dates." Display="Dynamic">
                                    </asp:CompareValidator>
     
                                                         
                                                    </td>                                            </tr>
                                                                                        
     
     
            </table>
            </telerik:RadAjaxPanel>
                <asp:Button ID="btnback3" runat="server" Text="Back" OnClick="btnback3_Click" CausesValidation="false" />
                <asp:Button ID="btnStep3" runat="server" Text="Next" OnClick="btnStep3_Click" CausesValidation="true"/>
     
            </telerik:RadPageView>
             
            <telerik:RadPageView ID="Tab_Others" runat="server">
     
                    <telerik:RadAjaxPanel ID="Panel_others" runat="server" Enabled="false" clientevents-onrequeststart="conditionalPostback">
     
            <table cellpadding="1" width="100%" style="vertical-align:top">
             <tr>
                                                    <td align="left" valign="top" class="table_header">
                                                        Language</td>
                                                    <td align="left" valign="top" class="table_content">                                                                                                       
                                                        <asp:CheckBoxList ID="CheckBoxList_Language" runat="server" 
                                                            AutoPostBack="True"
                                                             
                                                             OnDataBound="CheckBoxList_Language_DataBound" DataSourceID="LDS_Language"
                                                            DataTextField="Language_LongName" DataValueField="Language_ID"
                                                            RepeatColumns="8" >
                                                        </asp:CheckBoxList>
                                                        <asp:CustomValidator  OnServerValidate="Language_ServerValidation"  ID="valLanguage"  EnableClientScript="true"  ClientValidationFunction="verifyCheckboxList2"  ErrorMessage="Please select a Language"  runat="server"></asp:CustomValidator>
                                                        <%--<asp:CustomValidator ID="CustomValidator2" ClientValidationFunction="ValidateChkList2" runat="server" >Please select a Language</asp:CustomValidator>--%>
                                                                <asp:LinqDataSource ID="LDS_Language" runat="server"
                                                            ContextTypeName="dcLRDBDataContext" 
                                                            Select="new (Language_ID, Language_LongName)"
                                                            TableName="db_Dictionary_Languages">
                                                        </asp:LinqDataSource>
                                                                 
     
                                                    </td>                                            </tr>   
                                                     <tr>
                                                    <td align="left" valign="top" class="table_header">
                                                        Ability</td>
                                                    <td align="left" valign="top" class="table_content">                                                                                                       
                                                        <asp:CheckBoxList ID="CheckBoxList_Ability" runat="server" 
                                                            AutoPostBack="True"                                                        
                                                             OnDataBound="CheckBoxList_Ability_DataBound" DataSourceID="LDS_Ability"
                                                            DataTextField="Ability_LongName" DataValueField="Ability_ID"
                                                            RepeatColumns="8"  >
                                                        </asp:CheckBoxList>
                                                                <%--<asp:CustomValidator ID="CustomValidator3" ClientValidationFunction="ValidateChkList3" runat="server" >Please select a Ability</asp:CustomValidator>--%>
                                                                <asp:LinqDataSource ID="LDS_Ability" runat="server"
                                                            ContextTypeName="dcLRDBDataContext" 
                                                            Select="new (Ability_ID, Ability_LongName)"
                                                            TableName="db_Dictionary_Abilities">
                                                        </asp:LinqDataSource>                                                                                                                       
                                                    </td>                                            </tr
                                                                                                   <tr>
                                                    <td align="left" valign="top" class="table_header">
                                                        Prior Experience</td>
                                                    <td align="left" valign="top" colspan="2">
                                                        <asp:TextBox runat="server" ID="Tb_prior_exp" Width="639px" TextMode="MultiLine"
                                                          Enabled="true"></asp:TextBox>
     
                                                    </td>
                                                    <td align="left" valign="top">
                                                         </td>
                                                </tr>                                                                                              
     
                                                                                                   <tr>
                                                    <td align="left" valign="top" class="table_header">
                                                        Notes</td>
                                                    <td align="left" valign="top" colspan="2">
                                                        <asp:TextBox runat="server" ID="tb_notes" Width="639px" TextMode="MultiLine"
                                                          Enabled="true"></asp:TextBox>
                                                    </td>
                                                    <td align="left" valign="top">
                                                         </td>
                                                </tr
            </table>
            </telerik:RadAjaxPanel>
                        <asp:Button ID="btnback4" runat="server" Text="Back" OnClick="btnback4_Click" CausesValidation="false" />
                        <asp:Button ID="btnStep4" runat="server" Text="Next" OnClick="btnStep4_Click" CausesValidation="true"/>
     
            </telerik:RadPageView>
     
            <telerik:RadPageView ID="Tab_license" runat="server">
             
                <strong><span class="style4">License</span><br /> </strong>
                <br />
     
                        <telerik:RadAjaxPanel ID="Panel_License" runat="server" Enabled="false" clientevents-onrequeststart="conditionalPostback">
     
                                                                <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
                                                                <script type="text/javascript">
                                                                    function RowDblClick(sender, eventArgs) {
                                                                        sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
                                                                    }
                                                                </script>
                                                            </telerik:RadCodeBlock>
     
                                                            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                                                                <AjaxSettings>
                                                                    <telerik:AjaxSetting AjaxControlID="RadGrid_License">
                                                                        <UpdatedControls>
                                                                            <telerik:AjaxUpdatedControl ControlID="RadGrid_License" LoadingPanelID="RadAjaxLoadingPanel1">
                                                                            </telerik:AjaxUpdatedControl>
                                                                            <telerik:AjaxUpdatedControl ControlID="divMsgs"></telerik:AjaxUpdatedControl>
                                                                        </UpdatedControls>
                                                                    </telerik:AjaxSetting>
                                                                </AjaxSettings>
                                                            </telerik:RadAjaxManager>
                                                            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
                                                            </telerik:RadAjaxLoadingPanel>
                                                                <telerik:RadGrid ID="RadGrid_License" runat="server" CellSpacing="0"
                                                                DataSourceID="ODS_License" GridLines="None" style="margin-top: 0px"
                                                                AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True"
                                                                AutoGenerateColumns="False" ShowStatusBar="True" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
                                                                AllowAutomaticUpdates="True" Width="800">
                                                                    <MasterTableView AutoGenerateColumns="False"
                                                                        DataKeyNames="License_To_Operate_ID" DataSourceID="ODS_License"
                                                                        AllowFilteringByColumn="False" AllowPaging="False"
                                                                        CommandItemDisplay="Top">
     
                                                                        <CommandItemSettings ExportToPdfText="Export to PDF" />
                                                                        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"
                                                                            Visible="True">
                                                                        </RowIndicatorColumn>
                                                                        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"
                                                                            Visible="True">
                                                                        </ExpandCollapseColumn>
     
                                                                        <Columns>
                                                                            <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
                                                                            </telerik:GridEditCommandColumn>
                                                                            <telerik:GridBoundColumn DataField="License_To_Operate_ID"
                                                                                FilterControlAltText="Filter License_Number column" HeaderText="License_To_Operate_ID"
                                                                                SortExpression="License_To_Operate_ID" UniqueName="License_To_Operate_ID" Visible="false">
                                                                            </telerik:GridBoundColumn>
                                                                            <telerik:GridBoundColumn DataField="License_Name"
                                                                                FilterControlAltText="Filter License_Name column" HeaderText="License Name"
                                                                                SortExpression="License_Name" UniqueName="License_Name">
                                                                            </telerik:GridBoundColumn>
                                                                            <telerik:GridBoundColumn DataField="License_Number"
                                                                                FilterControlAltText="Filter License_Number column" HeaderText="License Number"
                                                                                SortExpression="License_Number" UniqueName="License_Number">
                                                                            </telerik:GridBoundColumn>
                                                                            <telerik:GridBoundColumn DataField="License_Issuer"
                                                                                FilterControlAltText="Filter License_Issuer column" HeaderText="License Issuer"
                                                                                SortExpression="License_Issuer" UniqueName="License_Issuer">
                                                                            </telerik:GridBoundColumn>
                                                                            <telerik:GridBoundColumn DataField="Valid_From" DataType="System.DateTime"
                                                                                FilterControlAltText="Filter Valid_From column" HeaderText="Valid From"
                                                                                SortExpression="Valid_From" UniqueName="Valid_From" DataFormatString="{0: dd-MMM-yyyy}">
                                                                            </telerik:GridBoundColumn>
                                                                            <telerik:GridBoundColumn DataField="Valid_Till" DataType="System.DateTime"
                                                                                FilterControlAltText="Filter Valid_Till column" HeaderText="Valid Till"
                                                                                SortExpression="Valid_Till" UniqueName="Valid_Till" DataFormatString="{0: dd-MMM-yyyy}">
                                                                            </telerik:GridBoundColumn>
                                                                            <telerik:GridBoundColumn DataField="Issue_date" DataType="System.DateTime"
                                                                                FilterControlAltText="Filter Issue_date column" HeaderText="Issue Date"
                                                                                SortExpression="Issue_date" UniqueName="Issue_date" DataFormatString="{0: dd-MMM-yyyy}">
                                                                            </telerik:GridBoundColumn>
                                                                        </Columns>
                                                                        <EditFormSettings EditFormType="Template">
                                                                            <EditColumn FilterControlAltText="Filter EditCommandColumn1 column"
                                                                                UniqueName="EditCommandColumn1">
                                                                            </EditColumn>
                                                                        <FormTemplate>
     
                                                            <table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="1" rules="none"
                                                                style="border-collapse: collapse;">
                                                                <tr class="EditFormHeader">
                                                                <td style="width:100px">
                                                                <asp:Label ID="Label5" Text="License Type" runat="server"></asp:Label>                                                           
                                                                </td>
                                                                <td>
                                                                    <telerik:RadDropDownList ID="rdl_license_type" runat="server" DataSourceID="LDS_License_type" DefaultMessage="Please select..."
                                                                     DataValueField="License_ID" DataTextField="License_name" >
                                                                    </telerik:RadDropDownList>  
                                                                    <%--<asp:Label ID="Lb_License_ID" runat="server" text='<%# Bind("License_ID") %>' Visible="false"></asp:Label>--%>
                                                         
                                                                </td>
                                                                </tr>
                                                                <tr >
                                                                <td >
                                                                <asp:Label ID="lb" Text="License Number" runat="server"></asp:Label>                                                           
                                                                </td>
                                                                <td>
                                                                <asp:TextBox ID="tb_License_Number" runat="server" Text='<%# Bind("License_Number") %>' TabIndex="2"></asp:TextBox>                                                           
                                                                </td>
                                                                </tr>
                                                                <tr>
                                                                <td>
                                                                <asp:Label ID="Label1" Text="License Issuer" runat="server"></asp:Label>
                                                                </td>
                                                                <td>
                                                                <asp:TextBox ID="tb_License_Issuer" runat="server" Text='<%# Bind("License_Issuer") %>' TabIndex="3"></asp:TextBox>
                                                                </td>
                                                                </tr>
                                                                <tr>
                                                                <td>
                                                                <asp:Label ID="Label2" Text="Issue Date" runat="server"></asp:Label>
                                                                </td>
                                                                <td>
                                                                <telerik:RadDatePicker ID="IssueDatePicker" runat="server" MinDate="1/1/1900" DbSelectedDate='<%# Bind("Issue_Date") %>' TabIndex="4"></telerik:RadDatePicker>
                                                                </td>
                                                                </tr>
                                                                <tr>
                                                                <td>
                                                                <asp:Label ID="Label3" Text="Valid From" runat="server"></asp:Label>
                                                                </td>
                                                                <td>
                                                                <telerik:RadDatePicker ID="RadDatePicker_ValidFrom" runat="server" MinDate="1/1/1900" DbSelectedDate='<%# Bind("Valid_From") %>' TabIndex="5"></telerik:RadDatePicker>
                                                                </td>
                                                                </tr>
                                                                                                                            <tr>
                                                                <td>
                                                                <asp:Label ID="Label4" Text="Valid To" runat="server"></asp:Label>
                                                                </td>
                                                                <td>
                                                                <telerik:RadDatePicker ID="RadDatePicker_ValidTill" runat="server" MinDate="1/1/1900" DbSelectedDate='<%# Bind("Valid_Till") %>' TabIndex="6"></telerik:RadDatePicker>
                                                                </td>
                                                                </tr>
     
                                                                   <tr>
                                                                    <td align="right" colspan="2">
                                                                        <asp:Button ID="btnUpdate" Text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "Insert", "Update") %>'
                                                                            runat="server" CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update")%>' >
                                                                        </asp:Button
                                                                        <asp:Button ID="btnDelete" Text="Delete" runat="server" CausesValidation="False"
                                                                            CommandName="Delete"></asp:Button>
                                                                        <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                                                            CommandName="Cancel"></asp:Button>
     
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </FormTemplate>
                                                    </EditFormSettings>
                                                                        <PagerStyle PageSizeControlType="RadComboBox" />
                                                                    </MasterTableView>
                                                                    <PagerStyle PageSizeControlType="RadComboBox" />
                                                                    <FilterMenu EnableImageSprites="False">
                                                                    </FilterMenu>
     
                                                            </telerik:RadGrid>
                                                            <asp:LinqDataSource ID="LDS_License_type" runat="server"
                                                                ContextTypeName="dcLRDBDataContext" EntityTypeName=""
                                                                TableName="db_Dictionary_Licenses">
                                                                </asp:LinqDataSource>
                                                            <asp:ObjectDataSource ID="ODS_License" runat="server"
                                                                SelectMethod="GetLicenseArrayByUserID" TypeName="LRDB">
                                                                <SelectParameters>
                                                                    <asp:SessionParameter DefaultValue="0" Name="id" SessionField="SelectedUserID"
                                                                        Type="String" />
                                                                </SelectParameters>
                                                            </asp:ObjectDataSource>
                                                            <asp:LinqDataSource ID="LDS_License" runat="server"
                                                                ContextTypeName="dcLRDBDataContext" EntityTypeName=""
                                                                TableName="db_Employee_Licenses" Where="UserID == @UserID">
                                                                <WhereParameters>
                                                                    <asp:SessionParameter Name="UserID" SessionField="SelectedUserID"
                                                                        Type="Int32" DefaultValue="0"/>
                                                                </WhereParameters>
                                                            </asp:LinqDataSource>
                                          <br />
     
            </telerik:RadAjaxPanel>
                        <asp:Button ID="btnback5" runat="server" Text="Back" OnClick="btnback5_Click" CausesValidation="false" />
                        <asp:Button ID="btnStep5" runat="server" Text="Next" OnClick="btnStep5_Click" CausesValidation="true"/>
     
            </telerik:RadPageView>
             
            <telerik:RadPageView ID="Tab_training" runat="server">
             
                                                                <strong><span class="style4">Training Course Details and Progress</span><br />
                                                        </strong><br />
                                                         
                                                           <div style="width:80%;">
                                                               <strong>Completed Course (Internal)</strong>
             
     
     
            <br />
            <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" Width="800"
                CellSpacing="0" DataSourceID="ODS_CompleteCourse" GridLines="None" Skin="Windows7">
    <MasterTableView DataSourceID="ODS_CompleteCourse">
    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
     
    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
    <HeaderStyle Width="20px"></HeaderStyle>
    </RowIndicatorColumn>
     
    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
    <HeaderStyle Width="20px"></HeaderStyle>
    </ExpandCollapseColumn>
     
      <Columns>
            <telerik:GridBoundColumn DataField="Course_Name"
                FilterControlAltText="Filter Course Name"
                HeaderText="Course Name" SortExpression="Course_Name"
                UniqueName="Course_Name"  ReadOnly="True">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Exam_Date"
                FilterControlAltText="Filter Date column"
                HeaderText="Exam Date" SortExpression="Date" DataFormatString="{0:yyyy-MM-dd}"
                UniqueName="Exam_Date" DataType="System.DateTime" ReadOnly="True" HeaderStyle-Width="15%">
                <HeaderStyle Width="15%" />
            </telerik:GridBoundColumn>
    <%--        <telerik:GridBoundColumn DataField="Time"
                FilterControlAltText="Filter Time column" HeaderText="Time" ReadOnly="True"
                SortExpression="Time" UniqueName="Time" DataType="System.TimeSpan" DataFormatString="{0:t}" HeaderStyle-Width="15%">
            </telerik:GridBoundColumn>--%>
            <telerik:GridBoundColumn DataField="Exam_Score"
                FilterControlAltText="Filter Score" HeaderText="Exam Score" ReadOnly="True"
                SortExpression="Exam_Score" UniqueName="Exam_Score" HeaderStyle-Width="15%">
                <HeaderStyle Width="15%" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Result"
                FilterControlAltText="Filter Result" HeaderText="Result" ReadOnly="True"
                SortExpression="Result" UniqueName="Result" HeaderStyle-Width="15%">
                <HeaderStyle Width="15%" />
            </telerik:GridBoundColumn>
    <%--        <telerik:GridBoundColumn DataField="Status"
                FilterControlAltText="Filter Status column" HeaderText="Status" ReadOnly="True"
                SortExpression="Status" UniqueName="Status" HeaderStyle-Width="15%">
                <HeaderStyle Width="15%" />
            </telerik:GridBoundColumn>--%>
            <telerik:GridBoundColumn DataField="Remarks"
                FilterControlAltText="Filter Remarks column" HeaderText="Remarks" ReadOnly="True"
                SortExpression="Remarks" UniqueName="Remarks" HeaderStyle-Width="15%">
                <HeaderStyle Width="15%" />
            </telerik:GridBoundColumn>
        </Columns>
     
    <EditFormSettings>
    <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
    </EditFormSettings>
     
    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
    </MasterTableView>
     
    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
     
    <FilterMenu EnableImageSprites="False"></FilterMenu>
            </telerik:RadGrid>
     
     
     
     
                                                               <asp:ObjectDataSource ID="ODS_CompleteCourse" runat="server"
                                                                   SelectMethod="GetTrainingRecordByEmployeeID" TypeName="LRDB">
                                                                   <SelectParameters>
                                                                       <asp:QueryStringParameter Name="id" QueryStringField="EmployeeID"
                                                                           Type="Int32" />
                                                                   </SelectParameters>
                                                               </asp:ObjectDataSource>
            <br />
            <br />
            <span class="style6"><strong>
    Incompleted Course (Internal)</strong></span><telerik:RadGrid ID="RadGrid2" runat="server" AutoGenerateColumns="False"
                CellSpacing="0" DataSourceID="LinqDataSource2" GridLines="None" Skin="Windows7" Enabled="true" Width="800">
    <MasterTableView DataSourceID="LinqDataSource2">
    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
     
    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
    <HeaderStyle Width="20px"></HeaderStyle>
    </RowIndicatorColumn>
     
    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
    <HeaderStyle Width="20px"></HeaderStyle>
    </ExpandCollapseColumn>
     
        <Columns>
            <telerik:GridBoundColumn DataField="db_course.Course_Name"
                FilterControlAltText="Filter Course Name"
                HeaderText="Course Name" SortExpression="db_course.Course_Name"
                UniqueName="db_course.Course_Name"  ReadOnly="True">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Start_Time"
                FilterControlAltText="Filter Date column"
                HeaderText="Start Time" SortExpression="Start_Time" DataFormatString="{0:yyyy-MM-dd HH:mm}"
                UniqueName="Start_Time" DataType="System.DateTime" ReadOnly="True" HeaderStyle-Width="25%">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="End_Time"
                FilterControlAltText="Filter Date column"
                HeaderText="End Time" SortExpression="End_Time" DataFormatString="{0:yyyy-MM-dd HH:mm}"
                UniqueName="End_Time" DataType="System.DateTime" ReadOnly="True" HeaderStyle-Width="25%">
            </telerik:GridBoundColumn>       
            <telerik:GridBoundColumn DataField="Remarks"
                FilterControlAltText="Filter Remarks column" HeaderText="Remarks" ReadOnly="True"
                SortExpression="Remarks" UniqueName="Remarks" HeaderStyle-Width="15%">
            </telerik:GridBoundColumn>
        </Columns>
     
    <EditFormSettings>
    <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
    </EditFormSettings>
     
    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
    </MasterTableView>
     
    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
     
    <FilterMenu EnableImageSprites="False"></FilterMenu>
            </telerik:RadGrid>
     
            <br />
            <br />
            <span class="style6"><strong>
    External Training</strong></span><telerik:RadGrid ID="RadGrid3" runat="server" AutoGenerateColumns="False"
                CellSpacing="0" DataSourceID="LinqDataSource3" GridLines="None" Skin="Windows7" Enabled="true" Width="800">
    <MasterTableView DataSourceID="LinqDataSource3">
    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
     
    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
    <HeaderStyle Width="20px"></HeaderStyle>
    </RowIndicatorColumn>
     
    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
    <HeaderStyle Width="20px"></HeaderStyle>
    </ExpandCollapseColumn>
     
        <Columns>
            <telerik:GridBoundColumn DataField="db_Training_Course_External.Course_Name"
                FilterControlAltText="Filter Course Name"
                HeaderText="Course Name" SortExpression="db_Training_Course_External.Course_Name"
                UniqueName="db_Training_Course_External.Course_Name"  ReadOnly="True">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Start_Time"
                FilterControlAltText="Filter Date column"
                HeaderText="Start Time" SortExpression="Start_Time" DataFormatString="{0:yyyy-MM-dd HH:mm}"
                UniqueName="Start_Time" DataType="System.DateTime" ReadOnly="True" HeaderStyle-Width="25%">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="End_Time"
                FilterControlAltText="Filter Date column"
                HeaderText="End Time" SortExpression="End_Time" DataFormatString="{0:yyyy-MM-dd HH:mm}"
                UniqueName="End_Time" DataType="System.DateTime" ReadOnly="True" HeaderStyle-Width="25%">
            </telerik:GridBoundColumn>       
            <telerik:GridBoundColumn DataField="Status"
                FilterControlAltText="Filter Status column" HeaderText="Status" ReadOnly="True"
                SortExpression="Status" UniqueName="Status" HeaderStyle-Width="15%">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Remarks"
                FilterControlAltText="Filter Remarks column" HeaderText="Remarks" ReadOnly="True"
                SortExpression="Remarks" UniqueName="Remarks" HeaderStyle-Width="15%">
            </telerik:GridBoundColumn>
        </Columns>
     
    <EditFormSettings>
    <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
    </EditFormSettings>
     
    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
    </MasterTableView>
     
    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
     
    <FilterMenu EnableImageSprites="False"></FilterMenu>
            </telerik:RadGrid>
                                                                                                                            
                    <asp:LinqDataSource ID="LinqDataSource1" runat="server"
                ContextTypeName="dcLRDBDataContext" EntityTypeName=""
                Select="new (db_Course, db_Training_Session.db_training_record, db_Training_Session.Status)" TableName="db_Employee_Enrollments"
                Where="UserID == @UserID && db_Training_Session.Status == @Status">
                        <WhereParameters>
                            <asp:SessionParameter Name="UserID" SessionField="SelectedUserID" DefaultValue="0"
                                Type="Int32" />
                            <asp:Parameter DefaultValue="Completed" Name="Status"
                                Type="String" />
                        </WhereParameters>
            </asp:LinqDataSource>
                         
                    <asp:LinqDataSource ID="LinqDataSource2" runat="server"
                ContextTypeName="dcLRDBDataContext" EntityTypeName=""
                Select="new (db_Course, Start_Time, End_Time, Remarks)" TableName="db_Employee_Enrollments"
                Where="UserID == @UserID && db_Training_Session.Status == @Status && db_Training_Session.Parent_ID == null ">
                        <WhereParameters>
                            <asp:SessionParameter Name="UserID" SessionField="SelectedUserID" DefaultValue="0"
                                Type="Int32" />
                            <asp:Parameter DefaultValue="Confirmed" Name="Status"
                                Type="String" />
                            <asp:Parameter  Name="Parent_ID"
                                Type="Int32" />
                        </WhereParameters>
            </asp:LinqDataSource>                   
     
                    <asp:LinqDataSource ID="LinqDataSource3" runat="server"
                ContextTypeName="dcLRDBDataContext" EntityTypeName=""
                Select="new (db_Training_Course_External.course_name, Start_Time, End_Time, Remarks)" TableName="db_employee_enrollment_externals"
                Where="Employee_ID == @eid ">
                        <WhereParameters>
                          <asp:QueryStringParameter Name="eid" QueryStringField="EmployeeID"
                                                                           Type="Int32" />
     
                            <asp:Parameter DefaultValue="Confirmed" Name="Status"
                                Type="String" />
                            <asp:Parameter  Name="Parent_ID"
                                Type="Int32" />
                        </WhereParameters>
            </asp:LinqDataSource>                                                                                                        
                    </div>
                                               <asp:Button ID="btnback6" runat="server" Text="Back" OnClick="btnback6_Click" CausesValidation="false" />
     
            </telerik:RadPageView>
     
            </telerik:RadMultiPage>
     
     
     
     
     
     
     
     
       
     
    <%--    </telerik:RadAjaxPanel>--%>
        </div>
     
    </asp:Content>

    Code Behind:

    Imports System
    Imports System.IO
    Imports Telerik.Web.UI
    Imports System.Web.UI
    Imports Telerik.Web.UI.AsyncUpload
    Imports System.Runtime.Serialization.Json
    Imports System.Web.Services
    Imports System.Runtime.Serialization
    Imports System.Collections.Generic
    Imports System.Drawing
     
    Partial Class HR_HR_employee_details
        Inherits System.Web.UI.Page   
        Const MaxTotalBytes As Integer = 1048576 ' 1 MB
        Private totalBytes As Integer
        Private Shared prevPage As String = String.Empty
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
     
            If Not IsPostBack Then
                prevPage = Request.UrlReferrer.ToString()
     
                If IsNothing(Session("SelectedPID")) Then
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "MessageBox", "alert('Please select a Project.');", True)
                    'rtbMenu.FindItemByValue("New").Enabled = False
                Else
                    'rtbMenu.FindItemByValue("New").Enabled = True
                End If
     
                'Dim lb_panel As Label
                'lb_panel = CType(Master.FindControl("lb_panel"), Label)
                'lb_panel.Text = "Employee Details"
                'Dim photo_path As String = ""
                'Dim CurrentURL As String = ""
                'CurrentURL = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + ResolveUrl("~/")
                'If (Request("EmployeeID") <> "0") Or (Request("EmployeeID") <> "") Or (Not IsNothing(Request("EmployeeID"))) Then
     
                Session.Remove("SelectedEmployeeID")
                Session.Remove("SelectedUserID")
                Session.Remove("TmpFileName")
                'For Employee_license
                Session.Remove("TmpUserID")
                'For Employee_Detail
                Session.Remove("TmpUID_Emp_Detail")
     
                If Request.QueryString("EmployeeID") <> "" And Request.QueryString("EmployeeID") <> "0" Then
                    Dim dc As New dcLRDBDataContext
                    Dim result = (From d In dc.db_Employee_Details Where d.Employee_ID = Request("EmployeeID") Select d).FirstOrDefault
                    Dim result2 = (From d In dc.db_UserDBs Where d.UserID = GetUserIDbyEmployeeID(Request("EmployeeID")) Select d).FirstOrDefault
                    If Not IsNothing(result) Then
     
                        'Bind data
                        HttpContext.Current.Session("SelectedEmployeeID") = result.Employee_ID
                        HttpContext.Current.Session("SelectedUserID") = result.UserID
     
                        tb_addr.Text = result.Address
                        'tb_blood_type.Text = result.Blood_Type
                        If Not IsNothing(result.Blood_Type) Then
                            rbl_blood_type.SelectedValue = result.Blood_Type
                        End If
                        If Not IsNothing(result.Dept_ID) Then
                            tb_dept.Text = result.Dept_ID
                        End If
                        If Not IsNothing(result.Email) Then
                            tb_email.Text = result.Email
                        End If
                        rbl_gender.SelectedValue = result.Gender
     
                        tb_username.Text = result2.username
                        tb_first_name.Text = result.First_Name
     
                        tb_last_name.Text = result.Last_Name
                        tb_display_name.Text = result.Employee_Display_Name
                        If Not IsNothing(result.Location_ID) Then
                            tb_location.Text = result.Location_ID
                        End If
     
                        tb_middle_name.Text = result.Middle_Name
                        If Not IsNothing(result.Phone) Then
                            tb_phone.Text = result.Phone
                        End If
                        If Not IsNothing(result.Point_of_Hire) Then
                            tb_point_of_hire.Text = result.Point_of_Hire
                        End If
     
                        If Not IsNothing(result.Photo) Then
                            RadBinaryImage1.DataValue = result.Photo.ToArray
                        End If
     
                        If Not IsNothing(result.Dept_ID) Then
                            RadDropDownList_dept.SelectedValue = result.Dept_ID
                        End If
                        If Not IsNothing(result.Job_Title_ID) Then
                            RadDropDownList_job_title.SelectedValue = result.Job_Title_ID
                        End If
                        If Not IsNothing(result.Location_ID) Then
                            RadDropDownList_location.SelectedValue = result.Location_ID
                        End If
     
                        If result.Dept_ID > 0 Or Not IsNothing(result.Dept_ID) Then
                            RadDropDownList_supervisor.Enabled = True
                        End If
     
                        If result.Supervisor_UserID > 0 Or Not IsNothing(result.Supervisor_UserID) Then
                            RadDropDownList_supervisor.SelectedValue = result.Supervisor_UserID
                            'RadDropDownList_supervisor.Enabled = True
                        Else
                            RadDropDownList_supervisor.SelectedValue = RadDropDownList_supervisor.DefaultMessage
                            ' RadDropDownList_supervisor.Enabled = False
                        End If
     
                        tb_notes.Text = result.Notes
                        Tb_prior_exp.Text = result.Prior_Exp
                        RadDatePicker_birthday.SelectedDate = result.Date_of_Birth.ToString
                        RadDatePicker_start_date.SelectedDate = result.Start_date.ToString
                        If Not IsNothing(result.End_date) Then
                            RadDatePicker_end_date.SelectedDate = result.End_date.ToString
                        End If
     
                        'tb_roletype.Text = GetRoleTypeArrayByUserID(Request("EmployeeID")).Item(0).ToString
     
                        'Enable button
                        rtbMenu.FindItemByValue("Save").Enabled = False
                        rtbMenu.FindItemByValue("Edit").Enabled = True
                        rtbMenu.FindItemByValue("SIMPER").Enabled = True
                        rtbMenu.FindItemByValue("Delete").Enabled = True
                    End If
                Else 'New Record
                    'rtbMenu.FindItemByValue("New").Enabled = False
                    rtbMenu.FindItemByValue("Cancel").Visible = True
                    rtbMenu.FindItemByValue("Back").Visible = False
                    rtbMenu.FindItemByValue("Save").Enabled = True
                    rtbMenu.FindItemByValue("Search").Enabled = False
                    rtbMenu.FindItemByValue("Edit").Enabled = False
                    rtbMenu.FindItemByValue("SIMPER").Enabled = False
                    rtbMenu.FindItemByValue("Delete").Visible = False
                    'Panel_content.Enabled = True
                    Panel_personal.Enabled = True
                    Panel_job.Enabled = True
                    Panel_License.Enabled = True
                    Panel_others.Enabled = True
     
                    'Organization.Insert(0,new ListItem("--Select--","0"));
                    'RadDropDownList_dept.Items.Add(0, New ListItem("--Select--", "0"))
                    'RadDropDownList_dept.Items.Add(New Telerik.Web.UI.DropDownListItem("--Select--", "0"))
                    'RadDropDownList_job_title.Items.Add(New Telerik.Web.UI.DropDownListItem("--Select--", "0"))
                    'RadDropDownList_supervisor.Items.Add(New Telerik.Web.UI.DropDownListItem("--Select--", "0"))
                    'RadDropDownList_location.Items.Add(New Telerik.Web.UI.DropDownListItem("--Select--", "0"))
     
                End If
     
            End If
        End Sub
     
        Protected Sub RadGrid_License_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid_License.ItemCommand
     
            If e.CommandName = RadGrid.InitInsertCommandName Then   'Click Add New Record button           
                Dim editColumn As GridEditCommandColumn = CType(RadGrid_License.MasterTableView.GetColumn("EditCommandColumn"), GridEditCommandColumn)
                editColumn.Visible = False
            ElseIf (e.CommandName = RadGrid.RebindGridCommandName AndAlso e.Item.OwnerTableView.IsItemInserted) Then
                e.Canceled = True
            Else
                Dim editColumn As GridEditCommandColumn = CType(RadGrid_License.MasterTableView.GetColumn("EditCommandColumn"), GridEditCommandColumn)
                If Not editColumn.Visible Then  'Click Cancel button (both Insert and Update mode)
                    editColumn.Visible = True
                End If
     
                Dim ddlLicense_id As RadDropDownList = DirectCast(e.Item.FindControl("rdl_license_type"), RadDropDownList)
                Dim txtLicense_Number As TextBox = DirectCast(e.Item.FindControl("tb_License_Number"), TextBox)
                Dim txtLicense_Issuer As TextBox = DirectCast(e.Item.FindControl("tb_License_Issuer"), TextBox)
                Dim dateIssue As RadDatePicker = DirectCast(e.Item.FindControl("IssueDatePicker"), RadDatePicker)
                Dim dateValidFrom As RadDatePicker = DirectCast(e.Item.FindControl("RadDatePicker_ValidFrom"), RadDatePicker)
                Dim dateValidTill As RadDatePicker = DirectCast(e.Item.FindControl("RadDatePicker_ValidTill"), RadDatePicker)
                Dim dc As New dcLRDBDataContext
     
                ' If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then
     
                If e.CommandName = "PerformInsert" Then
     
                    If Request.QueryString("EmployeeID") = "" Then  'New Employee
                        Dim rnd As New Random()
                        Dim tmpUserID As Integer 'allow 10 digit only
                        tmpUserID = rnd.Next(100000, 999999) & DateTime.Now.Hour & DateTime.Now.Minute
                        HttpContext.Current.Session("tmpUserID") = tmpUserID
     
                        dc.insertEmployeeLicense(tmpUserID.ToString, ddlLicense_id.SelectedValue, txtLicense_Number.Text.Trim, txtLicense_Issuer.Text.Trim, _
                                                   dateIssue.SelectedDate, dateValidFrom.SelectedDate, dateValidTill.SelectedDate, "Y", DateTime.Now, HttpContext.Current.Session("UserID").ToString)
     
                    Else
                        dc.insertEmployeeLicense(GetUserIDbyEmployeeID(Request.QueryString("EmployeeID")).ToString, ddlLicense_id.SelectedValue, txtLicense_Number.Text.Trim, txtLicense_Issuer.Text.Trim, _
                                                   dateIssue.SelectedDate, dateValidFrom.SelectedDate, dateValidTill.SelectedDate, "N", DateTime.Now, HttpContext.Current.Session("UserID").ToString)
                    End If
                    RadGrid_License.DataBind()
                ElseIf e.CommandName = "Update" Then
                    Dim lid As Integer = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("License_To_Operate_ID")
                    Dim uid As Integer
                    If Request.QueryString("EmployeeID") = "" Then
                        uid = HttpContext.Current.Session("tmpUserID").ToString
                    Else
                        uid = GetUserIDbyEmployeeID(Request.QueryString("EmployeeID")).ToString
                    End If
     
                    Dim rec = (From p In dc.db_Employee_Licenses Where p.UserID = uid And p.License_To_Operate_ID = lid).FirstOrDefault
                    If Not rec Is Nothing Then
                        rec.License_ID = ddlLicense_id.SelectedValue
                        rec.License_Number = txtLicense_Number.Text.Trim
                        rec.License_Issuer = txtLicense_Issuer.Text.Trim
                        rec.Issue_date = dateIssue.SelectedDate
                        rec.Valid_From = dateValidFrom.SelectedDate
                        rec.Valid_Till = dateValidTill.SelectedDate
                        rec.LastUpdateBy = HttpContext.Current.Session("UserID")
                        rec.LastUpdateDate = DateTime.Now
                        dc.SubmitChanges()
                    End If
                    RadGrid_License.DataBind()
                ElseIf e.CommandName = "Delete" Then
                    Dim lid As Integer = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("License_To_Operate_ID")
                    Dim uid As Integer
                    If Request.QueryString("EmployeeID") = "" Then
                        uid = HttpContext.Current.Session("tmpUserID").ToString
                    Else
                        uid = GetUserIDbyEmployeeID(Request.QueryString("EmployeeID")).ToString
                    End If
                    Dim rec2 = (From p In dc.db_Employee_Licenses Where p.UserID = uid And p.License_To_Operate_ID = lid).FirstOrDefault
                    If Not IsNothing(rec2) Then
                        dc.db_Employee_Licenses.DeleteOnSubmit(rec2)
                        dc.SubmitChanges()
                    End If
                    RadGrid_License.DataBind()
                End If
                'End If
     
                dc.Dispose()
            End If
        End Sub
        Private Sub RadGrid_License_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid_License.ItemDataBound
            'If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then
            '    Dim item As GridEditableItem = e.Item
            '    'access/modify the edit item template settings here
            '    Dim list As RadDropDownList = item.FindControl("rdl_license_type")
            '    'list.DataSource = Country_values
            '    'list.DataBind()
            '    If (Not HttpContext.Current.Session("updatedValue") Is Nothing) Then
            '        list.SelectedValue = 2
            '        'HttpContext.Current.Session("updatedValue")
            '    End If
            'ElseIf (TypeOf e.Item Is GridDataItem AndAlso Not e.Item.IsInEditMode AndAlso Page.IsPostBack) Then
            '    Dim item As GridDataItem = e.Item
            '    Dim label As Label = item.FindControl("Lb_License_ID")
     
            '    'update the label value
            '    label.Text = HttpContext.Current.Session("updatedValue")
            'End If
     
            If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then
                Dim item As GridEditableItem = e.Item
                Dim ddl As RadDropDownList = item.FindControl("rdl_license_type")
                ddl.SelectedValue = DataBinder.Eval(e.Item.DataItem, "License_ID").ToString
            End If
     
     
        End Sub
     
        Protected Sub RadGrid_License_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid_License.PreRender
            If (Not Page.IsPostBack) Then
                RadGrid_License.EditIndexes.Add(0)
                RadGrid_License.Rebind()
            End If
        End Sub
     
        Protected Sub RadGrid_License_ItemDeleted(ByVal source As Object, ByVal e As Telerik.Web.UI.GridDeletedEventArgs) Handles RadGrid_License.ItemDeleted
            If Not e.Exception Is Nothing Then
                e.ExceptionHandled = True
                'DisplayMessage(True, "Employee " + e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("EmployeeID").ToString() + " cannot be deleted. Reason: " + e.Exception.Message)
            Else
                'DisplayMessage(False, "Employee " + e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("EmployeeID").ToString() + " deleted")
            End If
        End Sub
     
        Protected Sub RadGrid_License_ItemUpdated(ByVal source As Object, ByVal e As Telerik.Web.UI.GridUpdatedEventArgs) Handles RadGrid_License.ItemUpdated
            If Not e.Exception Is Nothing Then
                e.KeepInEditMode = True
                e.ExceptionHandled = True
                'DisplayMessage(True, "Employee " + e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("EmployeeID").ToString() + " cannot be updated. Reason: " + e.Exception.Message)
     
            Else
     
                'DisplayMessage(False, "Employee " + e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("EmployeeID").ToString() + " updated")
                'If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then
                '    Dim item As GridEditableItem = e.Item
                '    Dim dc As New dcLRDBDataContext
                '    Dim rec = (From p In dc.db_Employee_Licenses Where p.License_To_Operate_ID = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("License_To_Operate_ID").ToString()).FirstOrDefault
     
                '    Dim ddl As RadDropDownList = item.FindControl("rdl_license_type")
                '    'ddl.SelectedValue = DataBinder.Eval(e.Item.DataItem, "License_ID").ToString
     
                '    Dim tb_License_Number As TextBox = item.FindControl("tb_License_Number")
                '    Dim tb_License_Issuer As TextBox = item.FindControl("tb_License_Issuer")
                '    Dim IssueDatePicker As RadDatePicker = item.FindControl("IssueDatePicker")
                '    Dim RadDatePicker_ValidFrom As RadDatePicker = item.FindControl("RadDatePicker_ValidFrom")
                '    Dim RadDatePicker_ValidTill As RadDatePicker = item.FindControl("RadDatePicker_ValidTill")
     
                '    If Not rec Is Nothing Then
                '        rec.License_Number = tb_License_Number.Text
                '        rec.License_Issuer = tb_License_Issuer.Text
                '        rec.License_ID = ddl.SelectedValue
                '        rec.Valid_From = RadDatePicker_ValidFrom.SelectedDate
                '        rec.Valid_Till = RadDatePicker_ValidTill.SelectedDate
                '        rec.Issue_date = IssueDatePicker.SelectedDate
                '        dc.SubmitChanges()
                '    End If
                '    dc.Dispose()
                'End If
            End If
        End Sub
     
        Protected Sub RadGrid_License_ItemInserted(ByVal source As Object, ByVal e As Telerik.Web.UI.GridInsertedEventArgs) Handles RadGrid_License.ItemInserted
            If Not e.Exception Is Nothing Then
                e.ExceptionHandled = True
                e.KeepInInsertMode = True
                'DisplayMessage(True, "Employee cannot be inserted. Reason: " + e.Exception.Message)
            Else
                'DisplayMessage(False, "Employee inserted")
            End If
        End Sub
     
        Protected Sub RoleType_ServerValidation(ByVal source As Object, ByVal args As ServerValidateEventArgs)
            args.IsValid = CheckBoxList_RoleType.SelectedItem IsNot Nothing
        End Sub
     
        Protected Sub Language_ServerValidation(ByVal source As Object, ByVal args As ServerValidateEventArgs)
            args.IsValid = CheckBoxList_Language.SelectedItem IsNot Nothing
        End Sub
     
        Protected Sub rtbMenu_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles rtbMenu.ButtonClick
            If e.Item.Value = "New" Then
                Response.Redirect("~/HR/HR_employee_details.aspx")
            ElseIf e.Item.Value = "Home" Then
                Response.Redirect("~/HR/HR_employee.aspx")
            ElseIf e.Item.Value = "Search" Then
                Response.Redirect("~/HR/HR_employee_search.aspx")
            ElseIf e.Item.Value = "SIMPER" Then
                Response.Redirect("~/TrainingAdmin/SIMPER_details.aspx?UserID=" & GetUserIDbyEmployeeID(Request.QueryString("EmployeeID")))
            ElseIf e.Item.Value = "Save" Then
     
                'Existing Record
                If Request.QueryString("EmployeeID") <> "" And Request.QueryString("EmployeeID") > 0 Then
     
                    SaveEmpDetail(Request.QueryString("EmployeeID"))
     
                Else    'New
     
                    If CheckDuplicate() = False Then
     
     
     
                        'All new record
     
                        'insert into db_UserDB and retrieve UserID
                        Dim dc1 As New dcLRDBDataContext
                        Dim newRecord1 As New db_UserDB
                        Dim uid As Integer
                        Dim eid As Integer
     
                        dc1.db_UserDBs.InsertOnSubmit(newRecord1)
                        newRecord1.username = tb_username.Text.Trim.ToLower                   
                        newRecord1.Disabled = "0"
                        newRecord1.LastUpdateDate = DateTime.Now
                        newRecord1.LastUpdateBy = HttpContext.Current.Session("UserID")
                        dc1.SubmitChanges()
                        uid = newRecord1.UserID
                        dc1.ResetUserPassword(uid, "pass", 0, DateTime.Now, HttpContext.Current.Session("UserID"))
                        dc1.Dispose()
                        'insert into db_UserProject
                        Dim dc2 As New dcLRDBDataContext
                        Dim newRecord2 As New db_UserProject
                        dc2.db_UserProjects.InsertOnSubmit(newRecord2)
                        newRecord2.UserID = uid
                        newRecord2.ProjectID = HttpContext.Current.Session("SelectedPID").ToString
                        newRecord2.LastUpdateDate = DateTime.Now
                        newRecord2.LastUpdateBy = HttpContext.Current.Session("UserID")
                        dc2.SubmitChanges()
                        dc2.Dispose()
     
                        'insert into db_employee_details
                        Dim dc As New dcLRDBDataContext
                        Dim newRecord As New db_Employee_Detail
                        dc.db_Employee_Details.InsertOnSubmit(newRecord)
                        newRecord.UserID = uid
                        newRecord.Last_Name = tb_last_name.Text
                        newRecord.Middle_Name = tb_middle_name.Text
                        newRecord.First_Name = tb_first_name.Text
                        newRecord.Employee_Display_Name = tb_display_name.Text
                        newRecord.Gender = rbl_gender.SelectedValue
     
                        newRecord.Date_of_Birth = RadDatePicker_birthday.SelectedDate
                        'newRecord.Blood_Type = tb_blood_type.Text
                        If rbl_blood_type.SelectedValue <> "" Then
                            newRecord.Blood_Type = rbl_blood_type.SelectedValue
                        End If
     
                        If tb_email.Text <> "" Then
                            newRecord.Email = tb_email.Text
                        End If
                        If tb_phone.Text <> "" Then
                            newRecord.Phone = tb_phone.Text
                        End If
                        If tb_addr.Text <> "" Then
                            newRecord.Address = tb_addr.Text
                        End If
                        If RadDropDownList_location.SelectedValue <> "" Then
                            newRecord.Location_ID = RadDropDownList_location.SelectedValue
                        End If
                        If RadDropDownList_dept.SelectedValue <> "" Then
                            newRecord.Dept_ID = RadDropDownList_dept.SelectedValue
                        End If
                        If RadDropDownList_job_title.SelectedValue <> "" Then
                            newRecord.Job_Title_ID = RadDropDownList_job_title.SelectedValue
                        End If
                        If tb_point_of_hire.Text <> "" Then
                            newRecord.Point_of_Hire = tb_point_of_hire.Text
                        End If
                        newRecord.Start_date = RadDatePicker_start_date.SelectedDate
                        If Not IsNothing(RadDatePicker_end_date.SelectedDate) Then
                            newRecord.End_date = RadDatePicker_end_date.SelectedDate
                        End If
                        If tb_notes.Text <> "" Then
                            newRecord.Notes = tb_notes.Text
                        End If
     
                        newRecord.LastUpdateDate = DateTime.Now
                        newRecord.LastUpdateBy = HttpContext.Current.Session("UserID")
     
                        If Tb_prior_exp.Text <> "" Then
                            newRecord.Prior_Exp = Tb_prior_exp.Text
                        End If
     
                        If RadDropDownList_supervisor.SelectedValue <> "" Then
                            newRecord.Supervisor_UserID = RadDropDownList_supervisor.SelectedValue
                        End If
                        dc.SubmitChanges()
                        eid = newRecord.Employee_ID
     
                        'Insert RoleType
                        For i = 0 To CheckBoxList_RoleType.Items.Count - 1
                            If CheckBoxList_RoleType.Items(i).Selected = True Then
                                dc.insertRoleType(HttpContext.Current.Session("SelectedPID").ToString, CheckBoxList_RoleType.Items(i).Value.ToString, uid, DateTime.Now, HttpContext.Current.Session("UserID").ToString)
                            End If
                        Next
     
                        'insert language
                        For i = 0 To CheckBoxList_Language.Items.Count - 1
                            If CheckBoxList_Language.Items(i).Selected = True Then
                                dc.insertLanguage(CheckBoxList_Language.Items(i).Value.ToString, uid, DateTime.Now, HttpContext.Current.Session("UserID").ToString)
                            End If
                        Next
     
                        'insert ability
                        For i = 0 To CheckBoxList_Ability.Items.Count - 1
                            If CheckBoxList_Ability.Items(i).Selected = True Then
                                dc.insertAbility(CheckBoxList_Ability.Items(i).Value.ToString, uid, DateTime.Now, HttpContext.Current.Session("UserID").ToString)
                            End If
                        Next
     
                        If Not HttpContext.Current.Session("TmpFileName") Is Nothing Then
                            'rename tmpphoto
                            Dim tmpfile As String = Server.MapPath("..") & "\StaffPhoto\" & HttpContext.Current.Session("TmpFileName").ToString
                            Dim destfile As String = Server.MapPath("..") & "\StaffPhoto\" & eid & ".jpg"
     
                            System.IO.File.Move(tmpfile, destfile)
                        End If
     
                        If Request.QueryString("EmployeeID") = "" Then
                            If Not Session("TmpUserID") Is Nothing Then
                                'Update tmpuserid to userid
                                dc.updateEmployeeLicense(uid, HttpContext.Current.Session("TmpUserID").ToString, DateTime.Now, HttpContext.Current.Session("UserID").ToString)
                            End If
                        End If
     
                        'Had insert photo to db_employee_detail before click SAVE (already had a EmployeeID)
                        If Not Session("TmpUID_Emp_Detail") Is Nothing Then
                            dc.CopyEmployeeTmpPhoto(eid, HttpContext.Current.Session("TmpUID_Emp_Detail").ToString)
                        End If
     
     
     
                        dc.Dispose()
     
                        lb_message.Text = "User created successfully."
                        lb_message.Visible = True
     
                        rtbMenu.FindItemByValue("Edit").Enabled = True
                        rtbMenu.FindItemByValue("Save").Enabled = False
                        rtbMenu.FindItemByValue("Cancel").Visible = False
                        rtbMenu.FindItemByValue("Back").Visible = True
                        rtbMenu.FindItemByValue("Delete").Enabled = True
                        'rtbMenu.FindItemByValue("New").Enabled = True
                        rtbMenu.FindItemByValue("Search").Enabled = True
                        'Panel_content.Enabled = False
                        Panel_personal.Enabled = False
                        Panel_job.Enabled = False
                        Panel_License.Enabled = False
                        Panel_others.Enabled = False
     
                        If Not Session("TmpUID_Emp_Detail") Is Nothing Then
                            'remove tmp record from
                            Dim dc4 As New dcLRDBDataContext
                            dc4.deleteTmpPhoto(HttpContext.Current.Session("TmpUID_Emp_Detail").ToString)
                        End If
     
                        Response.Redirect("~/HR/HR_employee.aspx")
     
                    Else
                        lb_message.Text = "Username already exists."
                        lb_message.Visible = True
                    End If
     
                End If
                tb_username.Enabled = False
     
            ElseIf e.Item.Value = "Back" Then
                Response.Redirect(prevPage)
            ElseIf e.Item.Value = "Cancel" Then
     
                If Request.QueryString("EmployeeID") = "" Then
                    If Not Session("TmpUserID") Is Nothing Then
                        'remove tmp record from
                        Dim dc As New dcLRDBDataContext
                        dc.deleteEmployeeLicense(HttpContext.Current.Session("TmpUserID").ToString)
                    End If
                    If Not Session("TmpUID_Emp_Detail") Is Nothing Then
                        'remove tmp record from
                        Dim dc As New dcLRDBDataContext
                        dc.deleteTmpPhoto(HttpContext.Current.Session("TmpUID_Emp_Detail").ToString)
                    End If
     
                End If
     
                'Panel_content.Enabled = False
                Panel_personal.Enabled = False
                Panel_job.Enabled = False
                Panel_License.Enabled = False
                Panel_others.Enabled = False
     
                rtbMenu.FindItemByValue("Edit").Enabled = True
                rtbMenu.FindItemByValue("Save").Enabled = False
                rtbMenu.FindItemByValue("Cancel").Visible = False
                rtbMenu.FindItemByValue("Back").Visible = True
                'rtbMenu.FindItemByValue("New").Enabled = True
                rtbMenu.FindItemByValue("Search").Enabled = True
                rtbMenu.FindItemByValue("Delete").Enabled = True
                'Response.Redirect("~/HR/HR_employee.aspx")
            ElseIf e.Item.Value = "Edit" Then
                rtbMenu.FindItemByValue("Save").Enabled = True
                rtbMenu.FindItemByValue("Cancel").Visible = True
                rtbMenu.FindItemByValue("Back").Visible = False
                rtbMenu.FindItemByValue("Edit").Enabled = False
                'rtbMenu.FindItemByValue("New").Enabled = False
                rtbMenu.FindItemByValue("Search").Enabled = False
                rtbMenu.FindItemByValue("Delete").Enabled = False
                'Panel_content.Enabled = True
                Panel_personal.Enabled = True
                Panel_job.Enabled = True
                Panel_License.Enabled = True
                Panel_others.Enabled = True
     
                tb_username.Enabled = False
            ElseIf e.Item.Value = "Delete" Then
                If Request.QueryString("EmployeeID") <> "" Then
                    Dim dc As New dcLRDBDataContext
                    Dim i As Integer = 0
     
                    Dim rec = (From p In dc.db_UserDBs Where p.UserID = GetUserIDbyEmployeeID(Request.QueryString("EmployeeID"))).FirstOrDefault
                    If Not IsNothing(rec) Then
                        dc.db_UserDBs.DeleteOnSubmit(rec)
                        dc.SubmitChanges()
                    End If
     
                    Dim rec2 = (From p In dc.db_Employee_Details Where p.UserID = GetUserIDbyEmployeeID(Request.QueryString("EmployeeID"))).FirstOrDefault
                    If Not IsNothing(rec2) Then
                        dc.db_Employee_Details.DeleteOnSubmit(rec2)
                        dc.SubmitChanges()
                    End If
     
                    Dim rec3 = (From p In dc.db_UserProjects Where p.UserID = GetUserIDbyEmployeeID(Request.QueryString("EmployeeID"))).ToList
                    If Not IsNothing(rec3) Then
                        For i = 0 To rec3.Count - 1
                            dc.deleteUserProject(rec3.Item(i).UP_ID)
                        Next
                        dc.SubmitChanges()
                    End If
     
                    Dim rec4 = (From p In dc.db_UserRoles Where p.UserID = GetUserIDbyEmployeeID(Request.QueryString("EmployeeID"))).Count
                    If rec4 > 0 Then
                        dc.deleteUserRole(GetUserIDbyEmployeeID(Request.QueryString("EmployeeID")))
                        dc.SubmitChanges()
                    End If
     
                    Dim rec5 = (From p In dc.db_Employee_Languages Where p.User_ID = GetUserIDbyEmployeeID(Request.QueryString("EmployeeID"))).Count
                    If rec5 > 0 Then
                        dc.deleteEmployeeLanguage(GetUserIDbyEmployeeID(Request.QueryString("EmployeeID")))
                        dc.SubmitChanges()
                    End If
     
                    Dim rec6 = (From p In dc.db_Employee_Abilities Where p.User_ID = GetUserIDbyEmployeeID(Request.QueryString("EmployeeID"))).Count
                    If rec6 > 0 Then
                        dc.deleteEmployeeAbility(GetUserIDbyEmployeeID(Request.QueryString("EmployeeID")))
                        dc.SubmitChanges()
                    End If
     
                    Dim rec7 = (From p In dc.db_Employee_Licenses Where p.UserID = GetUserIDbyEmployeeID(Request.QueryString("EmployeeID"))).Count
                    If rec7 > 0 Then
                        dc.deleteEmployeeLicense_All(GetUserIDbyEmployeeID(Request.QueryString("EmployeeID")))
                        dc.SubmitChanges()
                    End If
     
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "MessageBox", "alert('User deleted successfully.');", True)
                    Response.Redirect("~/HR/HR_employee.aspx")
     
                End If
            End If
        End Sub
        Protected Sub FileUploaded() Handles RadAsyncUpload1.FileUploaded
            Dim dc As New dcLRDBDataContext
     
            If Request.QueryString("EmployeeID") <> "" Then
                For Each file As UploadedFile In RadAsyncUpload1.UploadedFiles
                    Dim rec = (From p In dc.db_Employee_Details Where p.Employee_ID = Request.QueryString("EmployeeID")).FirstOrDefault
                    If Not rec Is Nothing Then
                        Dim bytes As Byte() = New Byte(file.ContentLength - 1) {}
                        file.InputStream.Read(bytes, 0, file.ContentLength)                   
                        rec.Photo = bytes
                        RadBinaryImage1.DataValue = bytes
                        RadBinaryImage1.Width = 100
                        RadBinaryImage1.ResizeMode = BinaryImageResizeMode.Fit
                        dc.SubmitChanges()
                    End If
                Next
     
            Else
                Dim newRecord As New db_TmpPhoto
                For Each file As UploadedFile In RadAsyncUpload1.UploadedFiles
                    Dim bytes As Byte() = New Byte(file.ContentLength - 1) {}
                    file.InputStream.Read(bytes, 0, file.ContentLength)
                    newRecord.Photo = bytes
                    newRecord.Type = "Staff"
                    RadBinaryImage1.DataValue = bytes
                    RadBinaryImage1.Width = 100
                    RadBinaryImage1.ResizeMode = BinaryImageResizeMode.Fit
                    dc.db_TmpPhotos.InsertOnSubmit(newRecord)
                    dc.SubmitChanges()
                    HttpContext.Current.Session("TmpUID_Emp_Detail") = newRecord.ID
                Next
     
            End If
        End Sub
     
        Public Function ResizeImage(ByVal stream As IO.Stream) As Bitmap
            Dim originalImage As System.Drawing.Image = Bitmap.FromStream(stream)
            Dim height As Integer = 331
            Dim width As Integer = 495
            Dim scaledImage As New Bitmap(width, height)
            Using g As Graphics = Graphics.FromImage(scaledImage)
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
                g.DrawImage(originalImage, 0, 0, width, height)
                g.DrawString("Employee Photo ", New Font("Tahoma", 18), Brushes.White, New PointF(0, 0))
                Return scaledImage
            End Using
        End Function
     
        Protected Sub CheckBoxList_Language_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBoxList_Language.DataBound
            If Request.QueryString("EmployeeID") <> "" Then
     
                Dim results As IEnumerable = GetLanguageArrayByUserID(GetUserIDbyEmployeeID(HttpContext.Current.Session("SelectedEmployeeID")))
                Dim chkstr As String = ""
                For Each item In results
                    For Each cb As ListItem In CheckBoxList_Language.Items
                        If Trim(item.ToString).Contains(cb.Text) Then
                            If Trim(item.ToString).Contains("YES") Then
                                cb.Selected = True
                            End If
                        End If
                    Next
                Next
            End If
        End Sub
     
        Protected Sub CheckBoxList_Ability_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBoxList_Ability.DataBound
            If Request.QueryString("EmployeeID") <> "" Then
     
                Dim results As IEnumerable = GetAbilityArrayByUserID(GetUserIDbyEmployeeID(HttpContext.Current.Session("SelectedEmployeeID")))
                Dim chkstr As String = ""
                For Each item In results
                    For Each cb As ListItem In CheckBoxList_Ability.Items
                        If Trim(item.ToString).Contains(cb.Text) Then
                            If Trim(item.ToString).Contains("YES") Then
                                cb.Selected = True
                            End If
                        End If
                    Next
                Next
            End If
        End Sub
     
        Protected Sub CheckBoxList_RoleType_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBoxList_RoleType.DataBound
            If Request.QueryString("EmployeeID") <> "" Then
                Dim rList = Split(GetRoleTypeIDByUserID(GetUserIDbyEmployeeID(Request.QueryString("EmployeeID"))), ",")
                Dim i As Integer = 0
                Dim j As Integer = 0
                Dim chkboxlb As CheckBoxList
                chkboxlb = DirectCast(FindControl("CheckBoxList_RoleType"), CheckBoxList)
     
                'Dim results As IEnumerable = ODS_RoleType.[Select]()
                Dim results As IEnumerable = GetRoleTypeArrayByUserID(GetUserIDbyEmployeeID(HttpContext.Current.Session("SelectedEmployeeID")))
                'Dim chkstr As String = "HaveRight=" + Chr(34) + "Y" + Chr(34)
                Dim chkstr As String = ""
                For Each item In results
                    For Each cb As ListItem In CheckBoxList_RoleType.Items
                        'If item.Value("HaveRight") = "Y" Then
                        '    cb.Selected = True
                        'End If
                        'chkstr = item.ToString
                        If Trim(item.ToString).Contains(cb.Text) Then
                            If Trim(item.ToString).Contains("YES") Then
                                cb.Selected = True
                            End If
                        End If
                    Next
                Next
     
                'For Each item As ListItem In Me.CheckBoxList_RoleType.Items
                '    If item.Value("HaveRight") = "Y" Then
                '        item.Selected = True
                '    End If
                'Next
     
                ''For j = 0 To chkboxlb.Items.Count - 1
                ''    For i = 0 To rList.Length - 1
                ''        If rList(i).ToString = chkboxlb.DataValueField(j) Then
                ''            chkboxlb.Items(j).Selected = True
                ''        End If
                ''    Next
                ''Next
            End If
        End Sub
        Private Function CheckDuplicate() As Boolean
            Dim dc As New dcLRDBDataContext
            Dim rec = (From u In dc.db_UserDBs Where u.username = tb_username.Text.Trim.ToLower And u.Disabled = 0)
            If Not rec Is Nothing Then
                If rec.Count > 0 Then
                    Return True
                Else
                    Return False
                End If
            Else
                Return False
            End If
            dc.Dispose()
        End Function
     
        Protected Sub tb_username_OnTextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tb_username.TextChanged
     
            If CheckDuplicate() = True Then
                lb_message.Text = "Username already exists. Please assign another username"
                lb_message.Visible = True
            Else
                lb_message.Text = ""
                lb_message.Visible = False
            End If
     
        End Sub
     
        Protected Sub RadDropDownList_dept_OnSelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadDropDownList_dept.SelectedIndexChanged
     
            '        If RadDropDownList_dept.SelectedText <> RadDropDownList_dept.DefaultMessage And RadDropDownList_dept.SelectedText <> "" And RadDropDownList_supervisor.Enabled = False Then
            RadDropDownList_supervisor.Enabled = True
            RadDropDownList_supervisor.ClearSelection()
            RadDropDownList_supervisor.SelectedText = RadDropDownList_supervisor.DefaultMessage
            RadDropDownList_supervisor.DataBind()
            'End If
        End Sub
     
        Public Sub SaveEmpDetail(ByVal EID As Integer)
     
            Dim dc As New dcLRDBDataContext
            Dim rec = (From p In dc.db_Employee_Details Where p.Employee_ID = EID).FirstOrDefault
            If Not rec Is Nothing Then
                rec.Last_Name = tb_last_name.Text
                rec.Middle_Name = tb_middle_name.Text
                rec.First_Name = tb_first_name.Text
                rec.Employee_Display_Name = tb_display_name.Text
                rec.Gender = rbl_gender.SelectedValue
                rec.Date_of_Birth = RadDatePicker_birthday.SelectedDate
                'rec.Blood_Type = tb_blood_type.Text
                If rbl_blood_type.SelectedValue <> "" Then
                    rec.Blood_Type = rbl_blood_type.SelectedValue
                End If
                If tb_email.Text <> "" Then
                    rec.Email = tb_email.Text
                End If
                If tb_phone.Text <> "" Then
                    rec.Phone = tb_phone.Text
                End If
                If tb_addr.Text <> "" Then
                    rec.Address = tb_addr.Text
                End If
                If RadDropDownList_location.SelectedValue <> "" Then
                    rec.Location_ID = RadDropDownList_location.SelectedValue
                End If
                If RadDropDownList_dept.SelectedValue <> "" Then
                    rec.Dept_ID = RadDropDownList_dept.SelectedValue
                End If
                If RadDropDownList_job_title.SelectedValue <> "" Then
                    rec.Job_Title_ID = RadDropDownList_job_title.SelectedValue
                End If
                If Tb_prior_exp.Text <> "" Then
                    rec.Prior_Exp = Tb_prior_exp.Text
                End If
     
                If RadDropDownList_supervisor.SelectedValue <> "" Then
                    rec.Supervisor_UserID = RadDropDownList_supervisor.SelectedValue
                End If
                If tb_point_of_hire.Text <> "" Then
                    rec.Point_of_Hire = tb_point_of_hire.Text
                End If
     
                rec.Start_date = RadDatePicker_start_date.SelectedDate
                If Not IsNothing(RadDatePicker_end_date.SelectedDate) Then
                    rec.End_date = RadDatePicker_end_date.SelectedDate
                End If
                If tb_notes.Text <> "" Then
                    rec.Notes = tb_notes.Text
                End If
     
                rec.LastUpdateDate = DateTime.Now
                rec.LastUpdateBy = HttpContext.Current.Session("UserID")
                dc.SubmitChanges()
            End If
     
            Dim dc2 As New dcLRDBDataContext
            For i = 0 To CheckBoxList_RoleType.Items.Count - 1
                Dim chb_value As String = ""
                If CheckBoxList_RoleType.Items(i).Selected = True Then  'checkbox checked
                    chb_value = CheckBoxList_RoleType.Items(i).Value.ToString
                    Dim rec2 = (From p In dc2.db_UserRoles Where p.UserID = GetUserIDbyEmployeeID(EID).ToString And p.RoleTypeID = chb_value And p.ProjectID = HttpContext.Current.Session("SelectedPID").ToString).FirstOrDefault
                    If IsNothing(rec2) Then 'not exist
                        Dim newRecord2 As New db_UserRole
                        dc2.db_UserRoles.InsertOnSubmit(newRecord2)
                        newRecord2.RoleTypeID = chb_value
                        newRecord2.UserID = GetUserIDbyEmployeeID(EID).ToString
                        newRecord2.ProjectID = HttpContext.Current.Session("SelectedPID").ToString
     
                        newRecord2.CreateDate = DateTime.Now
                        newRecord2.CreateBy = HttpContext.Current.Session("UserID")
     
                        newRecord2.LastUpdateDate = DateTime.Now
                        newRecord2.LastupdateBy = HttpContext.Current.Session("UserID")
                        dc2.SubmitChanges()
                    End If
                Else    'checkbox unchecked
                    chb_value = CheckBoxList_RoleType.Items(i).Value.ToString
                    Dim rec2 = (From p In dc2.db_UserRoles Where p.UserID = GetUserIDbyEmployeeID(EID).ToString And p.RoleTypeID = chb_value And p.ProjectID = HttpContext.Current.Session("SelectedPID").ToString).FirstOrDefault
                    If Not IsNothing(rec2) Then 'exists in db, but user uncheck, need delete
                        dc2.db_UserRoles.DeleteOnSubmit(rec2)
                        dc2.SubmitChanges()
                    End If
                End If
            Next
     
            For i = 0 To CheckBoxList_Language.Items.Count - 1
                Dim chb_value As String = ""
                If CheckBoxList_Language.Items(i).Selected = True Then  'checkbox checked
                    chb_value = CheckBoxList_Language.Items(i).Value.ToString
                    Dim rec2 = (From p In dc2.db_Employee_Languages Where p.User_ID = GetUserIDbyEmployeeID(EID).ToString And p.Language_ID = chb_value).FirstOrDefault
                    If IsNothing(rec2) Then 'not exist
                        Dim newRecord2 As New db_Employee_Language
                        dc2.db_Employee_Languages.InsertOnSubmit(newRecord2)
                        newRecord2.Language_ID = chb_value
                        newRecord2.User_ID = GetUserIDbyEmployeeID(EID).ToString
     
                        newRecord2.LastUpdateDate = DateTime.Now
                        newRecord2.LastUpdateBy = HttpContext.Current.Session("UserID")
                        dc2.SubmitChanges()
                    End If
                Else    'checkbox unchecked
                    chb_value = CheckBoxList_Language.Items(i).Value.ToString
                    Dim rec2 = (From p In dc2.db_Employee_Languages Where p.User_ID = GetUserIDbyEmployeeID(EID).ToString And p.Language_ID = chb_value).FirstOrDefault
                    If Not IsNothing(rec2) Then 'exists in db, but user uncheck, need delete
                        dc2.db_Employee_Languages.DeleteOnSubmit(rec2)
                        dc2.SubmitChanges()
                    End If
                End If
            Next
     
            For i = 0 To CheckBoxList_Ability.Items.Count - 1
                Dim chb_value As String = ""
                If CheckBoxList_Ability.Items(i).Selected = True Then  'checkbox checked
                    chb_value = CheckBoxList_Ability.Items(i).Value.ToString
                    Dim rec2 = (From p In dc2.db_Employee_Abilities Where p.User_ID = GetUserIDbyEmployeeID(EID).ToString And p.Ability_ID = chb_value).FirstOrDefault
                    If IsNothing(rec2) Then 'not exist
                        Dim newRecord2 As New db_Employee_Ability
                        dc2.db_Employee_Abilities.InsertOnSubmit(newRecord2)
                        newRecord2.Ability_ID = chb_value
                        newRecord2.User_ID = GetUserIDbyEmployeeID(EID).ToString
     
                        newRecord2.LastUpdateDate = DateTime.Now
                        newRecord2.LastUpdateBy = HttpContext.Current.Session("UserID")
                        dc2.SubmitChanges()
                    End If
                Else    'checkbox unchecked
                    chb_value = CheckBoxList_Ability.Items(i).Value.ToString
                    Dim rec2 = (From p In dc2.db_Employee_Abilities Where p.User_ID = GetUserIDbyEmployeeID(EID).ToString And p.Ability_ID = chb_value).FirstOrDefault
                    If Not IsNothing(rec2) Then 'exists in db, but user uncheck, need delete
                        dc2.db_Employee_Abilities.DeleteOnSubmit(rec2)
                        dc2.SubmitChanges()
                    End If
                End If
            Next
     
            dc.Dispose()
            dc2.Dispose()
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "MessageBox", "alert('User details saved successfully.');", True)
            'lb_message.Text = "User details saved successfully."
            lb_message.Visible = True
            lb_message.ForeColor = Drawing.Color.Red
     
            rtbMenu.FindItemByValue("Edit").Enabled = True
            rtbMenu.FindItemByValue("Save").Enabled = False
            rtbMenu.FindItemByValue("Cancel").Enabled = False
            'rtbMenu.FindItemByValue("New").Enabled = True
            rtbMenu.FindItemByValue("Search").Enabled = True
            'Panel_content.Enabled = False
            Panel_personal.Enabled = False
            Panel_job.Enabled = False
     
            Response.AddHeader("REFRESH", "1;URL=HR_employee.aspx")
        End Sub
     
        Protected Sub btnback3_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnback3.Click
            'Response.Redirect(prevPage)
            GoToNextTab("Personal Info.", "Tab_personal")
        End Sub
        Protected Sub btnback4_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnback4.Click
            'Response.Redirect(prevPage)
            GoToNextTab("Job Particulars", "Tab_job")
        End Sub
        Protected Sub btnback5_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnback5.Click
            GoToNextTab("Other Info.", "Tab_Others")
        End Sub
        Protected Sub btnback6_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnback6.Click
            GoToNextTab("License", "Tab_license")
        End Sub
     
        Protected Sub btnStep2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnStep2.Click
            GoToNextTab("Job Particulars", "Tab_job")
        End Sub
     
        Protected Sub btnStep3_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnStep3.Click
            GoToNextTab("Other Info.", "Tab_Others")
        End Sub
     
        Protected Sub btnStep4_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnStep4.Click
            GoToNextTab("License", "Tab_license")
        End Sub
     
        Protected Sub btnStep5_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnStep5.Click
            GoToNextTab("Training Course", "Tab_training")
        End Sub
     
        Private Sub GoToNextTab(ByVal TabText As String, ByVal PageViewID As String)
     
            Dim NextTab As RadTab = RadTabStrip1.FindTabByText(TabText)
            NextTab.Enabled = True
            NextTab.Selected = True
            GoToNextPageView(PageViewID)
     
        End Sub
     
        Private Sub GoToNextPageView(ByVal PageViewID As String)
     
            Dim PageView As RadPageView = RadMultiPage1.FindPageViewByID(PageViewID)
            If PageView Is Nothing Then
                PageView = New RadPageView()
                PageView.ID = PageViewID
                RadMultiPage1.PageViews.Add(PageView)
            End If
            PageView.Selected = True
        End Sub
     
    End Class



  2. Joe
    Joe avatar
    57 posts
    Member since:
    Mar 2013

    Posted 23 Jul 2013 Link to this post

    Finally, i solved my problem that by using ValidationGroup. (for next button)
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top