<%@ Page Language="vb" AutoEventWireup="false" 
    CodeBehind="frmLogin.aspx.vb" 
    Inherits="CITAD.WEB.VB.frmLogin" 
    Culture="auto" 
    meta:resourcekey="PageResource1" 
    UICulture="auto" %>

<%@ Register Src="../../Controls/MessageBox.ascx" TagName="MessageBox" TagPrefix="uc1" %>

<!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>Đăng nhập</title>
    <link href="../../css/css.css" rel="Stylesheet" />
    <link href="../../css/login.css" rel="stylesheet" type="text/css" />
    <script src="../../js/citad-prototype.js" type="text/javascript"></script>
    <script language="JavaScript" type="text/javascript">
        window.document.onload = formload;
        function formload()
        {
            //$get('<%=txtUserID.ClientID %>').focus();
        }
        function fcnCheckForm()
        {
            //==================================================
            //Kiểm tra các gía trị nhập
            //==================================================
            //Lấy card mạng
            getMAC();
            if(document.getElementById('<%=hidListMAC.ClientID %>').value=='')
            {
                alert("Không lấy được card mạng");
                return false;
            }
            else
            {
                return true;
            }
        }
        function getMAC()
        {
            //=================================================
            //Get list of mac
            var objMAC = document.getElementById('<%=hidListMAC.ClientID %>');
            objMAC.value = '';
            try
	        {
		        var locator = new ActiveXObject("WbemScripting.SWbemLocator");
		        var service = locator.ConnectServer(".");
		        var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE MACAddress <> null AND IPFilterSecurityEnabled <> null");//WHERE IPEnabled=TRUE 
		        var e = new Enumerator(properties);
		        //=================================================
                //creat table of mac
                for (;!e.atEnd();e.moveNext())
                {
                    var p = e.item();
                    objMAC.value += p.MACAddress + ",";
                }
                if(objMAC.value == '') objMAC.value = '00:00:00:00:00:00,';
	        }
	        catch(err){}
        }
        
 
        
    </script>
