在线报名系统 net

时间:2015-07-02 02:49:46
【文件属性】:

文件名称:在线报名系统 net

文件大小:1.5MB

文件格式:RAR

更新时间:2015-07-02 02:49:46

在线报名系统

该系统是某工程硕士,开发的在线报名系统 public partial class login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string indexDirectory; indexDirectory = Server.MapPath("admin") + "\\App_LocalResources\\time.txt"; StreamReader sr = new StreamReader(indexDirectory, true); string strStart = sr.ReadLine(); string strEnd = sr.ReadLine(); sr.Close(); DateTime dtStart = DateTime.Parse(strStart); DateTime dtEnd = DateTime.Parse(strEnd); Label1.Text = "比赛报名时间为:" + dtStart.ToString() + "到" + dtEnd.ToString(); } } protected void imgbtnLogin_Click(object sender, ImageClickEventArgs e) { string userID = userid.Text.ToString().Trim(); string userPwd = password.Text.ToString().Trim(); string userRole = userrole.SelectedValue.Trim(); string selectStr = ""; switch (userRole) { case "0": selectStr = "Select * from teacher where t_no = '" + userID + "'"; break; case "1": selectStr = "Select * from student where s_no = '" + userID + "'"; break; case "2": selectStr = "Select * from admin where user_id = '" + userID + "'"; break; } SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); SqlCommand cmd = new SqlCommand(selectStr, conn); try { conn.Open(); SqlDataReader sdr = cmd.ExecuteReader(); if (sdr.Read()) { if (sdr.GetString(1) == userPwd) { Session["userID"] = userID; Session["userRole"] = userRole; conn.Close(); switch (userRole) { case "0": Response.Redirect("teacher/tea_main.aspx"); break; case "1": Response.Redirect("student/stu_main.aspx"); break; case "2": Response.Redirect("admin/admin_main.aspx"); break; } } else { lblMessage.Text = "您输入的密码错误,请检查后重新输入!"; } } else { lblMessage.Text = "该用户不存在或用户ID输入错误,请检查后重新输入!"; } } catch (Exception ee) { Response.Write("[removed]alert('" + ee.Message.ToString() + "')[removed]"); } finally { conn.Close(); } } protected void imgbtnClose_Click(object sender, ImageClickEventArgs e) { Response.Write("[removed][removed]widnow.close()[removed]"); } }


网友评论

  • 很值得学习
  • 编写工具有点老,还得转换,
  • 调试时提示错误,是在配置文件里面,看来以后我也要多学习下配置文件的书写了