基本信息
源码名称:C# 学生管理系统增删改的实现
源码大小:1.00M
文件格式:.zip
开发语言:C#
更新时间:2016-03-24
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍
入门级例子,含学生模块和教师模块,包含数据库,附加即可

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class login : System.Web.UI.Page
{
    Datacon dataconn = new Datacon();
    protected void Page_Load(object sender, EventArgs e)
    {
        Session["stu_name"] = this.TextBox1.Text; 
        if (!IsPostBack)
       {this.Label1.Text = System.Guid.NewGuid().ToString().Substring(0,4);}
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
       
        
            if (this.TextBox3.Text!=this.Label1.Text)
            {
                Response.Write("<script lanuage=javascript>alert('验证码错误')</script>");
            }
            else
            {
                if (this.CheckBoxList1.Items[0].Selected == true)
                {
                    this.getcom(1);
                }
                else
                {
                    this.getcom(2);
                }
            }
        
    }
    //==============================登录控制============================
    private void getcom(int i)
    {
        SqlConnection con = dataconn.getcon();
        con.Open();
        SqlCommand com=con.CreateCommand();
        switch (i)
        {
            case 1:
                com.CommandText = "select count(*) from users where User_id='"   this.TextBox1.Text   "' and User_Password='"   this.TextBox2.Text   "'";
                int count1 = Convert.ToInt32(com.ExecuteScalar());//获取SQL语句的值 强制转换成数值类型
                if (count1 > 0)
                {
                    Session[" User_id"] = TextBox1.Text;//成功
                    Session["User_Password"] = TextBox2.Text;
                    Page.Response.Redirect("tea/main.aspx");
                }
                else
                {
                    Response.Write("<script lanuage=javascript>alert('用户名或密码有误!')</script>");
                    return;
                }
                break;
            case 2:
                com.CommandText = "select count(*) from stu where UserID='"   this.TextBox1.Text   "' and stu_Password='"   this.TextBox2.Text   "'";
                int count2 = Convert.ToInt32(com.ExecuteScalar());
                if (count2 > 0)
                {
                    Session[" UserID"] = TextBox1.Text;//成功
                    Session["stu_Password"] = TextBox2.Text;
                    Page.Response.Redirect("stu/main1.aspx");
                }
                else
                {
                    Response.Write("<script lanuage=javascript>alert('用户名或密码有误!');location='javascript:history.go(-1)'</script>");
                    return;
                }
                break;
        }
        con.Close();
    }
}