Site_index.Master.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace 作业
{
    public partial class Site_index : System.Web.UI.MasterPage
    {
        static string connstr = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];//定义静态链接数据库参数
        SqlConnection Conn = new SqlConnection(connstr);//定义连接数据库连接对象conn
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void bt_login_Click(object sender, EventArgs e)
        {
            string login_type = this.ddl_logintype.SelectedValue.ToString();
            DataSet ds = new DataSet();
            string user = this.txt_zh.Text.ToString();
            string password = this.txt_mima.Text.ToString();
            SqlDataAdapter da = new SqlDataAdapter();//创建一个数据适配器
            //假如是企业登录
            if (login_type == "教师")
            {


                string sql = "select * from teacher where zh='" + user + "' and mima='" + password + "'";
                SqlCommand cmd = new SqlCommand(sql, Conn);//建立COMMAND对象
                da.SelectCommand = cmd;
                da.Fill(ds,"tea");
                DataTable dt =ds.Tables["tea"];
                int count = dt.Rows.Count;
                if (count == 0)
                {
                    Response.Write("<script>alert('请填写正确的账号和密码!');location='index.aspx'</script>");
                }
                else
                {
                    Session["zh"] = user;
                    Session["bj_id"] = dt.Rows[0]["bj_id"].ToString();
                    Session["kc"] = dt.Rows[0]["kc"].ToString();
                    Response.Redirect("tea_index.aspx");
                }
            }
            //假如是申请人
            if (login_type == "学生")
            {
                string sql1 = "select * from student where xh='" + user + "' and mima='" + password + "'";//定义登录的SQL语句
                SqlCommand cmd1 = new SqlCommand(sql1, Conn);//建立COMMAND对象
                da.SelectCommand = cmd1;
                da.Fill(ds, "xs");
                DataTable dt1 = ds.Tables["xs"];
                int count = dt1.Rows.Count;
                if (count == 0)
                {
后面还有 15 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。