webusercontrol.ascx.cs
来自「这是asp.net^和Visual C++Sharp编写的串并口通讯的书籍 源代」· CS 代码 · 共 58 行
CS
58 行
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class WebUserControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public int checkLogin(string loginName, string loginPwd)
{
SqlConnection con = new SqlConnection("Server=(local);database=mrdb;Uid=sa;Pwd=");
SqlCommand myCommand = new SqlCommand("select count(*) from UserData where loginName=@loginName and loginPwd=@loginPwd", con);
myCommand.Parameters.Add(new SqlParameter("@loginName", SqlDbType.NVarChar, 20));
myCommand.Parameters["@loginName"].Value = loginName;
myCommand.Parameters.Add(new SqlParameter("@loginPwd", SqlDbType.NVarChar, 20));
myCommand.Parameters["@loginPwd"].Value = loginPwd;
myCommand.Connection.Open();
int i = (int)myCommand.ExecuteScalar();
myCommand.Connection.Close();
return i;
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
int i = this.checkLogin(txtName.Text, txtPwd.Text);
if (i > 0)
{
if (txtCheckCode.Text == Session["CheckCode"].ToString())
{
Response.Write("<script>alert('登录成功!!!')</script>");
}
else
{
Response.Write("<script>alert('验证码输入错误!!!')</script>");
}
}
else
{
Response.Write("<script>alert('用户名称或密码错误!!!')</script>");
}
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
txtName.Text = "";
txtPwd.Text = "";
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?