public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/x-excel"; //将HTTP头添加到输出流,设置默认导出的文件名 string CourseName = context.Request.QueryString["CourseName"].ToString(); string filename = HttpUtility.UrlEncode(CourseName + "学生信息表.xls"); context.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename); //创建Excel工作簿和工作表 HSSFWorkbook workbook = new HSSFWorkbook(); ISheet newsheet = workbook.CreateSheet("学生成绩表"); //创建工作表的标题 IRow rowHeader = newsheet.CreateRow(0); rowHeader.CreateCell(0, CellType.Numeric).SetCellValue("学号"); rowHeader.CreateCell(1, CellType.String).SetCellValue("姓名"); rowHeader.CreateCell(2, CellType.String).SetCellValue("班级"); rowHeader.CreateCell(3, CellType.Numeric).SetCellValue("联系方式"); //查询数据 int CourseId = Convert.ToInt32(context.Request.QueryString["CourseId"]); List <Students> stulist = new StudentManage().queryStudentByCourseId(CourseId); for (int i = 0; i < stulist.Count; i++) { IRow newRow = newsheet.CreateRow(i + 1); newRow.CreateCell(0, CellType.Numeric).SetCellValue(stulist[i].StuId); newRow.CreateCell(1, CellType.Numeric).SetCellValue(stulist[i].StuName); newRow.CreateCell(2, CellType.Numeric).SetCellValue(stulist[i].ClassId); newRow.CreateCell(3, CellType.Numeric).SetCellValue(stulist[i].StuPhoneNum); } //将输出流写入Excel工作簿 workbook.Write(context.Response.OutputStream); }
public ActionResult DeleteStudent(string stuId) { //string studentId = Request.QueryString["stuId"]; int result = new StudentManage().DeleteStudent(stuId); return(Content("<script>alert('Delete Successfully'); document.location='" + Url.Action("Index", "Student") + "'</script>")); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int CourseId = Convert.ToInt32(Request.Params["CourseId"]); int StuNumber = new CourseManege().QueryStuNum(CourseId); StuNum.Text = StuNumber.ToString(); List <Model.Class> clalist = new CourseManege().queryClassByCourseId(CourseId); string ClassId; foreach (Model.Class Class in clalist) { ClassId = Class.ClassId; ddlclass.Items.Add(ClassId); } List <Students> stulist = new StudentManage().queryStudentByCourseId(CourseId); Repeater1.DataSource = stulist; Repeater1.DataBind(); int ScoreNum = new ScoreManage().queryCouseScoreNum(CourseId); //当前该课程只要有记录记录则无法在添加学生成绩,此处可扩展, if (ScoreNum > 0) { Button2.Enabled = false; Literal1.Text = "该课程已完成成绩录入"; } } }
protected void btn_sub_Click(object sender, EventArgs e) { Students stu = new Students() { StuId = ((Model.Login)Session["CurrentUser"]).UserName, StuName = Name.Text.Trim(), StuSex = Sex.Text.Trim(), StuBirth = Birth.Text.Trim(), Punish = Stupun.Text.Trim(), StuHonor = Stuhonor.Text.Trim(), StuPhoneNum = Pho.Text.Trim(), StuNoId = IdNo.Text.Trim(), StuState = StupoState.Text.Trim(), ClassId = ClassId.Text.Trim(), StuAdd = Add.Text.Trim(), College = CollegeID.Text.Trim(), Major = Major.Text.Trim(), PoliticalStatus = StupoState.Text.Trim() }; int res = new StudentManage().UpdateStudentById(stu); if (res > 0) { Response.Write("<script>alert('修改成功')</script>"); } else { Response.Write("<script>alert('修改失败')</script>"); } }
public ActionResult GetTitles() { var studentManage = new StudentManage(); var titles = studentManage.GetTitles(); return(Json(titles, JsonRequestBehavior.AllowGet)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int CourseId = Convert.ToInt32(Request.Params["CourseId"]); StuNum = new CourseManege().QueryStuNum(CourseId); coursename.Text = (new CourseManege().queryCourseById(CourseId)).CourseName; List <Model.Class> clalist = new CourseManege().queryClassByCourseId(CourseId); string ClassId; foreach (Model.Class Class in clalist) { ClassId = Class.ClassId; ddlclass.Items.Add(ClassId); } List <Students> stulist = new StudentManage().queryStudentByCourseId(CourseId); foreach (Students stu in stulist) { stu.KqNum = new KqManage().queryStuKqNum(stu.StuId, CourseId); stu.HwNum = new HomeworkManage().queryStuHwNum(stu.StuId, CourseId); } Repeater1.DataSource = stulist; Repeater1.DataBind(); List <Homework> HwList = new HomeworkManage().queryAllHKByTea(CourseId); DataList2.DataSource = HwList; DataList2.DataBind(); List <KQ> KqList = new KqManage().queryAllKq(CourseId); Repeater2.DataSource = KqList; Repeater2.DataBind(); List <JXGG> gglist = new GGManage().LookJXGG(CourseId); Repeater3.DataSource = gglist; Repeater3.DataBind(); } }
private void btnStudenManage_Click(object sender, EventArgs e) { StudentManage studentManage = new StudentManage(); studentManage.Show(); this.Close(); }
protected void btn_save_Click(object sender, EventArgs e) { //int id = Convert.ToInt32(Request.QueryString["StuId"]); StudentManage bll = new StudentManage(); Students stu = new Students(); stu.StuId = Convert.ToInt32(txt_stuid.Text); stu.StuName = txt_stuname.Text; stu.StuSex = txt_sex.Text; stu.StuBirth = txt_birth.Text; stu.StuAdd = txt_address.Text; stu.Punish = txt_punish.Text; stu.StuPhoneNum = txt_phone.Text; stu.StuHonor = txt_honor.Text; stu.College = txt_xueyuan.Text; stu.Major = txt_major.Text; stu.ClassId = txt_class.Text; stu.StuNoId = txt_noid.Text; stu.StuState = txt_ps.Text; stu.PoliticalStatus = txt_mianmao.Text; if (bll.UpdateStudentById(stu) == 1) { Response.Write("<script>alert('成功');</script>"); } else { Response.Write("<script>alert('失败');</script>"); } }
/// <summary> ///Handle Button Login click event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ButtonLogin_Click(object sender, EventArgs e) { if (ValidateForm()) { var studentManage = new StudentManage(); var auth = new Authenticator(); var am = new AdmissionManage(); var registrationId = 0; try { registrationId = am.GetAdmisionIdFromString(txtEnrollNumber.Text); } catch (Exception) { ShowMessage("Invalid Enrollnumber"); } var password = auth.EncodePassword(txtPassword.Text); var ds = studentManage.StudentLogin(registrationId, password); if (ds.Tables[0].Rows.Count == 0) { ShowMessage("Login failed. Invalid Enrollnumber or Password"); } else { Session["student"] = txtEnrollNumber.Text; StudentLoginForm.Visible = false; Page.ClientScript.RegisterClientScriptBlock(GetType(), "alert", "alert('Welcome: " + txtEnrollNumber.Text + "');document.location.href='Student.aspx';", true); } } }
protected void btn_searchstu_Click(object sender, EventArgs e) { string name = txt_name.Text.Trim(); StudentManage bll = new StudentManage(); if (name == "") { if ((ddlxueyuan.SelectedItem.Text != "" && ddlxueyuan.SelectedItem.Text != "请选择")) { string college = Request.Form["ddlxueyuan"]; Repeater1.DataSource = bll.QueryStuByCollege(college); Repeater1.DataBind(); } else if (ddlmajor.SelectedItem.Text != " " && ddlmajor.SelectedItem.Text != "请选择") { string major = Request.Form["ddlmajor"]; Repeater1.DataSource = bll.QueryStuByMajor(major); Repeater1.DataBind(); } else if (ddlclass.SelectedValue != " ") { string classid = Request.Form["ddlclass"]; Repeater1.DataSource = bll.QueryStuByClassId(classid); Repeater1.DataBind(); } } else { Repeater1.DataSource = bll.QueryStuByName(name); Repeater1.DataBind(); } }
public ActionResult DeleteStudent(int enrollmentId) { var status = false; var studentManage = new StudentManage(); status = studentManage.DeleteStudent(enrollmentId); return(Json(status, JsonRequestBehavior.AllowGet)); }
//通过学号查学生 protected void btn_searchStuId_Click(object sender, EventArgs e) { int StuId = Convert.ToInt32(txt_StuId.Text.Trim()); List <Students> stulist = new StudentManage().TeaqueryStudentByStuId(StuId); Repeater1.DataSource = stulist; Repeater1.DataBind(); }
//通过姓名模糊查询 protected void btn_searchstu_Click(object sender, EventArgs e) { int CourseId = Convert.ToInt32(Request.Params["CourseId"]); string StuName = txt_name.Text.Trim().ToString(); List <Students> stulist = new StudentManage().TeaqueryStudentByStuName(StuName, CourseId); Repeater1.DataSource = stulist; Repeater1.DataBind(); }
public ActionResult GetStudent(string stuId) { List <StudentClass> objStudentClasses = new StudentClassManage().GetAllClasses(); ViewBag.clsList = objStudentClasses; //string studentId = Request.QueryString["stuId"]; Student objStudent = new StudentManage().GetStudent(stuId); return(View("EditStudent", objStudent)); }
public ActionResult GetList(string queryClass) { //string queryClass = Request.Params["query"].ToString(); List <Student> objStudents = new StudentManage().GetListByClassId(queryClass); ViewBag.className = queryClass; ViewBag.stuList = objStudents; return(View("StudentManage")); }
public ActionResult UpdateStudent(Student student) { var status = false; if (ModelState.IsValid) { var studentManage = new StudentManage(); status = studentManage.SetStudent(student); } return(Json(status)); }
//班级下拉框改变 protected void ddlclass_SelectedIndexChanged(object sender, EventArgs e) { string college = ddlxueyuan.SelectedItem.Value.Trim().ToString(); string collegeId = ddlxueyuan.SelectedValue.Trim().ToString(); string majorId = ddlmajor.SelectedValue.Trim().ToString(); string classId = ddlclass.SelectedValue.Trim().ToString(); List <Students> stuList = new StudentManage().QueryStu(0, "", classId, college, majorId); Repeater1.DataSource = stuList; Repeater1.DataBind(); }
public ActionResult ViewStudent(string stuId) { //string studentId = Request.QueryString["stuId"]; Student objStudent = new StudentManage().GetStudent(stuId); ViewData["student"] = objStudent; string className = new StudentClassManage().GetClassNameById(objStudent.ClassId.ToString()); ViewData["className"] = className; return(View("ViewStudent")); }
public ActionResult GetStudents(StudentDataRequest request) { var studentManage = new StudentManage(); var students = studentManage.GetStudents(request); return(Json(new { draw = request.Draw, recordsFiltered = students.TotalRecord, recordTotal = students.TotalRecord, Student = students.Students }, JsonRequestBehavior.AllowGet)); }
//学号查询 protected void btn_SearchStuId_Click(object sender, EventArgs e) { string ClassId = Convert.ToString(Request.Params["ClassId"]); int StuId = Convert.ToInt32(txt_StuId.Text.Trim()); List <Students> stulist = new StudentManage().FDYqueryStudentByStuId(StuId, ClassId); foreach (Students stu in stulist) { stu.GKNum = new ScoreManage().queryGKNum(stu.StuId); stu.YXNum = new ScoreManage().queryYXNum(stu.StuId); } Repeater1.DataSource = stulist; Repeater1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { int stuId = ((Model.Login)Session["CurrentUser"]).UserName; Students stu = new StudentManage().QueryStuById(stuId); StuId.Text = stu.StuId.ToString(); StuName.Text = stu.StuName.ToString(); StuSex.Text = stu.StuSex.ToString(); StuBirth.Text = stu.StuBirth.ToString(); StuAdd.Text = stu.StuAdd.ToString(); pun.Text = stu.Punish.ToString(); StuPho.Text = stu.StuPhoneNum.ToString(); honor.Text = stu.StuHonor.ToString(); Col.Text = stu.College.ToString(); Major.Text = stu.Major.ToString(); Class.Text = stu.ClassId.ToString(); }
protected void Page_Load(object sender, EventArgs e) { int stuId = Convert.ToInt32(Request.QueryString["StuId"]); Students stu = new StudentManage().QueryStuById(stuId); txt_stuid.Text = stu.StuId.ToString(); txt_stuname.Text = stu.StuName.ToString(); txt_sex.Text = stu.StuSex.ToString(); txt_birth.Text = stu.StuBirth.ToString(); txt_address.Text = stu.StuAdd.ToString(); txt_punish.Text = stu.Punish.ToString(); txt_phone.Text = stu.StuPhoneNum.ToString(); txt_honor.Text = stu.StuHonor.ToString(); txt_xueyuan.Text = stu.College.ToString(); txt_major.Text = stu.Major.ToString(); txt_class.Text = stu.ClassId.ToString(); }
protected void Page_Load(object sender, EventArgs e) { int stuId = Convert.ToInt32(Request.QueryString["StuId"]); Students stu = new StudentManage().QueryStuById(stuId); StuId.Text = stu.StuId.ToString(); StuName.Text = stu.StuName.ToString(); StuSex.Text = stu.StuSex.ToString(); StuBirth.Text = stu.StuBirth.ToString(); StuAdd.Text = stu.StuAdd.ToString(); pun.Text = stu.Punish.ToString(); StuPho.Text = stu.StuPhoneNum.ToString(); honor.Text = stu.StuHonor.ToString(); Col.Text = stu.College.ToString(); Major.Text = stu.Major.ToString(); Class.Text = stu.ClassId.ToString(); }
protected void Page_Load(object sender, EventArgs e) { int stuId = ((Model.Login)Session["CurrentUser"]).UserName; Students stu = new StudentManage().QueryStuById(stuId); txt_stuid.Text = stu.StuId.ToString(); txt_stuname.Text = stu.StuName.ToString(); txt_sex.Text = stu.StuSex.ToString(); txt_birth.Text = stu.StuBirth.ToString(); txt_address.Text = stu.StuAdd.ToString(); txt_punish.Text = stu.Punish.ToString(); txt_phone.Text = stu.StuPhoneNum.ToString(); txt_honor.Text = stu.StuHonor.ToString(); txt_xueyuan.Text = stu.College.ToString(); txt_major.Text = stu.Major.ToString(); txt_class.Text = stu.ClassId.ToString(); }
protected void btn_searchstu_Click(object sender, EventArgs e) { string name = txt_name.Text.Trim(); StudentManage bll = new StudentManage(); int StuId = 0; if (txt_id.Text.Trim() != "") { StuId = Convert.ToInt32(txt_id.Text.Trim()); } string collegeId = ddlxueyuan.SelectedValue.Trim().ToString(); string majorId = ddlmajor.SelectedValue.Trim().ToString(); string classId = ddlclass.SelectedValue.Trim().ToString(); Repeater1.DataSource = new StudentManage().QueryStu(StuId, name, classId, collegeId, majorId); Repeater1.DataBind(); }
//专业下拉框改变 protected void ddlmajor_SelectedIndexChanged(object sender, EventArgs e) { string college = ddlxueyuan.SelectedItem.Value.Trim().ToString(); string collegeId = ddlxueyuan.SelectedValue.Trim().ToString(); string majorId = ddlmajor.SelectedValue.Trim().ToString(); List <Students> stuList = new StudentManage().QueryStu(0, "", "", college, majorId); Repeater1.DataSource = stuList; Repeater1.DataBind(); //班级下拉框联动 List <Model.Class> clalist = new queryManage().querAllCla(collegeId, majorId); ddlclass.DataSource = clalist; ddlclass.DataTextField = "ClassId"; ddlclass.DataBind(); ddlclass.Items.Insert(0, new ListItem("请选择", "")); }
public ActionResult AddStudent(Student objStudent) { //Student objStudent = new Student() //{ // StudentName = Request.Params["studentName"], // Gender = Request.Params["gender"], // Birthday = Convert.ToDateTime( Request.Params["birthday"]), // StudentIdNo = Request.Params["studentIdNo"], // CardNo = Request.Params["cardNo"], // PhoneNumber = Request.Params["phoneNumber"], // StudentAddress = Request.Params["studentAddress"], // ClassId = Convert.ToInt32(Request.Params["ClassId"]) //}; int result = new StudentManage().InsertStudent(objStudent); return(Content("<script>alert('Add Successfully'); document.location='" + Url.Action("Index", "Student") + "'</script>")); }
//删除学生 protected void btn_Del_Click(object sender, EventArgs e) { int StuId = Convert.ToInt32(((LinkButton)sender).CommandArgument); int res = new StudentManage().DeleteStudentById(StuId); if (res > 0) { System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "", "alert('删除成功');", true); } else if (res == -1) { System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "", "alert('该学生有未完成的课程无法删除');", true); } else { System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "", "alert('删除失败');", true); } }
public void UserLogin() { if (ddlSelect.SelectedValue == "教师") { TeacherManage tm = new TeacherManage(); tm.TeacherLogin(txtName.Text.ToString().Trim(), txtPwd.Text.ToString().Trim()); } else if (ddlSelect.SelectedValue == "学生") { StudentManage sm = new StudentManage(); sm.StudentLogin(txtName.Text.ToString().Trim(), txtPwd.Text.ToString().Trim()); } else { TeacherManage tm = new TeacherManage(); tm.AdminLogin(txtName.Text.ToString().Trim(), txtPwd.Text.ToString().Trim()); } }
protected void ddlclass_SelectedIndexChanged(object sender, EventArgs e) { string ClassId = ddlclass.SelectedItem.Text.Trim(); int CourseId = Convert.ToInt32(Request.Params["CourseId"]); if (ClassId == "请选择") { List <Students> stulist = new StudentManage().queryStudentByCourseId(CourseId); Repeater1.DataSource = stulist; Repeater1.DataBind(); } else { List <Students> stuList = new StudentManage().TeaqueryStudentByClassId(CourseId, ClassId); Repeater1.DataSource = stuList; Repeater1.DataBind(); } }