userlogin.aspx.cs

来自「成绩管理系统」· CS 代码 · 共 56 行

CS
56 行
字号
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;

public partial class UserLogin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
    protected void Button_Confirm_Click(object sender, EventArgs e)
    {

        DataBase DbOper = new DataBase();
        if (this.TextBox_UserName.Text.IndexOf("'") > 0 || this.TextBox_UserName.Text.IndexOf("-") > 0)
        {
            this.Label_Msg.Text = "用户名中有非法字符";
            return;
        }

        string Condition = "where UserName='" + this.TextBox_UserName.Text.Trim() + "' and UserPass='" + this.TextBox_UserPass.Text + "' and UserType='" + this.DropDownList1.SelectedValue.ToString() + "'";

      DataSet Dset = DbOper.BindGrid("User_Info", "*", Condition, "");
      if (Dset != null && Dset.Tables[0].Rows.Count > 0)
      {
          Session["UserType"] = this.DropDownList1.SelectedValue.ToString();
          Session["UserName"] = this.TextBox_UserName.Text;
         // Response.Redirect("AddCourse.aspx");
          this.Label_Msg.Text = "登录成功!";
          Response.Write("<meta http-equiv=refresh ; content='2;URL=QueryGrade.aspx'>");
          
      }
      else
      {
          this.Label_Msg.Text = "登录失败!";
          this.TextBox_UserName.Text = "";
          this.TextBox_UserPass.Text = "";

 
      }
    }

    protected void Button_Cancel_Click(object sender, EventArgs e)
    {
        this.TextBox_UserName.Text = "";
        this.TextBox_UserPass.Text = "";
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?