/*************************************** ******************/
/* Admin class JScript */
/**/
/*************************************** ******************/
// Member method define
// Check whether the user name exists (common)
Function _ isexitsuser (username)
{
Try
{
// Var conn = This. Conn;
VaR flag;
VaR SQL = "select membasinfid from m_membasinf where memusername = '" + username + "'";
VaR rs = server. Createobject ("ADODB. recordset ");
Rs. Open (SQL, this. Conn, 1, 1 );
Flag = (Rs. EOF = true? False: True );
Return flag;
}
Finally
{
Closeobj (RS );
}
}
// Obtain the user ID
Function _ getuseridbyusername (username)
{
Try
{
Username = string (username). Trim ();
// Var conn = This. Conn;
VaR userid = 0;
VaR SQL = "select membasinfid from m_membasinf where memusername = '" + username + "'";
// Var SQL = "select membasinfid from m_membasinf where memusername = 'abao '";
VaR rs = server. Createobject ("ADODB. recordset ");
Rs. Open (SQL, this. Conn, 1, 1 );
If (! Rs. EOF)
{
Userid = RS ("membasinfid ");
}
Return userid;
}
Finally
{
// Closeobj (RS );
}
}
// Member Logon
Function _ login (username, userpas)
{
Try
{
Username = sqlstr (string (username). Trim ());
Userpas = sqlstr (string (userpas). Trim ());
VaR flag;
VaR SQL = "select adminid from t_s_admin ";
SQL + = "where adminname = '" + username + "' and adminpaswd = '" + userpas + "'";
VaR rs = server. Createobject ("ADODB. recordset ");
Rs. Open (SQL, this. Conn, 1, 1 );
Flag = (Rs. EOF = true? False: True );
If (FLAG)
{
Session ("adminname") = username;
Session ("adminpaswd") = userpas;
}
Return flag;
}
Finally
{
Closeobj (RS );
}
}
// Member logout
Function _ loginout ()
{
}
// Update the password
Function _ altpassword (oldpas, newpas)
{
Try
{
VaR adminname = string (Session ("adminname "));
VaR flag;
Flag = false;
VaR rs = server. Createobject ("ADODB. recordset ");
VaR SQL = "select adminid from t_s_admin ";
SQL + = "where adminpaswd = '" + oldpas + "' and adminname = '" + adminname + "'";
Rs. Open (SQL, this. Conn, 1, 1)
If (! Rs. EOF)
{
SQL = "Update t_s_admin set adminpaswd = '" + newpas + "'where adminname ='" + adminname + "'";
This. Conn. Execute (SQL );
Session ("adminpaswd") = newpas; // update the password
Flag = true;
}
Return flag;
}
Finally
{
Closeobj (RS );
}
}
// Constructor
Function clsadmin (conn)
{
// Property
This. Conn = conn;
// Method
This. login = _ login;
This. altpaswd = _ altpassword;
}