//连接数据库:
//登录
string connstr=System.Configuration.ConfigurationSettings.AppSettings["sqllink"];
SqlConnection conn=new SqlConnection(connstr);
conn.Open();
string sql="select count(*) as icount from sysoper where logname='"+this.usrname.Text+"'";
SqlCommand comm=new SqlCommand(sql,conn);
SqlDataReader dr1=comm.ExecuteReader();
dr1.Read();
string count=dr1["icount"].ToString();
dr1.Close();
if(count!="0")
{
sql="select * from sys where logname='"+this.usrname.Text+"'";
SqlCommand comm1=new SqlCommand(sql,conn);
SqlDataReader dr=comm1.ExecuteReader();
dr.Read();
string drpwd=dr["logpass"].ToString();
dr.Close();
if(drpwd==this.usrpwd.Text)
{
this.Session["logid"]=this.usrname.Text.Trim();
if(dr["PLCName"].ToString()=="")
{
this.Session["level"]="1";
}
if(dr["PLCName"].ToString()!="")
{
this.Session["level"]="2";
this.Session["plcname"]=dr["PLCName"].ToString();
}
this.Response.Redirect("main.aspx");
}