Admin class [JScript]

Source: Internet
Author: User
/*************************************** ******************/
/* 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;

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.