• 大小: 49KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2023-02-09
  • 语言: C#
  • 标签: 学生  c#  

资源简介

NET平台上使用窗体和控件来创建用户界面

资源截图

代码片段和文件信息

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;
using System.Data.SqlClient;
using System.Security.Cryptography;
using System.Text;

public partial class AddUser : System.Web.UI.Page
{
    protected void Page_Load(object sender EventArgs e)
    {
        //保存客户端上次请求的URL信息
        if (Request.UrlReferrer.ToString() != null)
        {
            ViewState[“GoBackUrl“] = Request.UrlReferrer.ToString();
        }

        //禁用验证控件
        Login Lg = (Login)(Master.FindControl(“Login1“));
        RequiredFieldValidator rfv1;
        rfv1 = (RequiredFieldValidator)Lg.FindControl(“RequiredFieldValidator1“);
        rfv1.Enabled = false;

        RequiredFieldValidator rfv2;
        rfv2 = (RequiredFieldValidator)Lg.FindControl(“RequiredFieldValidator2“);
        rfv2.Enabled = false;

        //页面第一次加载
        if (!Page.IsPostBack)
        {
            SqlConnection con = DB.CreateCon();
            con.Open();

            //显示院系
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = “select * from DepartmentName“;
            cmd.Connection = con;
            SqlDataReader sdr = cmd.ExecuteReader();
            this.ddlUserDep.DataSource = sdr;
            this.ddlUserDep.DataTextField = “DepName“;
            this.ddlUserDep.DataValueField = “DepID“;
            this.ddlUserDep.DataBind();
            
            //关闭连接
            sdr.Close();            
            con.Close();
        }
    }
    protected void OkBtn_Click(object sender EventArgs e)
    {
        //如果页面验证未通过
        if (!Page.IsValid)
        {
            return;
        }
        string UserTxt;
        string PwdTxt;
        
        UserTxt= this.UserTxt.Text.Trim();
        PwdTxt = this.PwdTxt.Text.Trim();

        //加密用户名和密码
        UserTxt = FormsAuthentication.HashPasswordForStoringInConfigFile(UserTxt System.Web.Configuration.FormsAuthPasswordFormat.SHA1.ToString());
        PwdTxt = FormsAuthentication.HashPasswordForStoringInConfigFile(PwdTxt System.Web.Configuration.FormsAuthPasswordFormat.SHA1.ToString());

        SqlConnection con = DB.CreateCon();
        con.Open();

        //保存到数据库
        SqlCommand cmd = new SqlCommand();        
        if (DropDownList1.SelectedItem.Text == “教师“)
        {
            cmd.CommandText = “insert into TeachersLogin values(‘“ + UserTxt + “‘‘“ + PwdTxt + “‘“ + this.ddlUserDep.SelectedValue + “)“;
        }
        else if (DropDownList1.SelectedItem.Text == “管理员“)
        {
            cmd.CommandText = “insert into AdministratorLogin values(‘“ + UserTxt + “‘‘“ + PwdTxt + “‘“ + this.ddlUserDep.SelectedValue + “)“;
        }
        cmd.Connection = con;
        cmd.ExecuteNonQuery();
        con.Clos

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       5910  2007-12-07 17:43  ch26\StudentsMIS\AddUser.aspx

     文件       5621  2007-10-09 16:45  ch26\StudentsMIS\AddUser.aspx.cs

     文件      11384  2007-10-09 11:10  ch26\StudentsMIS\AdminPage.aspx

     文件      11676  2007-10-08 21:50  ch26\StudentsMIS\AdminPage.aspx.cs

     文件       1581  2007-10-03 21:51  ch26\StudentsMIS\App_Code\AdministratorOperator.cs

     文件        663  2007-10-01 17:55  ch26\StudentsMIS\App_Code\DB.cs

     文件       1877  2007-12-07 17:31  ch26\StudentsMIS\App_Code\Greet.cs

     文件       1049  2007-10-05 15:38  ch26\StudentsMIS\App_Code\StudentOperator.cs

     文件       1569  2007-10-06 18:19  ch26\StudentsMIS\App_Code\TeachersOperator.cs

     文件       2400  2007-10-05 11:39  ch26\StudentsMIS\CreateTables.sql

     文件        469  2008-03-13 18:18  ch26\StudentsMIS\ErrorPage.aspx

     文件        410  2007-10-01 20:02  ch26\StudentsMIS\ErrorPage.aspx.cs

     文件       1059  2007-10-02 14:36  ch26\StudentsMIS\Global.asax

     文件       2998  2007-12-07 17:08  ch26\StudentsMIS\Login.ascx

     文件       4026  2007-12-07 17:31  ch26\StudentsMIS\Login.ascx.cs

     文件        579  2007-12-07 17:08  ch26\StudentsMIS\Login.aspx

     文件        459  2007-10-31 22:19  ch26\StudentsMIS\Login.aspx.cs

     文件      17294  2007-09-19 08:47  ch26\StudentsMIS\logo.png

     文件       3530  2007-10-05 15:47  ch26\StudentsMIS\MasterPage.master

     文件        629  2007-12-07 17:31  ch26\StudentsMIS\MasterPage.master.cs

     文件       1502  2007-10-05 12:10  ch26\StudentsMIS\StudentsMIS.sln

    ..A..H.     21504  2007-10-05 23:06  ch26\StudentsMIS\StudentsMIS.suo

     文件       5351  2007-10-06 14:30  ch26\StudentsMIS\StudentsPage.aspx

     文件       2177  2007-10-06 11:31  ch26\StudentsMIS\StudentsPage.aspx.cs

     文件       1016  2007-10-06 11:45  ch26\StudentsMIS\StutitleTip.ascx

     文件        722  2007-10-05 22:32  ch26\StudentsMIS\StutitleTip.ascx.cs

     文件      11267  2007-12-07 17:40  ch26\StudentsMIS\TeacherPage.aspx

     文件      11530  2007-10-07 17:15  ch26\StudentsMIS\TeacherPage.aspx.cs

     文件       8534  2008-03-13 18:04  ch26\StudentsMIS\Web.Config

     文件       1533  2008-03-15 15:34  ch26\StudentsMIS.sln

............此处省略9个文件信息

评论

共有 条评论