protected void Page_Load(object sender, EventArgs e) { string op = Context.Request.Form["op"]; string op1 = Context.Request.QueryString["op"]; //下拉专业ID string dropstrWhere = Request.QueryString["dropstrWhere"]; //下拉批次ID string batchWhere = Request.QueryString["batchWhere"]; //下拉分院ID string collegeIdstWhere = Request.QueryString["collegeIdstrWhere"]; //搜索信息 string strsearch = Request.QueryString["search"]; //获取登录者信息、判断是分院管理员还是超管 userType = Session["state"].ToString(); collegeAdmin = (Teacher)Session["user"]; if (userType == "0") { //0为超级管理员 bads = colbll.Select(); prods = probll.Select(); if (collegeIdstWhere == "0" || collegeIdstWhere == "null" || collegeIdstWhere == null) { plands = planbll.Select(); } else { plands = planbll.GetplanByCollegeId(int.Parse(collegeIdstWhere)); } if (collegeIdstWhere != null && collegeIdstWhere != "null" && batchWhere == "null") { // 分院id不为空,批次id为空 getPage(Searchcollege()); } else if (batchWhere != null && batchWhere != "null" && (collegeIdstWhere == "null" || collegeIdstWhere == "0")) { // 分院id为空,批次id不为空 getPage(batcchdrop()); } else if (collegeIdstWhere != null && collegeIdstWhere != "null" && batchWhere != null && batchWhere != "null") { //两个都不为空 getPage(SearchCollegeAndBatch()); } else if (strsearch != null) { getPage(Search()); } else { getPage(""); } } else if (userType == "2") { //2为分院管理员 //获取分管所在分院ID int collegeId = collegeAdmin.college.ColID; prods = probll.SelectByCollegeId(collegeId); plands = planbll.GetplanByCollegeId(collegeId); if (dropstrWhere != null && dropstrWhere != "null" && batchWhere == "null") {// 如果批次id为空,专业id不为空 getPage(Searchdrop()); } else if (batchWhere != null && batchWhere != "null" && (dropstrWhere == "null" || dropstrWhere == "0")) {// 如果专业id为空,批次id不为空 getPage(batcchdrop()); } else if (dropstrWhere != null && dropstrWhere != "null" && batchWhere != null && batchWhere != "null") { //两个都不为空 getPage(SearchProAndBatch()); } else if (strsearch != null) { getPage(Search()); } else { getPage(""); } } else { prods = probll.Select(); plands = planbll.Select(); getPage(""); } if (op == "del") {//删除 IsdeleteCollege(); delPro(); } //导出列表 if (op1 == "export") { //分院id string collegeId = Request.QueryString["collegeIdstrWhere"]; //专业id string pro = Request.QueryString["dropstrWhere"]; //批次Id string batch = Request.QueryString["batchWhere"]; //输入框条件 string input = Request.QueryString["search"]; string strWhere = ""; if (userType == "2") { if (input == null) { if ((pro == "null" || pro == "0") && batch == "null") { strWhere = string.Format(""); } else if (pro != "null" && batch == "null") { strWhere = string.Format(" where proId = {0}", "'" + pro + "'"); } else if ((pro == "null" || pro == "0") && batch != "null") { strWhere = string.Format(" where planId = {0}", "'" + batch + "'"); } else { strWhere = string.Format(" where planId = {0} and proId = {1}", "'" + batch + "'", "'" + pro + "'"); } } //如果不为空传 input里的值 else { strWhere = string.Format(" where teaName {0} or title {0} or realName {0} or planName {0} or proName {0} or collegeName {0}", "like '%" + input + "%'"); } } else { if (input == null) { if (collegeId == "null" && batch == "null") { strWhere = string.Format(""); } else if (collegeId != "null" && batch == "null") { strWhere = string.Format(" where collegeId = {0}", "'" + collegeId + "'"); } else if ((collegeId == "null" || collegeId == "0") && batch != "null") { strWhere = string.Format(" where planId = {0}", "'" + batch + "'"); } else { strWhere = string.Format(" where planId = {0} and collegeId = {1}", "'" + batch + "'", "'" + collegeId + "'"); } } //如果不为空传 input里的值 else { strWhere = string.Format(" where teaName {0} or title {0} or realName {0} or planName {0} or proName {0} or collegeName {0}", "like '%" + input + "%'"); } } TitleRecordBll titlerd = new TitleRecordBll(); try { var name = DateTime.Now.ToString("yyyyMMddhhmmss") + new Random(DateTime.Now.Second).Next(10000); DataTable dt = titlerd.ExportExcel(strWhere); if (dt != null && dt.Rows.Count > 0) { var path = Server.MapPath("~/download/选题记录导出/" + name + ".xls"); ExcelHelper.x2003.TableToExcelForXLS(dt, path); downloadfile(path); } else { Response.Write("<script language='javascript'>alert('查询不到数据,不能执行导出操作!')</script>"); } } catch (Exception ex) { LogHelper.Error(this.GetType(), ex); } } }