用户登录代码实现用户登录代码实现
protected void btn_login_Click(object sender, EventArgs e)
{
string strcmd = "";
int i;
DataAcess mydataAcess = new DataAcess( )
if (txtUsername.Text.Trim() != "" && txtPassword.Text.Trim() != "")
{
if (DropDownList1.Text == "管理员")
{
strcmd = "sel...
用户登录代码实现
protected void btn_login_Click(object sender, EventArgs e)
{
string strcmd = "";
int i;
DataAcess mydataAcess = new DataAcess( )
if (txtUsername.Text.Trim() != "" && txtPassword.Text.Trim() != "")
{
if (DropDownList1.Text == "管理员")
{
strcmd = "select count(*) from admin where 用户名='" + txtUsername.Text + "' and 密码='" + txtPassword.Text + "'";
temp = 1;
}
if (DropDownList1.Text == "教师")
{
strcmd = "select count(*) from teacher where 教师编号='" + txtUsername.Text + "' and 密码='" + txtPassword.Text + "'";
temp = 2;
}
if (DropDownList1.Text == "学生")
{
strcmd = "select count(*) from student where 学号='" +
txtUsername.Text + "' and 密码='" + txtPassword.Text + "'";
temp = 3;
}
i = mydataAcess.ExecuteScalar(strcmd);
if (i == 1)
{
Session["Username"] = txtUsername.Text.ToString();
if (temp == 1)
Response.Redirect("admin//stuadmin.aspx");
if (temp == 2)
Response.Redirect("teacher//index.aspx");
if (temp == 3)
Response.Redirect("student//index.aspx");
}
else
Response.Write("")
}
else
{
Response.Write("");
txtUsername.Text = "";
txtPassword.Text = "";
}
}
using System;
using System.Collections.Generic; using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace login
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
protected void button1_Click(object sender, EventArgs e)
{
SqlConnection sqlcon = new SqlConnection("Data
Source=20101211-1746\\SQLEXPRESS;Initial Catalog=recruitsystem;Integrated
Security=True ");
if (txtNum.Text.Length == 0)
Information.Text = "请输入用户名~";
else
{
if (txtPwd.Text.Length == 0)
Information.Text = "请输入密码~";
else if (txtNum.Text == "Admin" && txtPwd.Text == "Admin")
{
Information.Text = "用户:" + txtNum.Text + "登录成功~";
}
else
Information.Text = "用户不存在或密码不正确~";
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void btnconcel_Click(object sender, EventArgs e)
{
}
}
}
本文档为【用户登录代码实现】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。