protected void Page_Load(object sender, EventArgs e) { if (Session["stunum"] != null || Session["adminnum"] != null || Session["thnnum"] != null) { Session.Abandon(); } DataBaseUtil.connectDB(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["stunum"] == null) { Response.Write("<script>alert('请先登录!');window.location.href='Login.aspx'</script>"); } else { DataBaseUtil.connectDB(); } }
protected void bind() { string tnum = Session["thnnum"].ToString(); DataBaseUtil.connectDB(); string showSql = " select tb_student.sno,sname,tb_course.cno,cname,grade from tb_course,tb_sc,tb_teacher,tb_student where tb_course.cno=tb_sc.cno and tb_sc.tno=tb_teacher.tno and tb_sc.sno=tb_student.sno and tb_sc.tno='" + tnum + "'"; DataSet ds = new DataSet(); SqlDataAdapter myDA = new SqlDataAdapter(showSql, myconn); myDA.Fill(ds, "TEST"); GridView1.DataSource = ds; GridView1.DataBind(); }
public void dBind() { DataBaseUtil.connectDB(); string snum = Session["stunum"].ToString(); string showSql = "select sno ,sname ,ssex, sbirth, mname from tb_student join tb_major on tb_student.mno=tb_major.mno and sno='" + snum + "'"; SqlDataAdapter sda = new SqlDataAdapter(showSql, myconn); DataSet ds = new DataSet(); sda.Fill(ds, "stutab"); GridView1.DataSource = ds; GridView1.DataBind(); }
public void dBind() { DataBaseUtil.connectDB(); string tnum = Session["thnnum"].ToString(); string showSql = "select tno ,dno ,tname, tsex from tb_teacher where tno='" + tnum + "'"; SqlDataAdapter sda = new SqlDataAdapter(showSql, myconn); DataSet ds = new DataSet(); sda.Fill(ds, "thtab"); GridView1.DataSource = ds; GridView1.DataBind(); }
public void dBind() { DataBaseUtil.connectDB(); string anum = Session["adminnum"].ToString(); string showSql = "select ano ,aname ,apass from tb_admin where ano='" + anum + "'"; SqlDataAdapter sda = new SqlDataAdapter(showSql, myconn); DataSet ds = new DataSet(); sda.Fill(ds, "admintab"); GridView1.DataSource = ds; GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["adminname"] == null) { Response.Write("<script>alert('请先登录!');window.location.href='Login.aspx'</script>"); } else if (Session["adminright"].ToString() == "10" || Session["adminright"].ToString() == null) { Response.Write("<script>alert('您没有权限使用此功能');window.location.href='AdminInfo.aspx'</script>"); } else { DataBaseUtil.connectDB(); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["adminname"] == null) { Response.Write("<script>alert('请先登录!');window.location.href='Login.aspx'</script>"); } else { DataBaseUtil.connectDB(); string ssql = "select mno as '专业编号',mname as '专业名称',tb_major.dno as '系别编号',dname as '系别',dtel as '联系方式' from tb_major join tb_dept on tb_major.dno=tb_dept.dno"; SqlDataAdapter sda = new SqlDataAdapter(ssql, myconn); DataSet ds = new DataSet(); sda.Fill(ds, "mdInfo"); GridView1.DataSource = ds; GridView1.DataBind(); } }
protected void bind() { if (Session["thnnum"] == null) { Response.Write("<script>alert('请先登录!');window.location.href='Login.aspx'</script>"); } else { string tnum = Session["thnnum"].ToString(); DataBaseUtil.connectDB(); string showSql = " select cno as '课程号',cname as '课程名',ccredit as '学分',tno as '本人教师编号' from tb_course where tno='" + tnum + "'"; DataSet ds = new DataSet(); SqlDataAdapter myDA = new SqlDataAdapter(showSql, myconn); myDA.Fill(ds, "TEST"); GridView1.DataSource = ds; GridView1.DataBind(); } }
protected void bind() { if (Session["stunum"] == null) { Response.Write("<script>alert('请先登录!');window.location.href='Login.aspx'</script>"); } else { string studentNum = Session["stunum"].ToString(); DataBaseUtil.connectDB(); string showSql = " select tb_course.cno as '课程号',cname as '课程名',ccredit as '学分',tname as '教师名',dname as '系别',dtel as '联系方式' from tb_course,tb_sc,tb_teacher,tb_dept where tb_course.cno=tb_sc.cno and tb_sc.tno=tb_teacher.tno and tb_teacher.dno=tb_dept.dno and tb_sc.sno='" + studentNum + "'"; DataSet ds = new DataSet(); SqlDataAdapter myDA = new SqlDataAdapter(showSql, myconn); myDA.Fill(ds, "TEST"); GridView1.DataSource = ds; GridView1.DataBind(); } }
protected void LinkButton1_Click(object sender, EventArgs e) { Session.Abandon(); DataBaseUtil.closeDB(); Response.Redirect("Login.aspx"); }
protected void LoginButton_Click(object sender, EventArgs e) { string usernumber = Textbox1.Text; string userpass = Textbox2.Text; if (Textbox1.Text == "" || Textbox2.Text == "") { Page.ClientScript.RegisterClientScriptBlock(GetType(), "Attention", "<script>alert('请输入学号或密码');</script>"); } else if (!RadioButton1.Checked && !RadioButton2.Checked && !RadioButton3.Checked) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "Attention", "<script>alert('请选择您的身份');</script>"); } else if (RadioButton1.Checked) { //loginsql = // "select sno,spass,sname,ssex,sbirth,sdept from tb_student where sno='"+usernumber+"' and spass='******'"; string studentsql = "select sno,spass,sname,ssex,sbirth,dname,mname from tb_student join tb_major on tb_student.mno=tb_major.mno join tb_dept on tb_major.dno=tb_dept.dno where sno='" + usernumber + "'" + " and spass='******'"; mycomd.CommandText = studentsql; mycomd.Connection = myconn; SqlDataAdapter myDA = new SqlDataAdapter(); myDA.SelectCommand = mycomd; //将数据保存至数据集 DataSet myDS = new DataSet(); int n = myDA.Fill(myDS, "login"); if (n != 0) { string studentname = myDS.Tables["login"].Rows[0]["sname"].ToString(); string studentnumber = myDS.Tables["login"].Rows[0]["sno"].ToString(); string studentsex = myDS.Tables["login"].Rows[0]["ssex"].ToString(); string studentpass = myDS.Tables["login"].Rows[0]["spass"].ToString(); string studentbirth = myDS.Tables["login"].Rows[0]["sbirth"].ToString(); string deptname = myDS.Tables["login"].Rows[0]["dname"].ToString(); string majorname = myDS.Tables["login"].Rows[0]["mname"].ToString(); Session["stuname"] = studentname; Session["stunum"] = studentnumber; Session["stusex"] = studentsex; Session["stupass"] = studentpass; Session["stubirth"] = studentbirth; Session["deptn"] = deptname; Session["majorn"] = majorname; Response.Redirect("StudentMainPage.aspx"); } else { Page.ClientScript.RegisterClientScriptBlock(GetType(), "Attention", "<script>alert('编号或密码有误,请重新输入');</script>"); Textbox1.Text = ""; Textbox2.Text = ""; } } else if (RadioButton2.Checked) { string adminsql = "select ano,aname,apass,asex,aright from tb_admin where ano='" + usernumber + "' and apass='******'"; SqlDataAdapter sda = new SqlDataAdapter(adminsql, myconn); DataSet ds = new DataSet(); int dsc = sda.Fill(ds, "admin"); if (dsc != 0) { string adminnumber = ds.Tables["admin"].Rows[0]["ano"].ToString(); string adminname = ds.Tables["admin"].Rows[0]["aname"].ToString(); string adminpass = ds.Tables["admin"].Rows[0]["apass"].ToString(); string adminsex = ds.Tables["admin"].Rows[0]["asex"].ToString(); string adminright = ds.Tables["admin"].Rows[0]["aright"].ToString(); Session["adminnum"] = adminnumber; Session["adminpass"] = adminpass; Session["adminsex"] = adminsex; Session["adminname"] = adminname; Session["adminright"] = adminright; Response.Redirect("AdminMainPage.aspx"); } else { Page.ClientScript.RegisterClientScriptBlock(GetType(), "Attention", "<script>alert('编号或密码有误,请重新输入');</script>"); Textbox1.Text = ""; Textbox2.Text = ""; } } else if (RadioButton3.Checked) { string teachersql = "select tno,dno,tname,tsex,tpass from tb_teacher where tno='" + usernumber + "' and tpass='******'"; SqlDataAdapter sda = new SqlDataAdapter(teachersql, myconn); DataSet ds = new DataSet(); int dsc = sda.Fill(ds, "teacher"); if (dsc != 0) { string teachernumber = ds.Tables["teacher"].Rows[0]["tno"].ToString(); string deptnumber = ds.Tables["teacher"].Rows[0]["dno"].ToString(); string teachername = ds.Tables["teacher"].Rows[0]["tname"].ToString(); string teacherpass = ds.Tables["teacher"].Rows[0]["tpass"].ToString(); string teachersex = ds.Tables["teacher"].Rows[0]["tsex"].ToString(); Session["thnnum"] = teachernumber; Session["deptnum"] = deptnumber; Session["thname"] = teachername; Session["thpass"] = teacherpass; Session["thsex"] = teachersex; Response.Redirect("TeacherMainPage.aspx"); } else { Page.ClientScript.RegisterClientScriptBlock(GetType(), "Attention", "<script>alert('编号或密码有误,请重新输入');</script>"); Textbox1.Text = ""; Textbox2.Text = ""; } } DataBaseUtil.closeDB(); //Server.Transfer("TestingRedirect.aspx"); }
protected void Page_Load(object sender, EventArgs e) { //Label1.Text = Session["stuname"].ToString();//test Session DataBaseUtil.connectDB(); }