</head>
<body id="login-body">
    <form id="frmLogin" runat="server">
        <ajaxToolkit:ToolkitScriptManager runat="Server" ID="ScriptManager1" EnableScriptGlobalization="True"
             EnableScriptLocalization="True" CombineScripts="True" EnablePageMethods="true"  />

        <div style="text-align:center; vertical-align:middle; padding:5px;">
            <div id="login-banner">
                <asp:Label ID="lblLogo" runat="server" Text="NGÂN HÀNG NHÀ NƯỚC VIỆT NAM" meta:resourcekey="lblLogoResource1" Width="396px" Font-Bold="True" ForeColor="#930015"></asp:Label>
            </div>
            <div id="login-main">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td class="login-table-tdleft" style="width: 50%;">
                    <img alt="" src="../../Images/Login/citad-logo.jpg" style="padding-bottom:5px;" /><br />
                    <asp:Label ID="lblDesign" runat="server" meta:resourcekey="lblDesignResource1" Text="Thiết kế và phát triển HIPT - HYUNDAI IT"></asp:Label><br />
                    <img alt="" src="../../Images/Login/hyundai.jpg" />
                </td>
                <td class="login-table-tdright" style="width: 50%">
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        &nbsp;<div id="divLogin">
                        <div class="div-login-label"><asp:Label ID="lblLogin" runat="server" meta:resourcekey="lblLoginResource1" Text="??ng nh?p" Font-Bold="True"></asp:Label></div>
                        <table width="100%" border="0" cellspacing="8" cellpadding="0" class="login-table-main">
                        <tr>
                          <td align="right" class="login-tdusername" style="width: 50px"><div id="login-table-divImgUid"></div></td>
                          <td style="width: 150px" >
                            <asp:TextBox ID="txtUserID" TabIndex="1" runat="server" meta:resourcekey="txtUserIDResource1" MaxLength="16" onblur="onTxtUserKeyUp(this);" CssClass="login-textusername citad-txt" Width="144px"></asp:TextBox>
                              <span class="txt-red"></span></td>
                        </tr>
                        <tr>
                          <td align="right" class="login-tdpassword" style="width: 50px; height: 35px;"><div id="login-table-divImgPwd"></div></td>
                          <td style="width: 150px; height: 35px;">
                             <asp:TextBox ID="txtPasswords" TabIndex="2" runat="server"  meta:resourcekey="txtPasswordsResource1" MaxLength="30" TextMode="Password" CssClass="login-textpassword citad-txt" Width="144px"></asp:TextBox>
                          <span class="txt-red"></span></td>
                        </tr>
                        </table>
                        <div class="login-table-button">
                            <asp:Button ID="btnLogin" OnClientClick="return fcnCheckForm();" runat="server" Text="Login" meta:resourcekey="btnLoginResource1" TabIndex="3" ValidationGroup="VG1"/>&nbsp;<asp:Button
                                ID="btnPalmVein" runat="server" OnClick="btnPalmVein_Click" Text="PalmVein" />
                  <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Vein" Visible="False" />
                  </div>
                      </div>
                      <asp:HiddenField ID="hidSerialNumber" runat="server" />
                        <asp:HiddenField ID="hidComputerName" runat="server" />
                        <asp:HiddenField ID="hidListMAC" runat="server" />
                        <asp:HiddenField ID="hidMessage" runat="server" />
                        <asp:HiddenField ID="hidFocusControlName" runat="server" />
                          <uc1:MessageBox ID="MessageBox1" runat="server" />
                          <asp:HiddenField ID="hidVeinData" runat="server" />
                          <asp:HiddenField ID="hidResultVein" runat="server" />
                        </ContentTemplate>
                    </asp:UpdatePanel>
	                </td>
                  </tr>
                </table>
                </div>
            </div>
    </form>
    <script type="text/javascript" language="javascript">
        function onTxtUserKeyUp(text)
        {
            try
            {
                text.value = text.value.trim();
                text.value = text.value.toUpperCase();
            }
            catch(err){}
        }

        function fcnMessage()
        {
            var mes = $get('<%=hidMessage.ClientID %>');
            if(mes.value != "")
            {
                alert(mes.value);
                mes.value = "";
                var focusControlName = $get('<%=hidFocusControlName.ClientID %>').value;                
                if(focusControlName != "")
                {
                    $get(focusControlName).focus();
                }
            }
        }
    </script>
    <script type="text/javascript">
        //Nhóm hàm xử lý postback ajax
        try
        {            
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(onEndRequest);
        }
        catch(err){}
        function pageUnload()
        {
            try
            {
                Sys.WebForms.PageRequestManager.getInstance().remove_endRequest(onEndRequest);
            }
            catch(err){}
        }

        function onEndRequest(sender, args)
        {
            fcnMessage();
        }
    </script>
    
    <script language="javascript" type="text/javascript">
    /* PALMVEIN */
    function fGetVein()
    { 
        fcnCheckForm();
        var getVein; // Lấy mẫu vein từ thiết bị
        try
        {
            getVein = ActiveXPSC.CaptureVeinData();             	              
            if(getVein == 0) // Lấy mẫu vein từ thiết bị thành công
            {	
               $('hidVeinData').value = ActiveXPSC.veinData;
               document.getElementById('frmLogin').submit();
            }
            else
            {
                alert('Lấy mẫu vein không thành công');
            }                   
        }
        catch(err)
        {
            alert('Chức năng này chưa thực hiện được!');
            return 3;
        }
    }
    
    function VerifyAfterInputUserName()
    {
        fcnCheckForm();
        var getVein; // Lấy mẫu vein từ thiết bị
        try
        {
            getVein = ActiveXPSC.CaptureVeinData();
            if(getVein == 0) // Lấy mẫu vein từ thiết bị thành công
            {	
               $('hidVeinData').value = ActiveXPSC.veinData;
               document.getElementById('frmLogin').submit();
//               var btnVein = $('<%=Button1.ClientID %>');               
//               btnVein.click();               
//               setTimeout('__doPostBack(\'btnVein\',\'\')', 0)
            }
            else
            {
                //alert('Lấy mẫu vein ko thanh cong');
                return;
            }    
        }
        catch(err)
        {
            alert('Chức năng này chưa thực hiện được!');
            return 3;
        }
    }
    
    function onEndRequest(sender, args)
    {/*
        var result = $('hidResultVein').value;
        alert(result_vein);
        if(result == '')
        {
                window.location='Default.aspx';
        }*/
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(onEndRequest);
    }
    try
    {
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(onEndRequest);
    }
    catch(err){}
    
    function pageUnload()
    {
        try
        {
            Sys.WebForms.PageRequestManager.getInstance().remove_endRequest(onEndRequest);
        }
        catch(err){}
    }
    </script>
    <object id="ActiveXPSC" classid="CLSID:7A6143A1-163F-4E2A-9308-7BD10D094627" width="1" height="0"> </object>    
    
</body>
</html>