/// <summary> /// 执行选题操作 /// </summary> public void StusecltTitle() { try { //string stuId = Context.Request["stuId"].ToString(); stu = (Student)Session["loginuser"]; int titleid = int.Parse(Context.Request.QueryString["titleId"]); Title dstitle = new Title(); TitleBll titleSelect = new TitleBll(); dstitle = titleSelect.GetTitle(titleid); int limited = int.Parse(dstitle.Limit.ToString()); int selected = int.Parse(dstitle.Selected.ToString()); if (selected < limited) { Result row = isExist(); if (row == Result.记录不存在) { LogHelper.Info(this.GetType(), stu.StuAccount + " - " + stu.RealName + " - 学生选题 - " + dstitle.TitleId + dstitle.title); TitleRecord titleRecord = new TitleRecord(); titleRecord.student = stu; Title title = new Title(); title.TitleId = titleid; titleRecord.title = title; int rows = pbll.AddTitlerecord(titleRecord); if (rows > 0) { Response.Write("选题成功"); Response.End(); } else { Response.Write("选题失败"); Response.End(); } } else { Response.Write("已选题"); Response.End(); } } else { Response.Write("已达上限"); Response.End(); } } catch (Exception ex) { LogHelper.Error(this.GetType(), ex); } }
/// <summary> /// 获取数据 /// </summary> /// <param name="strWhere">查询条件</param> public void getdata(String strWhere) { string currentPage = Request.QueryString["currentPage"]; if (currentPage == null || currentPage.Length <= 0) { currentPage = "1"; } TitleBll titbll = new TitleBll(); Teacher tea = (Teacher)Session["loginuser"]; string teaAccount = tea.TeaAccount; string account = "teaAccount = '" + teaAccount + "'"; string Account = "teaAccount = '" + teaAccount + "' and "; TableBuilder tabuilder = new TableBuilder(); tabuilder.StrTable = "V_Title"; tabuilder.StrWhere = (strWhere == null || strWhere == "" ? account : Account + strWhere); tabuilder.IntColType = 0; tabuilder.IntOrder = 1; tabuilder.IntPageNum = int.Parse(currentPage); tabuilder.IntPageSize = pagesize; tabuilder.StrColumn = "titleId"; tabuilder.StrColumnlist = "*"; getCurrentPage = int.Parse(currentPage); ds = titbll.SelectBypage(tabuilder, out count); //加载所有分院 colds = colbll.Select(); //加载登录教师所在分院的专业 TableBuilder tabuilderPro = new TableBuilder(); tabuilderPro.StrTable = "T_Profession"; tabuilderPro.StrWhere = "collegeId = '" + tea.college.ColID + "'"; tabuilderPro.IntColType = 0; tabuilderPro.IntOrder = 0; tabuilderPro.IntPageNum = 1; tabuilderPro.IntPageSize = 100; tabuilderPro.StrColumn = "proId"; tabuilderPro.StrColumnlist = "*"; prods = probll.SelectBypage(tabuilderPro, out count); //加载登录教师所在分院的批次 TableBuilder tabuilderPlan = new TableBuilder(); tabuilderPlan.StrTable = "T_Plan"; tabuilderPlan.StrWhere = "collegeId = '" + tea.college.ColID + "'"; tabuilderPlan.IntColType = 0; tabuilderPlan.IntOrder = 0; tabuilderPlan.IntPageNum = 1; tabuilderPlan.IntPageSize = 100; tabuilderPlan.StrColumn = "planId"; tabuilderPlan.StrColumnlist = "*"; plads = plabll.SelectBypage(tabuilderPlan, out count); }
protected void Page_Load(object sender, EventArgs e) { TitleRecordBll titleRecordBll = new TitleRecordBll(); TitleBll titleBll = new TitleBll(); //获取登录学生学号 stu = (Student)Session["loginuser"]; string stuAccount = stu.StuAccount.ToString(); ds = titleRecordBll.Select(); if (ds != null) { if (ds.Tables[0].Rows.Count != 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (stuAccount == ds.Tables[0].Rows[i]["stuAccount"].ToString()) { string tId = ds.Tables[0].Rows[i]["titleId"].ToString(); Title title = titleBll.GetTitle(int.Parse(tId)); string showTitle = title.title.ToString(); if (showTitle != "") { Response.Write("<a href='../PaperDtailStu.aspx'>你已选过题目,请点击跳转到题目详情界面 </a>"); Response.End(); } } } } } //获取op titiId string op = Context.Request.QueryString["op"]; string titleid = Context.Request.QueryString["titleId"]; //获取学生专业id string proId = stu.profession.ProId.ToString(); if (!Page.IsPostBack) { if (proId != null) { proId = "proId=" + proId; getPage(proId); } } if (op == "selectTitle") { StusecltTitle(); } }
protected void Page_Load(object sender, EventArgs e) { state = Session["state"].ToString(); string op = Context.Request.QueryString["op"]; titleid = Request.QueryString["titleId"].ToString(); TitleBll nb = new TitleBll(); titleId = nb.GetTitle(int.Parse(titleid)); if (state == "3") { if (op == "selectTitle") { StusecltTitle(); } } }
/// <summary> /// 编辑题目 /// </summary> public void editTitle() { int titleId = int.Parse(Context.Request["titleId"].ToString()); string planId = Context.Request["planId"].ToString(); TitleBll titleBll = new TitleBll(); bool state = titleBll.selectByplanId(planId); if (state) { Response.Write("批次已激活,不可编辑"); Response.End(); } else { //Response.Redirect("addPaper.aspx?state=1"); } }
/// <summary> /// 获取数据 /// </summary> /// <param name="strWhere">查询条件</param> public void getdata(String strWhere) { string where = ""; Teacher teacher = new Teacher(); string currentPage = Request.QueryString["currentPage"]; if (currentPage == null || currentPage.Length <= 0) { currentPage = "1"; } if (state == "0") { where = ""; dsColl = colbll.Select(); dsPro = probll.SelectByCollegeId(Convert.ToInt32(Session["collegeId"])); dsPlan = plabll.getPlanByCid(Convert.ToInt32(Session["collegeId"])); } else if (state == "1") { teacher = (Teacher)Session["loginuser"]; where = "collegeId = '" + teacher.college.ColID + "'"; dsPro = probll.SelectByCollegeId(teacher.college.ColID); dsPlan = plabll.getPlanByCid(teacher.college.ColID); } else if (state == "2") { teacher = (Teacher)Session["user"]; where = "collegeId = '" + teacher.college.ColID + "'"; dsPro = probll.SelectByCollegeId(teacher.college.ColID); dsPlan = plabll.getPlanByCid(teacher.college.ColID); } TitleBll titbll = new TitleBll(); TableBuilder tabuilder = new TableBuilder(); tabuilder.StrTable = "V_Title"; tabuilder.StrWhere = (strWhere == null || strWhere == "" ? where : strWhere); tabuilder.IntColType = 0; tabuilder.IntOrder = 1; tabuilder.IntPageNum = int.Parse(currentPage); tabuilder.IntPageSize = pagesize; tabuilder.StrColumn = "titleId"; tabuilder.StrColumnlist = "*"; getCurrentPage = int.Parse(currentPage); ds = titbll.SelectBypage(tabuilder, out count); }
/// <summary> /// 根据登录者判断加载公告 /// </summary> public void loadNewsList() { state = Session["state"].ToString(); if (state == "0" || state == "2")//根据登录的管理员只显示相关公告 { admin = (Teacher)Session["user"]; colId = admin.college.ColID; teaId = admin.TeaAccount; } else if (state == "1")//根据登录的教师只显示相关公告 { teacher = (Teacher)Session["loginuser"]; colId = teacher.college.ColID; teaId = teacher.TeaAccount; } else//根据登录的学生只显示相关公告 { stu = (Student)Session["loginuser"]; col = stu.college; colId = col.ColID; stuAccount = stu.StuAccount; TitleRecordBll recordBll = new TitleRecordBll(); ds = recordBll.Select(); if (ds != null) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (stuAccount == ds.Tables[0].Rows[i]["stuAccount"].ToString()) { TitleBll titleBll = new TitleBll(); titleId = int.Parse(ds.Tables[0].Rows[i]["titleId"].ToString()); title = titleBll.GetTitle(titleId); teaId = title.teacher.TeaAccount; } } } } }
protected void Page_Load(object sender, EventArgs e) { string op = Context.Request["op"]; article = Request.QueryString["article"]; //调用下拉菜单数据 TeacherBll teabll = new TeacherBll(); //TODO 获取当前登录的教师账号 Teacher tea = (Teacher)Session["loginuser"]; //加载登录教师所在分院的专业 TableBuilder tabuilderPro = new TableBuilder(); tabuilderPro.StrTable = "T_Profession"; tabuilderPro.StrWhere = "collegeId = '" + tea.college.ColID + "'"; tabuilderPro.IntColType = 0; tabuilderPro.IntOrder = 0; tabuilderPro.IntPageNum = 1; tabuilderPro.IntPageSize = 100; tabuilderPro.StrColumn = "proId"; tabuilderPro.StrColumnlist = "*"; prods = probll.SelectBypage(tabuilderPro, out count); //加载登录教师所在分院的批次 TableBuilder tabuilderPlan = new TableBuilder(); tabuilderPlan.StrTable = "T_Plan"; tabuilderPlan.StrWhere = "collegeId = '" + tea.college.ColID + "'"; tabuilderPlan.IntColType = 0; tabuilderPlan.IntOrder = 0; tabuilderPlan.IntPageNum = 1; tabuilderPlan.IntPageSize = 100; tabuilderPlan.StrColumn = "planId"; tabuilderPlan.StrColumnlist = "*"; plands = pbll.SelectBypage(tabuilderPlan, out count); if (article == "edit") { string titleId = Request.QueryString["titleId"]; Session["titleId"] = titleId; TitleBll titBll = new TitleBll(); titleEdit = titBll.GetTitle(Convert.ToInt32(titleId)); //string ti = title.Limit.ToString(); } else { TitleBll titlebll = new TitleBll(); Title title = new Title(); if (op == "new") { try { string paperTitle = Request["paperTitle"].ToString(); string profession = Request["profession"].ToString(); string plans = Request["plan"].ToString(); string numMax = Request["numMax"].ToString(); string paperContent = Request["paperContent"].ToString(); title.title = paperTitle; title.TitleContent = HttpUtility.UrlDecode(paperContent); title.CreateTime = DateTime.Now; //TODO 专业批次选定人数为固定值,需重新改动 title.Selected = 0; title.Limit = int.Parse(numMax); title.teacher = (Teacher)Session["loginuser"]; title.plan = new Plan { PlanId = Convert.ToInt32(plans) }; title.profession = new Profession { ProId = Convert.ToInt32(profession) }; Result result = titlebll.Insert(title); if (result == Result.添加成功) { LogHelper.Info(this.GetType(), tea.TeaAccount + " - " + tea.TeaName + " - 发布论文"); Response.Write("添加成功"); Response.End(); } else { Response.Write("添加失败"); Response.End(); } }catch (Exception ex) { LogHelper.Error(this.GetType(), ex); } } else if (op == "edit") { try { string paperTitle = Request["paperTitle"].ToString(); string profession = Request["profession"].ToString(); string plans = Request["plan"].ToString(); string numMax = Request["numMax"].ToString(); string paperContent = Request["paperContent"].ToString(); title.TitleId = Convert.ToInt32(Session["titleId"].ToString()); title.title = paperTitle; title.TitleContent = HttpUtility.UrlDecode(paperContent); title.CreateTime = DateTime.Now; //TODO 专业批次选定人数为固定值,需重新改动 title.Selected = 0; title.Limit = int.Parse(numMax); title.teacher = tea; title.plan = new Plan { PlanId = 1 }; title.profession = new Profession { ProId = 1 }; Result result = titlebll.Update(title); if (result == Result.更新成功) { LogHelper.Info(this.GetType(), tea.TeaAccount + " - " + tea.TeaName + " - 修改" + Session["titleId"].ToString() + "论文"); Response.Write("更新成功"); Response.End(); } else { Response.Write("更新失败"); Response.End(); } }catch (Exception ex) { LogHelper.Error(this.GetType(), ex); } } } }
/// <summary> /// 执行选题操作 /// </summary> public void StusecltTitle() { //string stuId = Context.Request["stuId"].ToString(); int titleid = int.Parse(Context.Request.QueryString["titleId"]); Title dstitle = new Title(); Plan plan = new Plan(); TitleBll titleSelect = new TitleBll(); PlanBll planBll = new PlanBll(); dstitle = titleSelect.GetTitle(titleid); int limited = int.Parse(dstitle.Limit.ToString()); int selected = int.Parse(dstitle.Selected.ToString()); //获取截止时间 int pid = dstitle.plan.PlanId; plan = planBll.Select(pid); string now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); DateTime nowTime = Convert.ToDateTime(now); string end = plan.EndTime.ToString("yyyy-MM-dd HH:mm:ss"); DateTime endTime = Convert.ToDateTime(end); try { if (nowTime <= endTime) { if (selected < limited) { Result row = isExist(); if (row == Result.记录不存在) { TitleRecord titleRecord = new TitleRecord(); titleRecord.student = stu; Title title = new Title(); title.TitleId = titleid; titleRecord.title = title; int rows = pbll.AddTitlerecord(titleRecord); if (rows > 0) { LogHelper.Info(this.GetType(), stu.StuAccount + " - " + stu.RealName + " - 学生选题 - " + dstitle.TitleId + dstitle.title); Response.Write("选题成功"); Response.End(); } else { Response.Write("选题失败"); Response.End(); } } else { Response.Write("已选题"); Response.End(); } } else { Response.Write("已达上限"); Response.End(); } } else { Response.Write("选题时间已截止"); Response.End(); } } catch (Exception ex) { LogHelper.Error(this.GetType(), ex); } }
/// <summary> /// 获取数据 /// </summary> /// <param name="strWhere">查询条件</param> public void getdata(String strWhere) { string currentPage = Request.QueryString["currentPage"]; if (currentPage == null || currentPage.Length <= 0) { currentPage = "1"; } TitleBll titbll = new TitleBll(); string account = "defenGroupId = " + defenGroupId; string Account = account + " and "; string type = Request.QueryString["type"]; //选择文本 if (type == "textSelect") { strWhere = Search(); } //批次下拉菜单 if (type == "plandrop") { dropstrWhereplan = Context.Request.QueryString["dropstrWhereplan"].ToString(); if (dropstrWhereplan == "0") { strWhere = ""; } strWhere = string.Format(" planId = {0}", dropstrWhereplan); } //专业下拉菜单 if (type == "prodrop") { dropstrWherepro = Request["dropstrWherepro"]; strWhere = string.Format(" proId = {0}", dropstrWherepro); } //学院下拉菜单 if (type == "colldrop") { dropstrWherecoll = Request["dropstrWherecoll"]; strWhere = string.Format(" collegeId = {0}", dropstrWherecoll); //加载超管所选分院的所有专业 TableBuilder tabuilderPro = new TableBuilder(); tabuilderPro.StrTable = "T_Profession"; tabuilderPro.StrWhere = "collegeId = '" + dropstrWherecoll + "'"; tabuilderPro.IntColType = 0; tabuilderPro.IntOrder = 0; tabuilderPro.IntPageNum = 1; tabuilderPro.IntPageSize = 100; tabuilderPro.StrColumn = "proId"; tabuilderPro.StrColumnlist = "*"; prods = probll.SelectBypage(tabuilderPro, out count); //加载超管所选分院的所有批次 TableBuilder tabuilderPlan = new TableBuilder(); tabuilderPlan.StrTable = "T_Plan"; tabuilderPlan.StrWhere = "collegeId = '" + dropstrWherecoll + "'"; tabuilderPlan.IntColType = 0; tabuilderPlan.IntOrder = 0; tabuilderPlan.IntPageNum = 1; tabuilderPlan.IntPageSize = 100; tabuilderPlan.StrColumn = "planId"; tabuilderPlan.StrColumnlist = "*"; plads = plabll.SelectBypage(tabuilderPlan, out count); } //所有下拉菜单 if (type == "alldrop") { dropstrWhereplan = Context.Request.QueryString["dropstrWhereplan"].ToString(); dropstrWherepro = Context.Request.QueryString["dropstrWherepro"].ToString(); strWhere = string.Format(" proId = {0} and planId = {1}", dropstrWherepro, dropstrWhereplan); } TableBuilder tabuilder = new TableBuilder(); tabuilder.StrTable = "V_DefenceRecord"; tabuilder.StrWhere = (strWhere == null || strWhere == "" ? account : Account + strWhere); tabuilder.IntColType = 0; tabuilder.IntOrder = 0; tabuilder.IntPageNum = int.Parse(currentPage); tabuilder.IntPageSize = pagesize; tabuilder.StrColumn = "defenRecordId"; tabuilder.StrColumnlist = "*"; getCurrentPage = int.Parse(currentPage); ds = titbll.SelectBypage(tabuilder, out count); //加载所有分院 if (state == 2 || state == 1) { //加载登录教师所在分院的专业 TableBuilder tabuilderPro = new TableBuilder(); tabuilderPro.StrTable = "T_Profession"; tabuilderPro.StrWhere = "collegeId = '" + tea.college.ColID + "'"; tabuilderPro.IntColType = 0; tabuilderPro.IntOrder = 0; tabuilderPro.IntPageNum = 1; tabuilderPro.IntPageSize = 100; tabuilderPro.StrColumn = "proId"; tabuilderPro.StrColumnlist = "*"; prods = probll.SelectBypage(tabuilderPro, out count); //加载登录教师所在分院的批次 TableBuilder tabuilderPlan = new TableBuilder(); tabuilderPlan.StrTable = "T_Plan"; tabuilderPlan.StrWhere = "collegeId = '" + tea.college.ColID + "'"; tabuilderPlan.IntColType = 0; tabuilderPlan.IntOrder = 0; tabuilderPlan.IntPageNum = 1; tabuilderPlan.IntPageSize = 100; tabuilderPlan.StrColumn = "planId"; tabuilderPlan.StrColumnlist = "*"; plads = plabll.SelectBypage(tabuilderPlan, out count); } else if (state == 0) { dropstrWherecoll = Request["dropstrWherecoll"]; dropstrWherepro = Request["dropstrWherepro"]; dropstrWhereplan = Request["dropstrWhereplan"]; //加载超管所选分院的所有专业 TableBuilder tabuilderPro = new TableBuilder(); tabuilderPro.StrTable = "T_Profession"; tabuilderPro.StrWhere = "collegeId = '" + dropstrWherecoll + "'"; tabuilderPro.IntColType = 0; tabuilderPro.IntOrder = 0; tabuilderPro.IntPageNum = 1; tabuilderPro.IntPageSize = 100; tabuilderPro.StrColumn = "proId"; tabuilderPro.StrColumnlist = "*"; prods = probll.SelectBypage(tabuilderPro, out count); //加载超管所选分院的所有批次 TableBuilder tabuilderPlan = new TableBuilder(); tabuilderPlan.StrTable = "T_Plan"; tabuilderPlan.StrWhere = "collegeId = '" + dropstrWherecoll + "'"; tabuilderPlan.IntColType = 0; tabuilderPlan.IntOrder = 0; tabuilderPlan.IntPageNum = 1; tabuilderPlan.IntPageSize = 100; tabuilderPlan.StrColumn = "planId"; tabuilderPlan.StrColumnlist = "*"; plads = plabll.SelectBypage(tabuilderPlan, out count); } }
/// <summary> /// 批量导入 /// </summary> public void upload() { try { //Teacher user = (Teacher)Session["user"];//取得登录用户用账号作为文件夹名称 HttpFileCollection file = HttpContext.Current.Request.Files;//从HTTP文件流中读取上传文件 if (file.Count > 0) { //文件大小 long size = file[0].ContentLength; //文件类型 string type = file[0].ContentType; //文件名 IE浏览器文件名是绝对路径,服务器文件夹名不支持(\\),其他浏览器为文件名(兼容ie) string filename = ""; filename = file[0].FileName; if (filename.IndexOf("\\") != -1) //判断路径中是否包含\\ { string[] a = filename.Split('\\'); //分割字符串 filename = a[a.Length - 1].ToString(); //取数组最后一位作为文件夹名称 } else { filename = file[0].FileName;//不是ie直接返回文件名称作为文件夹名 } //文件格式 string tp = System.IO.Path.GetExtension(filename); if (tp == ".xls" || tp == ".xlsx") { DirectoryInfo dir; //将文件导入服务器 //string savePath = Server.MapPath("~/upload/题目信息导入Excel文件存储/admin");//指定上传文件在服务器上的保存路径 //dir = new DirectoryInfo(savePath); //dir.Create(); Teacher user = (Teacher)Session["user"];//获取当前用户账号作为文件夹名称 string savePath = Server.MapPath("~/upload/题目信息导入Excel文件存储/" + user.TeaName); dir = new DirectoryInfo(savePath); dir.Create(); DateTime d = DateTime.Now; string datetime = d.ToString("yyyyMMddHHmmss"); string name = datetime + "-" + filename; //将当前时间作为文件名称 savePath = savePath + "\\" + name; //将路径合并 file[0].SaveAs(savePath); //存入服务器 var dt = ExcelHelper.GetDataTable(savePath); //从服务器路径读取数据成DataTable TitleBll bll = new TitleBll(); int row = bll.upload(dt); if (row > 0) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "js", "<script>alert('导入失败');</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(GetType(), "js", "<script>alert('导入成功');</script>"); } } else { Page.ClientScript.RegisterClientScriptBlock(GetType(), "js", "<script>alert('Excel格式不正确');</script>"); } } else { Page.ClientScript.RegisterClientScriptBlock(GetType(), "js", "<script>alert('请选择上传文件');</script>"); } } catch (Exception ex) { LogHelper.Error(this.GetType(), ex); this.Response.Write("<script>alert('" + ex.Message + "');</script>"); } }