protected void Page_Load(object sender, EventArgs e) { if (Session["identity"] == null || Session["identity"].ToString() != "teacher") { Response.Redirect("../../404.aspx"); } string cmdsql = "SELECT t.*, d.name " + "FROM teacher t, department d " + "where tno='" + Session["id"].ToString() + "' and t.depart = d.no;"; OperateDataBase odb = new OperateDataBase(); SqlDataReader myRead = odb.ExceRead(cmdsql); if (myRead.HasRows) { while (myRead.Read()) { lblTname.Text = myRead["tname"].ToString(); lblGender.Text = myRead["gender"].ToString(); lblDepart.Text = myRead["name"].ToString(); lblProf.Text = myRead["prof"].ToString(); } myRead.Close(); } else { Response.Write("<script>alert(\"查询失败\")</script>"); } /*lblDno.Text = ddlDepart.SelectedValue; * txtDno.Text = lblDno.Text; * lblDname.Text = ddlDepart.Text; * txtDname.Text = lblDname.Text; * lblPcno.Text = ddlPcno.Text; * lblTno.Text = ddlTno.Text;*/ }
protected void btnSelect_Click(object sender, EventArgs e) { string cmdsql = "SELECT c1.*, c2.cname AS pcname, t.tname " + "FROM course c1 LEFT JOIN course c2 ON c1.pcno=c2.cno , teacher t " + "WHERE t.tno=c1.tno and c1.cno='" + ddlCourse.SelectedValue + "';"; OperateDataBase odb = new OperateDataBase(); SqlDataReader myRead = odb.ExceRead(cmdsql); if (myRead.HasRows) { while (myRead.Read()) { lblCname.Text = myRead["cname"].ToString(); if (myRead["pcno"].ToString() != " ") { lblPcno.Text = myRead["pcname"].ToString(); } else { lblPcno.Text = "无"; } lblTno.Text = myRead["tname"].ToString(); } myRead.Close(); } else { Response.Write("<script>alert(\"查询失败\")</script>"); } }
protected void ddlCourse_SelectedIndexChanged(object sender, EventArgs e) { string cmdsql = "SELECT * FROM teacher " + "where tno='" + ddlTeacher.SelectedValue + "';"; OperateDataBase odb = new OperateDataBase(); SqlDataReader myRead = odb.ExceRead(cmdsql); if (myRead.HasRows) { while (myRead.Read()) { lblOldTno.Text = myRead["tno"].ToString(); txtNewTno.Text = lblOldTno.Text; lblOldTname.Text = myRead["tname"].ToString(); txtNewTname.Text = lblOldTname.Text; lblOldGender.Text = myRead["gender"].ToString(); ddlNewGender.SelectedValue = lblOldGender.Text; lblOldAge.Text = myRead["age"].ToString(); txtNewAge.Text = lblOldAge.Text; lblOldDepart.Text = myRead["depart"].ToString(); ddlNewDepart.SelectedValue = lblOldDepart.Text; lblOldProf.Text = myRead["prof"].ToString(); txtNewProf.Text = lblOldProf.Text; } myRead.Close(); } else { Response.Write("<script>alert(\"查询失败\")</script>"); } }
protected void btnSelect_Click(object sender, EventArgs e) { string cmdsql = "SELECT t.*, d.name AS dname " + "FROM teacher t, department d " + "WHERE t.depart=d.no AND tno='" + ddlTeacher.SelectedValue + "';"; OperateDataBase odb = new OperateDataBase(); SqlDataReader myRead = odb.ExceRead(cmdsql); if (myRead.HasRows) { while (myRead.Read()) { lblOldTno.Text = myRead["tno"].ToString(); txtNewTno.Text = lblOldTno.Text; lblOldTname.Text = myRead["tname"].ToString(); txtNewTname.Text = lblOldTname.Text; lblOldGender.Text = myRead["gender"].ToString(); ddlNewGender.SelectedValue = lblOldGender.Text; lblOldAge.Text = myRead["age"].ToString(); txtNewAge.Text = lblOldAge.Text; lblOldDepart.Text = myRead["dname"].ToString(); ddlNewDepart.SelectedValue = myRead["depart"].ToString(); lblOldProf.Text = myRead["prof"].ToString(); txtNewProf.Text = lblOldProf.Text; } myRead.Close(); } else { Response.Write("<script>alert(\"查询失败\")</script>"); } }
protected void ddlCourse_SelectedIndexChanged(object sender, EventArgs e) { lblCno.Text = ddlCourse.SelectedValue; txtCno.Text = lblCno.Text; lblCname.Text = ddlCourse.Text; txtCname.Text = lblCname.Text; lblPcno.Text = ddlPcno.Text; lblTno.Text = ddlTno.Text; string cmdsql = "SELECT * " + "FROM course " + "WHERE cno='" + ddlCourse.SelectedValue + "';"; OperateDataBase odb = new OperateDataBase(); SqlDataReader myRead = odb.ExceRead(cmdsql); if (myRead.HasRows) { while (myRead.Read()) { lblCname.Text = myRead["cname"].ToString(); txtCname.Text = lblCname.Text; } myRead.Close(); } else { Response.Write("<script>alert(\"查询失败\")</script>"); } }
protected void btnSelect_Click(object sender, EventArgs e) { string cmdsql = "SELECT s.*, d.name " + "FROM student s, department d " + "WHERE sno='" + Session["id"].ToString() + "' and s.depart=d.no;"; OperateDataBase odb = new OperateDataBase(); SqlDataReader myRead = odb.ExceRead(cmdsql); if (myRead.HasRows) { while (myRead.Read()) { lblSno.Text = myRead["sno"].ToString(); lblSname.Text = myRead["sname"].ToString(); lblGender.Text = myRead["gender"].ToString(); lblAge.Text = myRead["age"].ToString(); lblDepart.Text = myRead["name"].ToString(); lblSpecialst.Text = myRead["specialty"].ToString(); } myRead.Close(); } else { Response.Write("<script>alert(\"查询失败\")</script>"); } }
protected void btnSelect_Click(object sender, EventArgs e) { string cmdsql = "SELECT s.*, d.name AS dname " + "FROM student s, department d " + "WHERE sno='" + ddlStudent.SelectedValue + "' and s.depart=d.no;"; OperateDataBase odb = new OperateDataBase(); SqlDataReader myRead = odb.ExceRead(cmdsql); if (myRead.HasRows) { while (myRead.Read()) { lblOldSno.Text = myRead["sno"].ToString(); txtNewSno.Text = lblOldSno.Text; lblOldSname.Text = myRead["sname"].ToString(); txtNewSname.Text = lblOldSname.Text; lblOldGender.Text = myRead["gender"].ToString(); ddlNewGender.SelectedValue = lblOldGender.Text; lblOldAge.Text = myRead["age"].ToString(); txtNewAge.Text = lblOldAge.Text; lblOldDepart.Text = myRead["dname"].ToString(); ddlNewDepart.SelectedValue = myRead["depart"].ToString(); lblOldSpecialty.Text = myRead["specialty"].ToString(); txtNewSpecialty.Text = lblOldSpecialty.Text; } myRead.Close(); } else { Response.Write("<script>alert(\"查询失败\")</script>"); } }
protected void btnSelect_Click(object sender, EventArgs e) { string cmdsql = "SELECT t.*, d.name " + "FROM teacher t, department d " + "where tno='" + ddlTeacher.SelectedValue + "' and t.depart = d.no;"; OperateDataBase odb = new OperateDataBase(); SqlDataReader myRead = odb.ExceRead(cmdsql); if (myRead.HasRows) { while (myRead.Read()) { lblTno.Text = myRead["tno"].ToString(); lblTname.Text = myRead["tname"].ToString(); lblGender.Text = myRead["gender"].ToString(); lblAge.Text = myRead["age"].ToString(); lblDepart.Text = myRead["name"].ToString(); lblProf.Text = myRead["prof"].ToString(); } myRead.Close(); } else { Response.Write("<script>alert(\"查询失败\")</script>"); } }
protected void btnSelect_Click(object sender, EventArgs e) { lblDno.Text = ddlDepart.SelectedValue; txtDno.Text = lblDno.Text; lblDean.Text = ddlDean.Text; string cmdsql = "SELECT d.*, t.tname " + "FROM department d, teacher t " + "WHERE d.no='" + ddlDepart.SelectedValue + "' AND d.dean=t.tno;"; OperateDataBase odb = new OperateDataBase(); SqlDataReader myRead = odb.ExceRead(cmdsql); if (myRead.HasRows) { while (myRead.Read()) { lblDname.Text = myRead["name"].ToString(); txtDname.Text = lblDname.Text; ddlDean.SelectedValue = myRead["dean"].ToString(); lblDean.Text = myRead["tname"].ToString(); } myRead.Close(); } else { Response.Write("<script>alert(\"查询失败\")</script>"); } }
protected void btnSelect_Click(object sender, EventArgs e) { string cmdsql = "SELECT grade FROM score " + "WHERE sno='" + ddlStudent.SelectedValue + "' and cno='" + ddlCourse.SelectedValue + "';"; OperateDataBase odb = new OperateDataBase(); SqlDataReader myRead = odb.ExceRead(cmdsql); if (myRead.HasRows) { while (myRead.Read()) { lblGrade.Text = myRead["grade"].ToString(); } myRead.Close(); } else { Response.Write("<script>alert(\"查询失败\")</script>"); } }
protected void ddlDepart_SelectedIndexChanged(object sender, EventArgs e) { lblDname.Text = ddlDepart.Text; string cmdsql = "SELECT * " + "FROM department " + "WHERE no='" + ddlDepart.SelectedValue + "';"; OperateDataBase odb = new OperateDataBase(); SqlDataReader myRead = odb.ExceRead(cmdsql); if (myRead.HasRows) { while (myRead.Read()) { lblDname.Text = myRead["name"].ToString(); } myRead.Close(); } else { Response.Write("<script>alert(\"查询失败\")</script>"); } }