<!--#include file="../Include/Conn.jsp" -->
<!--#include file="../Include/const.jsp" -->
<!--#include file="../Include/Char.jsp" -->
<!--#include file="../Include/md5.jsp" -->
<%
if session("master")<>"" and checkStr(Request("ID"))<>"" then
   Response.Cookies("UserID") = checkStr(Request("ID"))
   Response.Cookies("LinkMan") = "Admin"
   Response.Cookies("companyid") = checkStr(Request("ID"))
      SET rs=server.createobject("adodb.recordset")
      SQL="SELECT template_id FROM  CityCard_League WHERE companyid = "&checkStr(Request("ID"))
      rs.Open SQL,conn,1,1 
	  if not rs.eof then
	  Response.Cookies("templateid") = rs("template_id")
	  end if
	  rs.close
	  set rs=nothing
   Response.Redirect("Index.jsp")
end if

If CheckStr(Request("Login"))="OK" Then
      m_UserName = CheckStr(Request("UserName"))
	  m_UserPWD = CheckStr(Request("UserPWD"))
      SET rs=server.createobject("adodb.recordset")
      SQL="SELECT * FROM  CityCard_League WHERE ischecked=1 and UserName = '"& m_UserName &"'"   
      rs.Open SQL,conn,1,1 
	  if rs.Eof then
	    rsErr = "对不起，该商家不存在或当前还未通过审核！"
	  elseif rs("password") <> m_UserPWD then
	        rsErr = "对不起，您输入的密码出错"
	  else
	    Response.Cookies("UserID") = rs("CompanyID")  
		Response.Cookies("LinkMan") = rs("LinkMan")
	    	
	    SQL="UPDATE CityCard_League SET LoginCount ='"&rs("LoginCount")+1 &"' WHERE CompanyID='"& rs("CompanyID")&"'"
        Conn.Execute SQL

		Response.Cookies("LoginCount") = rs("LoginCount")+1
		Response.Cookies("UserName") = rs("UserName")
		Response.Cookies("companyid") = rs("companyid")
		Response.Cookies("templateid") = rs("template_id")
		if rs("grade") <> "" Then
	      Response.Cookies("grade") = rs("grade")
		else
		  Response.Cookies("grade") = " "
		end if
		Response.cookies("iscard") = rs("iscard")
		if rs("LastLoginTime") <> "" then
		  Response.cookies("LastLoginTime") = rs("LastLoginTime")
		else
		  Response.Cookies("LastLoginTime") = "未登录过"
		end if
	    SQL="UPDATE CityCard_League SET LastLoginTime ='"& now() &"' WHERE CompanyID='"& rs("CompanyID")&"'"
        Conn.Execute SQL
		
		Response.Cookies("LoginTime") = now()
		Response.Redirect("Index.jsp")
		Response.END()
	  end if	
		
	  rs.Close
	  SET rs = Nothing
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=site_info(0)%> - 商家管理系统</title>
<link href="../Include/Style.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
</head>

<body onLoad="MM_preloadImages('images/xf_link1b.gif','images/xf_link2b.gif','images/xf_link3b.gif','images/xf_link4b.gif','images/xf_link5b.gif','images/ly_b_2b.gif','images/ly_b_4b.gif','images/ly_b_1b.gif','images/ly_b_3b.gif','images/ly_b_5b.gif')">

<table width="760" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td width="170" height="500" valign="top" bgcolor="f5f5f5">
      <!--#include file="Left.jsp" -->
    </td>
    <td width="10" valign="top"></td>
    <td width="600" valign="top"><table width="600" border="0" cellspacing="0" cellpadding="0">
      <tr>
          <td height="50" class="p1"> <STRONG>登录事项：</STRONG>欢迎您进入商家管理系统！只有聚宝卡加盟商家才能登录，如果您还不是聚宝卡加盟商家，请加盟后登录！<A 
            class=p1 
            href="reginfo.jsp">现在加盟>></A></td>
      </tr>
    </table>
      <table width="600" border="1" cellpadding="0" cellspacing="5" bordercolor="e2e2e2" bgcolor="f5f5f5">
        <tr>
          <td height="25" background="images/about_bj.gif" class="p4">&nbsp;<b>·请先输入商家的用户名和登陆密码。</b></td>
        </tr>
      </table>
      <table width="600" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="5"></td>
        </tr>
        <tr>
          <td height="1" background="images/line.gif" ></td>
        </tr>
      </table>
      <br>
      <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
          <td colspan="3"><img src="images/sjdl_01.gif" width="500" height="20"></td>
        </tr>
        <tr> 
          <td width="10"><img src="images/sjdl_02.gif" width="10" height="310"></td>
          <td width="480" align="left" background="images/sjdl_03.gif"><table width="300" border="0" cellspacing="5" cellpadding="0">
              <tr> 
                <td height="150" colspan="2"> <div align="center"> <font color="#FF0000">
                    <%
				  Response.Write rsErr  
				%>
                    </font> </div></td>
              </tr>
			  <form name="form1" method="post" action="?Login=OK">
              <tr> 
                <td width="110" height="25" align="right" class="p4">商家用户名：</td>
                <td width="175"><input name="UserName" type="text" id="UserName" size="20"></td>
              </tr>
              <tr> 
                <td height="25" align="right" class="p4">密　码：</td>
                <td><input name="UserPWD" type="password" id="UserPWD" size="20"></td>
              </tr>
              <tr> 
                <td colspan="2" align="center"><input type="submit" name="Submit" value="登录">
                  　 
                    <input type="button" name="Submit2" onClick="location.href='reginfo.jsp'" value="申请加盟"></td>
              </tr>
			  </form>
            </table></td>
          <td width="10"><img src="images/sjdl_04.gif" width="12" height="310"></td>
        </tr>
        <tr> 
          <td colspan="3"><img src="images/sjdl_05.gif" width="500" height="20"></td>
        </tr>
      </table></td>
  </tr>
</table>

</body>
</html>

