<%@ page language="VB" autoeventwireup="false" inherits="Manage_DeviceList, App_Web_qcbprguc" enableEventValidation="false" %>
<%@ Register TagPrefix="obout" Namespace="Obout.Grid" Assembly="obout_Grid_NET" %>
<%@ Register TagPrefix="obout" Namespace="OboutInc.Flyout2" Assembly="obout_Flyout2_NET" %>
<%@ Register TagPrefix="uctrl" Src="~/Header.ascx" TagName="header" %>
<%@ Register TagPrefix="owd" Namespace="OboutInc.Window" Assembly="obout_Window_NET" %>
<%@ Register TagPrefix="oem" Namespace="OboutInc.EasyMenu_Pro" Assembly="obout_EasyMenu_Pro" %>
<%@ Register TagPrefix="obout" Namespace="OboutInc.Combobox" Assembly="obout_Combobox_Net" %>

<script type="text/javascript">	
	// Client-Side Events for Delete
	    function OnBeforeDelete(record) 
	        {
	            record.Error='';
		        document.getElementById("<%=Hdn_DeviceId.ClientID %>").value = record.DeviceId;
	            if(confirm("Are you sure you want to delete? "))
	                return true;
	            else
	                return false;
	        }
	
	    function OnDelete(record) 
	    {
	        alert(record.Error);
	    }
    	
	    function OnInsert(record) 
	    {
		    document.getElementById("<%=Lbl_InvalidError.ClientID %>").innerHTML = record.Error;
	    }
	
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <link href="../StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body onload="drp_connectionType_SelectIndexChanges();">
    <form id="form1" runat="server">
        <div>
            <uctrl:header ID="MyHeader" runat="server" />
            <table cellpadding="0" cellspacing="0" style="border-right: gray 1px solid; border-top: gray 1px solid;
                border-left: gray 1px solid; border-bottom: gray 1px solid;">
                <tr style="font-weight: bold; font-size: 14px; background-color: lightsteelblue;
                    padding-left: 5px; padding-top: 3px; padding-bottom: 3px; color: white;">
                    <td style="font-weight: bold; font-size: 14px; background-color: lightsteelblue;padding:5px; color: white; height: 27px;">
                        Devices List
                        </td>
                         <td align="right">&nbsp;&nbsp;
                         Location &nbsp;<asp:DropDownList ID="drp_FilterLocation" runat="server" AutoPostBack="true"> </asp:DropDownList>&nbsp;&nbsp;
                            
                         <input type="button" class="tdText" value="Refresh" onclick="grid_Devices.refresh()" id="btn_Refresh" />
                         </td>
                </tr>
               
                
                  <tr style=" background-color: lightsteelblue;">
                <td colspan="2">
                <hr />
                </td>
                </tr>
                
                <tr>
                    <td colspan="2">
                    <div id="div_Employees">
                        <obout:Grid ID="grid_Devices"  runat="server" CallbackMode="true" EnableRecordHover="true" AllowMultiRecordSelection="true" 
                            KeepSelectedRecords="true" Serialize="true" AllowFiltering="true" AutoGenerateColumns="false"
                            FolderStyle="~/styles/grid/styles/premiere_blue" AllowAddingRecords="true" ShowLoadingMessage="false"
                            OnRebind="RebindGrid" OnInsertCommand="InsertRecord"  OnDeleteCommand="DeleteRecord">
                            <ClientSideEvents OnClientInsert="OnInsert" OnBeforeClientDelete="OnBeforeDelete" OnClientDelete="OnDelete"/>
                            <TemplateSettings NewRecord_TemplateId="tplAddBtn" />
                            <Columns>
                                <obout:Column ID="Column2" DataField="DeviceId" Visible="false" Width="300" HeaderText="DeviceId"
                                    runat="server" />
                                <obout:Column ID="Column1" DataField="DeviceSName" Visible="true" SortOrder="Asc"  Width="115" HeaderText="Device Name"
                                    runat="server" />
                                 <obout:Column ID="Column3" DataField="DeviceFName" Visible="false" Width="350" HeaderText="DeviceFName"
                                    runat="server" />   
                                <obout:Column ID="Column7" DataField="SerialNumber" Visible="true" Width="105" HeaderText="Serial No."
                                    runat="server" />
                                <obout:Column ID="Column8" DataField="DeviceDirection" Visible="true" Width="130" HeaderText="Device Direction"
                                    runat="server" />
                                <obout:Column ID="Column4" DataField="IpAddress" Visible="false" Width="300" HeaderText="IpAddress"
                                    runat="server" />
                                <obout:Column ID="Column5" DataField="ConnectionType" Visible="false" Width="300" HeaderText="ConnectionType"
                                    runat="server" /> 
                                    <obout:Column ID="Column10" DataField="DeviceType" Visible="false"   Width="130" HeaderText="DeviceType" runat="server" >   
                                </obout:Column>
                                 <obout:Column ID="Column11" DataField="TransactionStamp" Visible="true" Width="90" HeaderText="T Stamp"
                                    runat="server" />       
                                <obout:Column ID="Column9" DataField="OpStamp" Visible="true" Width="95" HeaderText="Op Stamp"
                                    runat="server" /> 
                                     <obout:Column ID="Column13" DataField="TimeZone" Visible="true" Width="105" HeaderText="Time Zone"
                                    runat="server" />
                                    <obout:Column ID="Column15" DataField="TimeOut" Visible="false" Width="120" HeaderText="TimeOut"
                                    runat="server" />
                                     <obout:Column ID="Column14" DataField="DeviceLocation" Visible="true"   Width="100" HeaderText="Location" runat="server" >   
                                </obout:Column>
                                
                                 <obout:Column ID="Column6"  Visible="true" Width="130" SortOrder="Asc" HeaderText="Last Ping" runat="server" >   
                                     <TemplateSettings TemplateId="LastPing_Template" />
                                </obout:Column> 
                                 <obout:Column ID="Column12"  Visible="true" Width="100"  HeaderText="Device Status" runat="server" >   
                                     <TemplateSettings TemplateId="DeviceStatus_Template" />
                                </obout:Column> 
                                
                                
                                
                                <obout:Column  Width="135" AllowEdit="false"    AllowDelete="false" Visible="true" ><TemplateSettings TemplateId="tplViewUsersInDeviceBtn" /></obout:Column>
                                <obout:Column HeaderText="Edit" Width="45" AllowEdit="true" AllowDelete="true">
                                    <TemplateSettings TemplateId="tplEditBtn" />
                                </obout:Column>
                                <obout:Column HeaderText="Delete" Width="50" AllowEdit="false" AllowDelete="true"
                                    Visible="true" />
                            </Columns>
                            <Templates>
                                <obout:GridTemplate runat="server" ID="tplEditBtn">
                                    <Template>
                                        <a href="javascript: //" id="grid_link_<%# Container.PageRecordIndex %>" onclick="attachFlyoutToLink(this,'Update')"
                                            class="ob_gAL">Edit</a>
                                    </Template>
                                </obout:GridTemplate>
                                
                                <obout:GridTemplate runat="server" ID="tplAddBtn">
                                    <Template>
                                        <a href="javascript: //" id="btAdd" onclick="attachFlyoutToLink(this,'Add')" class="ob_gAL">
                                            <%#CheckPermissions("Add")%></a>
                                    </Template>
                                </obout:GridTemplate>
                                
                                 <obout:GridTemplate runat="server" ID="tplViewUsersInDeviceBtn">
			                        <Template>
			                        <asp:Hyperlink runat="server" CssClass="ob_gAL" style="cursor:hand;" Text="View Users In Device" NavigateUrl='<%# "~/Manage/DeviceUsers.aspx?DeviceId=" + Container.DataItem.Item("DeviceId")+"&DeviceSName=" + Container.DataItem.Item("DeviceSName")+"&SerialNumber=" + Container.DataItem.Item("SerialNumber")%>' ID="AA1" />
			                        </Template>
			                    </obout:GridTemplate>
			                    
			                    <obout:GridTemplate runat="server" ID="LastPing_Template" ControlID="" ControlPropertyName="">
                                    <Template>
                                        <%#ParseLastPing(Container.DataItem.Item("LastPing"))%>
                                    </Template>
                                </obout:GridTemplate>
                                
                                 <obout:GridTemplate runat="server" ID="DeviceStatus_Template" ControlID="" ControlPropertyName="">
                                    <Template>
                                        <asp:Label ID="Label1" runat="server" Text=  '<%#DeviceStatus(Container.DataItem.Item("LastPing"),Container.DataItem.Item("TimeOut"))%>' ForeColor=<%#ChangeColorOnDeviceStatusCheck(Container.DataItem("LastPing"),Container.DataItem("TimeOut")) %>></asp:Label>
                                    </Template>
                                </obout:GridTemplate>
                                
                                
                            </Templates>
                        </obout:Grid>
                        </div>
                    </td>
                </tr>
            </table>
            
            
            <oem:EasyMenu ID="EasyMenu1" runat="server" StyleFolder="~/styles/EasyMenu/Styles/vsnet"
            IconsFolder="MenuIcons" Width="210" UseIcons="true" AttachTo="div_Employees"
            ShowEvent="ContextMenu" Align="Cursor">
            <Components>
                <oem:MenuItem ID="menuItem4" runat="server"  >
                    <a id="btn_ClearLogsFromDevice" style="width:100%;" href="#" runat="server" onclick="return confirm('Are you sure you want to delete all the logs from device.')" onserverclick="btn_ClearLogsFromDevice_onserverclick" >Clear Logs From Device</a>
                </oem:MenuItem>
                <oem:MenuSeparator ID="menuSeparator2" InnerHtml="&amp;nbsp;" AllowsIcon="true">
                </oem:MenuSeparator>
                
                 <oem:MenuItem ID="btn_ChangeIpAddress" runat="server"  InnerHtml="Change Ip Address" OnClientClick="Wnd_ChangeDeviceDetails_Open('Ip Address');">
                </oem:MenuItem>
                <oem:MenuSeparator ID="menuSeparator3" InnerHtml="&amp;nbsp;" AllowsIcon="true">
                </oem:MenuSeparator>
                
                 <oem:MenuItem ID="menuItem3" runat="server"  >
                    <a id="btn_ResetTransactionStamp"  style="width:100%;" href="#" runat="server" onserverclick="btn_ResetTransactionStamp_onserverclick" >Reset Transaction Stamp</a>
                </oem:MenuItem>
                <oem:MenuSeparator ID="menuSeparator4" InnerHtml="&amp;nbsp;" AllowsIcon="true">
                </oem:MenuSeparator>
                
                 <oem:MenuItem ID="menuItem5" runat="server" >
                    <a id="btn_ResetOpStamp" href="#" style="width:100%;" runat="server" onserverclick="btn_ResetOpStamp_onserverclick" >Reset OpStamp</a>
                </oem:MenuItem>
                <oem:MenuSeparator ID="menuSeparator5" InnerHtml="&amp;nbsp;" AllowsIcon="true">
                </oem:MenuSeparator>
                
                 <oem:MenuItem ID="menuItem6" runat="server" >
                    <a id="A1" href="#" runat="server" style="width:100%;" onserverclick="btn_UploadUsersToDevice_onserverclick" >Upload Users To Device</a>
                </oem:MenuItem>
                <oem:MenuSeparator ID="menuSeparator6" InnerHtml="&amp;nbsp;" AllowsIcon="true">
                </oem:MenuSeparator>
                
                 <oem:MenuItem ID="menuItem7" runat="server"  InnerHtml="Change Card Key" OnClientClick="Wnd_ChangeDeviceDetails_Open('Card Key');">
                </oem:MenuItem>
                <oem:MenuSeparator ID="menuSeparator7" InnerHtml="&amp;nbsp;" AllowsIcon="true">
                </oem:MenuSeparator>
                
                 <oem:MenuItem ID="menuItem8" runat="server"  >
                    <a id="btn_RestartDevice" href="#" style="width:100%;" runat="server" onserverclick="btn_RestartDevice_onserverclick" >Restart Device</a>
                </oem:MenuItem>
                <oem:MenuSeparator ID="menuSeparator8" InnerHtml="&amp;nbsp;" AllowsIcon="true">
                </oem:MenuSeparator>
                
                 <oem:MenuItem ID="menuItem9" runat="server"  InnerHtml="Change SubnetMask" OnClientClick="Wnd_ChangeDeviceDetails_Open('SubnetMask');">
                </oem:MenuItem>
                <oem:MenuSeparator ID="menuSeparator9" InnerHtml="&amp;nbsp;" AllowsIcon="true">
                </oem:MenuSeparator>
                
                 <oem:MenuItem ID="menuItem10" runat="server"  InnerHtml="Change GateWay" OnClientClick="Wnd_ChangeDeviceDetails_Open('GateWay');">
                </oem:MenuItem>
                
                <oem:MenuSeparator ID="menuSeparator1" InnerHtml="&amp;nbsp;" AllowsIcon="true">
                </oem:MenuSeparator>
                
                 <oem:MenuItem ID="menuItem1" runat="server"  InnerHtml="Change WebServerIP" OnClientClick="Wnd_ChangeDeviceDetails_Open('WebServerIP');">
                </oem:MenuItem>
                <oem:MenuSeparator ID="menuSeparator10" InnerHtml="&amp;nbsp;" AllowsIcon="true">
                </oem:MenuSeparator>
                
                 <oem:MenuItem ID="menuItem2" runat="server"  InnerHtml="Change WebServerPort" OnClientClick="Wnd_ChangeDeviceDetails_Open('WebServerPort');">
                </oem:MenuItem>
                
            </Components>
        </oem:EasyMenu>
            
            <obout:Flyout runat="server" ID="Flyout1" Align="left" Position="BOTTOM_left" CloseEvent="NONE"
                OpenEvent="NONE" DelayTime="500">
                <table class="rowEditTable">
                <tr>
                 <td >
                            <fieldset>
                                <legend>Device Information</legend>
                                <table>
                                    <tr>
                                        <td style="font-weight: bold; " >
                                            
                                            Device Name</td>
                                        <td  >
                                            <asp:TextBox ID="txt_DeviceFName" runat="server" ></asp:TextBox>
                                        </td>
                                         <td style="font-weight: bold; " >
                                            Short Name
                                        </td>
                                        <td >
                                            <asp:TextBox ID="txt_DeviceShortName" runat="server"></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="font-weight: bold; " >
                                            Serial Number
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txt_SerialNo" runat="server" ></asp:TextBox>
                                        </td>
                                         <td  align="right">
                                            Connection Type
                                        </td>
                                        <td >
                                        <SELECT id="drp_ConnectionType" runat="server" onchange="drp_connectionType_SelectIndexChanges();" style="width:160px;">
                                            <option selected="selected">Tcp/IP</option>
                                            <option>USB</option>
                                            </SELECT>
                                        </td>
                                    </tr>
                                    
                                    
                                    <tr>
                                       
                                        
                                        <td style="font-weight: bold; " >
                                            
                                            Ip Address
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txt_IpAddress" runat="server"></asp:TextBox>
                                        </td>
                                        
                                        <td >
                                            Device Location</td>
                                        <td >
                                             <obout:Combobox Validate="false" ID="drp_Location" runat="server"  CssClass="WebControls"   FolderStyle="~/styles/default" Width="160"
                                                SelectedIndex="0">
                                            </obout:Combobox>
                                        </td>
                                        
                                        
                                    </tr>
                                    <tr>
                                    
                                       
                                          <td style="font-weight: bold; " >
                                            Time Zone
                                        </td>
                                        <td >
                                            <asp:TextBox ID="txt_TimeZone" runat="server"></asp:TextBox>
                                        </td>
                                         <td style="font-weight: bold; " >
                                            Time Out
                                        </td>
                                        <td  >
                                            <asp:TextBox ID="txt_TimeOut" runat="server" Width="130px"></asp:TextBox>&nbsp;Sec
                                        </td>
                                    </tr>
                                    <tr>
                                     <td>
                                            Device Direction
                                        </td>
                                        <td  colspan="3">
                                        <SELECT id="drp_DeviceDiretion" runat="server"  EnableViewState="true" >
                                            <option selected="selected">In Device</option>
                                            <option>Out Device</option>
                                            <option>Alternate In/Out Device</option>
                                            <option>System Direction(In/Out) Device</option>
                                            </SELECT>
                                        </td>
                                    </tr>
                                    <tr>
                                    <td style="font-weight: bold; " >
                                    Device Type
                                    </td>
                                    <td colspan="3">
                                        <asp:RadioButtonList ID="rbtn_DeviceType" runat="server" RepeatDirection="Horizontal">
                                        <asp:ListItem Selected="True">Attendance</asp:ListItem>
                                        <asp:ListItem>Canteen</asp:ListItem>
                                        <asp:ListItem>Access Control</asp:ListItem>
                                        </asp:RadioButtonList>
                                    </td>
                                    </tr>
                                    
                                </table>
                            </fieldset>
                        </td>
                </tr>
                 <tr>
                        <td align="right" >
                            <input id="btn_Save"  type="button" value="Save" onclick="javascript:btn_Save_onclick();" />&nbsp;&nbsp;&nbsp;&nbsp;<input
                                id="btn_Cancel" type="button" value="Close" onclick="javascript:closeFlyout();" />
                        </td>
                    </tr>
                   
                   <tr>
                        <td >
                            &nbsp; &nbsp; &nbsp;
                            <asp:Label runat="server" foreColor="red" EnableViewState="false" ID="Lbl_InvalidError"></asp:Label>
                            <asp:HiddenField  ID="Hdn_DeviceId" runat="server" />
                            <asp:HiddenField  ID="Hdn_SerialNumber" runat="server" />
                            
                            
                        </td>
                    </tr>
                </table>
            </obout:Flyout>
            
          <owd:Window ID="Wnd_ChangeDeviceDetails" runat="server" IsModal="true" Height="120" Width="330" StyleFolder="~/Styles/mainwindow/blue" Title="Change Device Details" VisibleOnLoad="false" ShowCloseButton="false"  ShowStatusBar="False" Left="450" Top="120">
		    <table class="rowEditTable" width="100%" height="100%">
                    <tr>
                        <td >
                            <fieldset>
                                
                                <table>
                                <tr>
                                <td>
                                    <asp:Label ID="lbl_ChangeName" runat="server" Text="Ip Address"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_ChangeIpAddress" runat="server" Width="200px"></asp:TextBox>
                                </td>
                                </tr>
                                </table>
                                </fieldset>
                                </td>
                                </tr>
                                
                                <tr>
                                <td align="right">
                                    <asp:HiddenField ID="hdn_DeviceComm" runat="server" /> <asp:Button ID="btn_SaveChange"     runat="server" Text="Save" />&nbsp;<input id="btn_CancelSave" onclick="Wnd_ChangeDeviceDetails.Close();" type="button" value="Close" />&nbsp;&nbsp;
                                </td>
                                </tr>
                                <tr>
                                <td>
                                    <asp:Label ID="lbl_Error" runat="server" EnableViewState="false"></asp:Label>
                                </td>
                                </tr>
                </table>
           </owd:Window>
        </div>
    </form>
    
     <script type="text/javascript">
        document.getElementById("ob_drp_LocationContainer").style.zIndex="99999";
    </script>
    
    
    <script runat="server">
        Function CheckPermissions(ByVal Action As String) As String
            If Not Session.Item("LoginUser") Is Nothing Then
                If CType(Session("LoginUser"), eTimeTrackLiteLibrary.Data.Admin.User).PermissionNameList.Contains("DeviceManagement") Then
                    Return Action
                End If
                Return ""
            End If
        End Function
        
        Function ParseLastPing(ByVal LastCheckDate As String)
            Try
                If CDate(LastCheckDate) < CDate("1910-01-01") Then
                    Return ""
                Else
                    Return CDate(LastCheckDate).ToString("dd-MMM-yyyy HH:mm")
                End If
            Catch ex As Exception
                Return ""
            End Try
        End Function
        
        Function DeviceStatus(ByVal LastCheckDate As String,TimeOut as String)
            Try
            if TimeOut="" then
                    TimeOut = 300
            end if
            
                If DateDiff(DateInterval.Second, CDate(LastCheckDate), CDate(Now.ToString("dd-MMM-yyyy HH:mm:ss"))) > TimeOut Then
                    Return "offline"
                Else
                    Return "online"
                End If
                Return "offline"
            Catch ex As Exception
                Return "online"
            End Try
        End Function
        
        Function ChangeColorOnDeviceStatusCheck(ByVal LastCheckDate As String,TimeOut as String) As System.Drawing.Color
            Try
            if TimeOut="" then
                    TimeOut = 300
            end if
            
                If DateDiff(DateInterval.Second, CDate(LastCheckDate), CDate(Now.ToString("dd-MMM-yyyy HH:mm:ss"))) > TimeOut Then
                    Return Drawing.Color.Red
                Else
                    Return Drawing.Color.Green
                End If
                Return Drawing.Color.Red
            Catch ex As Exception
                Return Drawing.Color.Red
            End Try
        End Function
        
        
    </script>
    
    
    <script type="text/javascript">
		        
    
    
    function Wnd_ChangeDeviceDetails_Open(Action)
    {
        if(Action=='Ip Address')
        {
            document.getElementById('<%=lbl_ChangeName.ClientID %>').innerHTML='Ip Address';
            document.getElementById('<%=hdn_DeviceComm.ClientID %>').value='Ip Address';
            document.getElementById('<%=txt_ChangeIpAddress.ClientID %>').value=document.getElementById('<%=txt_IpAddress.ClientID %>').value;
        }
        else
        {
            document.getElementById('<%=txt_ChangeIpAddress.ClientID %>').value='';
            document.getElementById('<%=lbl_ChangeName.ClientID %>').innerHTML=Action;
            document.getElementById('<%=hdn_DeviceComm.ClientID %>').value=Action;
        }
        Wnd_ChangeDeviceDetails.Open();
        Wnd_ChangeDeviceDetails.screenCenter();
        return false;
    }
		    
		    function attachFlyoutToLink(oLink,Action)
		        {	
	                <%=Flyout1.getClientID()%>.AttachTo(oLink.id);		            		            
	                <%=Flyout1.getClientID()%>.Open();
	                clearFlyout();
	                if(Action=='Update')
	                {
	                    populateEditControls(oLink.id.toString().replace("grid_link_", ""));
	                }
		        }
		        
		        function GetSerialNumber(Sender)
		        {
		            var id=Sender.id;
		            document.getElementById('<%=Hdn_SerialNumber.ClientID %>').value=id.replace('lnkDevice_','')
		        }
		    
		    function closeFlyout() 
		        {
		            <%=Flyout1.getClientID()%>.Close();
		        }
		        
		        function drp_connectionType_SelectIndexChanges()
		        {
		            var ConnectionType=document.getElementById("<%=drp_ConnectionType.ClientID %>").value;
		            if(ConnectionType=='Tcp/IP')
		                document.getElementById("<%=txt_IpAddress.ClientID %>").disabled=false;
		            else
		                document.getElementById("<%=txt_IpAddress.ClientID %>").disabled=true;
		        }
		       
		    
		    function populateEditControls(iRecordIndex) 
		        {	
		            document.getElementById("<%=Hdn_DeviceId.ClientID%>").value =grid_Devices.Rows[iRecordIndex].Cells[0].Value;
		            document.getElementById("<%=txt_DeviceShortName.ClientID%>").value = grid_Devices.Rows[iRecordIndex].Cells[1].Value;
		            document.getElementById("<%=txt_DeviceFName.ClientID%>").value = grid_Devices.Rows[iRecordIndex].Cells[2].Value;
		            document.getElementById( "<%=txt_SerialNo.ClientID %>").value = grid_Devices.Rows[iRecordIndex].Cells[3].Value;
		        document.getElementById("ob_drp_LocationTextbox").value=grid_Devices.Rows[iRecordIndex].Cells[12].Value;
		            var Direction=grid_Devices.Rows[iRecordIndex].Cells[4].Value;
		            if(Direction=='in')
		                document.getElementById("<%=drp_DeviceDiretion.ClientID %>").value='In Device';
		            
		            else if(Direction=='out')
		                document.getElementById("<%=drp_DeviceDiretion.ClientID %>").value="Out Device"
		            
		            else if(Direction=='altinout')
		                document.getElementById("<%=drp_DeviceDiretion.ClientID %>").value="Alternate In/Out Device"
		            
		            else if(Direction=='inout')
		                document.getElementById("<%=drp_DeviceDiretion.ClientID %>").value="System Direction(In/Out) Device"
		                
		            document.getElementById("<%=txt_IpAddress.ClientID %>").value = grid_Devices.Rows[iRecordIndex].Cells[5].Value;
		            document.getElementById("<%=drp_ConnectionType.ClientID %>").value = grid_Devices.Rows[iRecordIndex].Cells[6].Value;
		            
		            var DeviceType=grid_Devices.Rows[iRecordIndex].Cells[7].Value;
                document.getElementById('<%=txt_TimeZone.ClientID %>').disabled=false; 
                document.getElementById('<%=txt_TimeOut.ClientID %>').disabled=false; 
                
		             document.getElementById("<%=txt_TimeZone.ClientID%>").value = grid_Devices.Rows[iRecordIndex].Cells[10].Value;
		             document.getElementById("<%=txt_TimeOut.ClientID%>").value = grid_Devices.Rows[iRecordIndex].Cells[11].Value;
		             
		            if(DeviceType=='Attendance')
                       document.getElementById("Flyout1_rbtn_DeviceType_0").checked=true;
		            
		            else if(DeviceType=='Canteen')
                       document.getElementById("Flyout1_rbtn_DeviceType_1").checked=true;
		            
		            else if(DeviceType=='Access Control')
                       document.getElementById("Flyout1_rbtn_DeviceType_2").checked=true;
		            drp_connectionType_SelectIndexChanges();
		        }
		   
		   
		      
		      
		       function btn_Save_onclick()
		        {
		            var oRecord = new Object();
	                oRecord.DeviceId =document.getElementById("<%=Hdn_DeviceId.ClientID %>").value ;
		        oRecord.Location=document.getElementById("ob_drp_LocationTextbox").value;
	                oRecord.Error='';
	                 if(document.getElementById("Flyout1_rbtn_DeviceType_0").checked ==  true)
		                    oRecord.ShiftType='Attendance';
		             else if(document.getElementById("Flyout1_rbtn_DeviceType_1").checked ==  true)
		                    oRecord.ShiftType='Canteen';
		             else if(document.getElementById("Flyout1_rbtn_DeviceType_2").checked ==  true)
		                    oRecord.ShiftType='Access Control';
	                grid_Devices.executeInsert(oRecord);
		        }
		    
            function clearFlyout() 
            {
		        document.getElementById("<%=txt_DeviceFName.ClientID%>").value = '';
		        document.getElementById("<%=txt_DeviceShortName.ClientID%>").value = '';
		        document.getElementById( "<%=txt_SerialNo.ClientID %>").value = '';
		        document.getElementById("<%=drp_DeviceDiretion.ClientID %>").selectedIndex=0;
		        document.getElementById("<%=drp_ConnectionType.ClientID %>").selectedIndex=0;
		        document.getElementById("<%=txt_IpAddress.ClientID %>").value = '';
		        document.getElementById("<%=Hdn_DeviceId.ClientID%>").value = '0';
		        document.getElementById("<%=Lbl_InvalidError.ClientID %>").innerHTML ='';
		        document.getElementById("<%=txt_TimeZone.ClientID%>").value = '330';
		        document.getElementById("<%=txt_TimeOut.ClientID%>").value = '300';
                document.getElementById('<%=txt_TimeZone.ClientID %>').disabled=true; 
                document.getElementById('<%=txt_TimeOut.ClientID %>').disabled=true; 
                document.getElementById("Flyout1_rbtn_DeviceType_0").checked=true;
		        drp_connectionType_SelectIndexChanges();
		        
		    }
		    
		    function RefreshDataGrid()
            {
                grid_Devices.refresh();
                window.setTimeout('RefreshDataGrid()', 15000);
            }
                window.setTimeout('RefreshDataGrid()', 15000);
    </script>
    
</body>
</html>
