protected void getDataSouce() { try { using (var db = new oucITEntities()) { teacherLs = (from teac in db.Teacher join userid in db.User on teac.UserID equals userid.UserID orderby userid.Number select new myData { userId = userid.UserID, name = teac.Name, number = userid.Number }) .ToList(); studentLs = (from stu in db.Student join userid in db.User on stu.UserID equals userid.UserID orderby userid.Number select new myData { userId = userid.UserID, name = stu.Name, number = userid.Number }) .ToList(); } } catch (Exception ex) { Response.Redirect("adminList.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["User"] == null) { Response.Write("<script>alert('账户过期请重新登录!');window.parent.location.href='Login.aspx';</script>"); } //绑定所有组织 try { connID = Convert.ToInt32(Request.QueryString["connID"].ToString()); using (var db = new oucITEntities()) { if (!IsPostBack) { dplGp.DataSource = (from it in db.ITGroup orderby it.groupType select it.GroupName).ToList(); dplGp.DataBind(); } Connection isExist = db.Connection.SingleOrDefault(a => a.ID == connID); if (isExist == null) { Response.Redirect("groupList.aspx"); return; } } } catch { Response.Redirect("groupList.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["User"] == null) { Response.Write("<script>alert('账户过期请重新登录!');window.parent.location.href='Login.aspx';</script>"); } int id = ((User)Session["User"]).UserID; string type = UserHelper.RtnType(id); if (type == "Teacher") { using (var db = new oucITEntities()) { var teacher = (from it in db.Teacher where it.UserID == id select it).FirstOrDefault(); lbWelcome.Text = "Welcome " + teacher.Name; } } else { using (var db = new oucITEntities()) { var student = (from it in db.Student where it.UserID == id select it).FirstOrDefault(); lbWelcome.Text = "Welcome " + student.Name; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["type"] != "学院概况") { Response.Redirect("index.aspx"); } string name = "学院概况:学院介绍"; if (Request.QueryString["item"] != null) { name = "学院概况:" + Request.QueryString["item"]; } if (name != "学院概况:学院介绍" && name != "学院概况:物理系" && name != "学院概况:电子工程系" && name != "学院概况:计算机科学与技术系" && name != "学院概况:海洋技术系" && name != "学院概况:信息工程中心") { Response.Redirect("index.aspx"); } if (name == "学院概况:计算机科学与技术系") { Response.Redirect("http://cs.ouc.edu.cn/"); } else if (name == "学院概况:海洋技术系") { Response.Redirect("http://it.ouc.edu.cn/SeaProject/View/Home.aspx"); } else { int id; try { id = int.Parse(Request.QueryString["id"]); } catch { id = 1; } oucITEntities db = new oucITEntities(); Introduce intr; try { if (name != null) { intr = db.Introduce.First(p => p.name == name); } else { intr = db.Introduce.First(p => p.id == id); } } catch { intr = db.Introduce.First(); }; Label1.Text = intr.name.Substring(5); Label2.Text = ArticleHelper.GetEnglishItems(intr.name); Literal1.Text = intr.text; } } }
protected void Page_Load(object sender, EventArgs e) { string temTitle = "物理系"; if (Request.QueryString["type"] != "本科生教育") { Response.Redirect("index.aspx"); } if (Request.QueryString["item"] != null) { temTitle = Request.QueryString["item"]; } lbdepartment.Text = temTitle.Replace('<', ' ').Replace('>', ' ').Replace('"', ' '); lbenglishDepart.Text = ArticleHelper.GetEnglishItems(temTitle); List <Introduce> ls = new List <Introduce>(); oucITEntities db = new oucITEntities(); ls = db.Introduce.Where(p => p.name.StartsWith("合作办学")).ToList(); switch (temTitle) { case "物理系": Panel1.Visible = true; Literal1.Text = db.Introduce.Where(p => p.name == "专业介绍:物理学").SingleOrDefault().text == null ? "" : db.Introduce.Where(p => p.name == "专业介绍:物理学").SingleOrDefault().text; Literal2.Text = db.Introduce.Where(p => p.name == "专业介绍:光电信息科学与技术").SingleOrDefault().text == null ? "" : db.Introduce.Where(p => p.name == "专业介绍:光电信息科学与技术").SingleOrDefault().text; break; case "电子工程系": Panel2.Visible = true; Literal3.Text = db.Introduce.Where(p => p.name == "专业介绍:电子信息科学与技术").SingleOrDefault().text == null ? "" : db.Introduce.Where(p => p.name == "专业介绍:电子信息科学与技术").SingleOrDefault().text; Literal4.Text = db.Introduce.Where(p => p.name == "专业介绍:通信工程").SingleOrDefault().text == null ? "" : db.Introduce.Where(p => p.name == "专业介绍:通信工程").SingleOrDefault().text; Literal5.Text = db.Introduce.Where(p => p.name == "专业介绍:电子信息工程").SingleOrDefault().text == null ? "" : db.Introduce.Where(p => p.name == "专业介绍:电子信息工程").SingleOrDefault().text; break; case "计算机科学与技术系": Panel3.Visible = true; Literal6.Text = db.Introduce.Where(p => p.name == "专业介绍:计算机科学与技术").SingleOrDefault().text == null ? "" : db.Introduce.Where(p => p.name == "专业介绍:计算机科学与技术").SingleOrDefault().text; break; case "海洋技术系": Panel4.Visible = true; Literal7.Text = db.Introduce.Where(p => p.name == "专业介绍:海洋技术").SingleOrDefault().text == null ? "" : db.Introduce.Where(p => p.name == "专业介绍:海洋技术").SingleOrDefault().text; break; default: Response.Redirect("index.aspx"); break; } }
protected void btnAdd_Click(object sender, EventArgs e) { if (txtNum.Text.Length == 0) { Response.Write(JSHelper.ShowAlert("输入不能为空!")); } else { var user = UserHelper.Select(txtNum.Text); if (user != null) { var teac = TeacherHelper.Select(user.UserID); var stu = StudentHelper.Select(user.UserID); if (teac != null || stu != null) { var db = new oucITEntities(); var itgroup = (from a in db.ITGroup where a.GroupName == ddlGroup.Text select a).SingleOrDefault(); var conn = (from a in db.Connection where a.UserID == user.UserID && a.GroupID == itgroup.GroupID select a).FirstOrDefault(); if (conn == null) { int class1 = ddlClass.Text == "管理员" ? 2 : 1; if (ConnHelp.Add(itgroup.GroupID, user.UserID, ddlClass.Text, class1, txtJob.Text, txtDuty.Text, txtPhone.Text, txtEmail.Text) == true) { Response.Write("<script>alert('添加成功!');window.location.href ='Index.aspx'</script>"); } else { Response.Write(JSHelper.ShowAlert("添加失败")); } } else { Response.Write(JSHelper.ShowAlert("该老师或学生已存在于该组")); } } else { Response.Write(JSHelper.ShowAlert("该老师或学生不存在")); } } else { Response.Write(JSHelper.ShowAlert("该老师或学生不存在")); } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["User"] == null) { Response.Write("<script>alert('账户过期请重新登录!');window.parent.location.href='Login.aspx';</script>"); } else if (!IsPostBack) { User u = (User)Session["User"]; if (u != null) { var db = new oucITEntities(); var teac = (from a in db.Teacher where a.UserID == u.UserID select a).FirstOrDefault(); if (teac != null) { lblName.Text = teac.Name; var query = (from a in db.Connection where a.UserID == u.UserID select a.ITGroup.GroupName).ToList(); if (query.Count != 0) { ddlGroup.DataSource = query; ddlGroup.DataBind(); ITGroup itgroup = GroupHelper.Select(ddlGroup.Text); var conn = (from a in db.Connection where a.UserID == u.UserID && a.GroupID == itgroup.GroupID select a).FirstOrDefault(); if (conn != null) { txtDuty.Text = conn.Duty; txtJob.Text = conn.Job; txtEmail.Text = conn.Email; txtPhone.Text = conn.Phone; } } else { Response.Redirect("Index.aspx"); } } else { Response.Redirect("Index.aspx"); } } } }
/*static DataTable dtSelect = new DataTable(); * protected void Page() * { * DataSourceSelectArguments arg = new DataSourceSelectArguments(); * DataView d = (DataView)SqlDataSource1.Select(arg); * dtSelect = d.Table; * GridView1.DataSourceID = string.Empty; * GridView1.DataSource = dtSelect; * }*/ protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { using (var db = new oucITEntities()) { int userID = ((User)Session["User"]).UserID; try { var ar = from it in db.Article where it.Deleted == true && it.AuthorID == userID orderby it.UpdateTime descending select it; GridView1.PageIndex = e.NewPageIndex; GridView1.DataSource = ar.ToList(); GridView1.DataBind(); } catch { } } }
protected void ddlGroup_SelectedIndexChanged(object sender, EventArgs e) { User u = (User)Session["User"]; var db = new oucITEntities(); ITGroup itgroup = GroupHelper.Select(ddlGroup.Text); var conn = (from a in db.Connection where a.UserID == u.UserID && a.GroupID == itgroup.GroupID select a).FirstOrDefault(); if (conn != null) { txtDuty.Text = conn.Duty; txtJob.Text = conn.Job; txtEmail.Text = conn.Email; txtPhone.Text = conn.Phone; } }
protected void btnEdit_Click(object sender, EventArgs e) { User u = (User)Session["User"]; var db = new oucITEntities(); ITGroup itgroup = GroupHelper.Select(ddlGroup.Text); var conn = (from a in db.Connection where a.UserID == u.UserID && a.GroupID == itgroup.GroupID select a).FirstOrDefault(); if (ConnHelp.MessUpdate(conn.GroupID, u.UserID, txtJob.Text, txtDuty.Text, txtPhone.Text, txtEmail.Text)) { Response.Write("<script>alert('修改成功!');window.location.href ='Index.aspx'</script>"); } else { Response.Write(JSHelper.ShowAlert("修改失败")); } }
protected void getDataSouce(int groupTyped) { try { using (var db = new oucITEntities()) { bindData = (from gp in db.ITGroup where gp.groupType == groupTyped orderby gp.GroupID select gp) .ToList(); } } catch (Exception ex) { Response.Redirect("groupList.aspx"); } }
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.Item.ItemType == ListItemType.Item) { if (e.CommandName == "delete") { oucITEntities db = new oucITEntities(); if (CourseHelper.Delete(Convert.ToInt32(e.CommandArgument), db)) { JSHelper.Redirect("CourseList.aspx", true);//window.location.href='NewsList.aspx' } else { Response.Write("<script>alert('删除失败!');</script>"); } } } }
protected void btnDelCheck_Click(object sender, EventArgs e) { if (txtDelete.Text.Length == 0) { Response.Write(JSHelper.ShowAlert("输入不能为空!")); } else { var user = UserHelper.Select(txtDelete.Text); if (user == null) { lblDelete.Text = "该组不存在该老师或学生<br/>"; } else { var teac = TeacherHelper.Select(user.UserID); var stu = StudentHelper.Select(user.UserID); if (teac != null || stu != null) { var itgroup = GroupHelper.Select(ddlDelete.Text); var db = new oucITEntities(); var conn = (from a in db.Connection where a.UserID == user.UserID && a.GroupID == itgroup.GroupID select a).SingleOrDefault(); if (conn != null && teac != null) { lblDelete.Text = teac.Name; } else if (conn != null && stu != null) { lblDelete.Text = stu.Name; } else { lblDelete.Text = "该组不存在该老师或学生<br/>"; } } else { lblDelete.Text = "该组不存在该老师<br/>"; } } } }
public void BindGrid() { int page = 0; if (Request.QueryString["page"] != null) { try { page = int.Parse(Request.QueryString["page"]); } catch { page = 0; } } oucITEntities db = new oucITEntities(); // Repeater1.DataSource = db.Course.OrderBy(p => p.CourseID).Skip(pageIndex * pageSize).Take(pageSize).ToList(); List <Course> ls = db.Course.OrderBy(p => p.CourseID).ToList(); Repeater1.DataSource = ls.Skip(20 * page).Take(20); //Repeater1.DataSource = ArticleHelper.GetMyArticles(((User)Session["User"]).UserID); Repeater1.DataBind(); TotalPage.Text = Math.Ceiling(ls.Count / 20.0).ToString(); currentPage.Text = (page + 1).ToString(); Prev.NavigateUrl = "CourseList.aspx?page=" + (page - 1).ToString(); Next.NavigateUrl = "CourseList.aspx?page=" + (page + 1).ToString(); Last.NavigateUrl = "CourseList.aspx?page=" + ls.Count / 20; if (page == 0) { First.Enabled = false; Prev.Enabled = false; } if (page == (int)Math.Ceiling(ls.Count / 20.0) - 1) { Next.Enabled = false; Last.Enabled = false; } /* * oucITEntities db = new oucITEntities(); * * Repeater1.DataSource = db.Course.OrderBy(p => p.CourseID).Skip(pageIndex * pageSize).Take(pageSize).ToList();//db.GetCurrentPage(pageIndex, pageSize); * Repeater1.DataBind();*/ }
protected void btnDelete_Click(object sender, EventArgs e) { if (txtDelete.Text.Length == 0) { Response.Write(JSHelper.ShowAlert("输入不能为空!")); } else { var user = UserHelper.Select(txtDelete.Text); if (user == null) { Response.Write(JSHelper.ShowAlert("该组不存在该老师")); } else { var teac = TeacherHelper.Select(user.UserID); var stu = StudentHelper.Select(user.UserID); if (teac != null || stu != null) { var itgroup = GroupHelper.Select(ddlDelete.Text); var db = new oucITEntities(); var conn = (from a in db.Connection where a.UserID == user.UserID && a.GroupID == itgroup.GroupID select a).SingleOrDefault(); if (conn != null) { db.Connection.Remove(conn); db.SaveChanges(); Response.Write("<script>alert('删除成功!');window.location.href ='Index.aspx'</script>"); } else { Response.Write(JSHelper.ShowAlert("该组不存在该老师或学生")); } } else { Response.Write(JSHelper.ShowAlert("该组不存在该老师或学生")); } } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["User"] == null) { Response.Write("<script>alert('账户过期请重新登录!');window.parent.location.href='Login.aspx';</script>"); } #region 分发当前页面属于哪个模块 string type = Request.QueryString["type"].ToString(); switch (type) { //默认添加管理员 default: addAdmin.Visible = true; addOrg.Visible = false; addOrgNumber.Visible = false; break; case "org": addAdmin.Visible = false; addOrg.Visible = true; addOrgNumber.Visible = false; break; case "orgNumber": if (!IsPostBack) { //添加所有组别到组别下拉框 using (var db = new oucITEntities()) { ddlGroup.DataSource = (from it in db.ITGroup orderby it.groupType select it.GroupName).ToList(); ddlGroup.DataBind(); } } addAdmin.Visible = false; addOrg.Visible = false; addOrgNumber.Visible = true; break; } #endregion }
protected void Page_Load(object sender, EventArgs e) { int id = 1; try { id = Convert.ToInt32(Request.QueryString["id"].ToString()); } catch { } using (var db = new oucITEntities()) { Introduce ar = db.Introduce.SingleOrDefault(a => a.id.Equals(id)); if (ar.name != "合作办学") { id = 11; } ar = db.Introduce.SingleOrDefault(a => a.id.Equals(id)); ltTitle.Text = ar.name.Substring(ar.name.IndexOf(':') + 1); ltContent.Text = ar.text; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { User user = (User)Session["User"]; List <string> ls = ArticleHelper.CheckRight(((User)Session["User"]).UserID); Repeater1.DataSource = ls; Repeater1.DataBind(); if (ls.Count == 0) { Article.Visible = false; MyArticles.Visible = false; } var teac = TeacherHelper.Select(user.UserID); if (teac == null) { PanelMessEdit.Visible = false; Course.Visible = false; relationCourse.Visible = false; } var db = new oucITEntities(); var conn = (from a in db.Connection where a.UserID == user.UserID select a).ToList(); if (conn.Count == 0 || teac == null) { PanelOrgEdit.Visible = false; } var conn2 = (from a in db.Connection where a.UserID == user.UserID && a.Right == 2 select a).ToList(); if (conn2.Count == 0) { PanelOrg.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { oucITEntities db = new oucITEntities(); string temTitle = "物理系"; if (Request.QueryString["type"] != "本科生教育") { Response.Redirect("index.aspx"); } if (Request.QueryString["item"] != null) { temTitle = Request.QueryString["item"]; } // 绑定院系名称 lbdepartment.Text = temTitle.Replace('<', ' ').Replace('>', ' ').Replace('"', ' '); lbenglishDepart.Text = ArticleHelper.GetEnglishItems(temTitle); // 绑定课程repeater switch (temTitle) { case "电子工程系": lbtnMajor1.Text = "电子信息科学与技术"; lbtnMajor1.Visible = true; lbtnMajor2.Text = "电子信息工程"; lbtnMajor2.Visible = true; lbtnMajor3.Text = "通信工程"; lbtnMajor3.Visible = true; Repeater1.DataSource = CourseHelper.GetCoursesOfTheMajor("电子信息科学与技术", db); Repeater1.DataBind(); Repeater2.DataSource = CourseHelper.GetCoursesOfTheMajor("电子信息工程", db); Repeater2.DataBind(); Repeater3.DataSource = CourseHelper.GetCoursesOfTheMajor("通信工程", db); Repeater3.DataBind(); break; case "物理系": lbtnMajor1.Text = "物理学"; lbtnMajor1.Visible = true; lbtnMajor2.Text = "光信息科学与技术"; lbtnMajor2.Visible = true; Repeater1.DataSource = CourseHelper.GetCoursesOfTheMajor("物理学", db); Repeater1.DataBind(); Repeater2.DataSource = CourseHelper.GetCoursesOfTheMajor("光信息科学与技术", db); Repeater2.DataBind(); break; case "计算机科学与技术系": lbtnMajor1.Text = "计算机科学与技术"; lbtnMajor1.Visible = true; Repeater1.DataSource = CourseHelper.GetCoursesOfTheMajor("计算机科学与技术", db); Repeater1.DataBind(); break; case "海洋技术系": lbtnMajor1.Text = "海洋技术"; lbtnMajor1.Visible = true; Repeater1.DataSource = CourseHelper.GetCoursesOfTheMajor("海洋技术", db); Repeater1.DataBind(); break; default: Response.Redirect("index.aspx"); break; } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["User"] == null) { Response.Write("<script>alert('账户过期请重新登录!');window.parent.location.href='Login.aspx';</script>"); } else if (!IsPostBack) { string type = Request.QueryString["type"]; if (type == "delete") { Panel1.Visible = false; Panel2.Visible = true; User u = (User)Session["User"]; if (u != null) { var db = new oucITEntities(); var teac = (from a in db.Teacher where a.UserID == u.UserID select a).FirstOrDefault(); var query = (from a in db.Connection where a.UserID == u.UserID && a.Right == 2 select a.ITGroup.GroupName).ToList(); if (query.Count == 0) { Response.Redirect("Index.aspx"); } else { ddlDelete.DataSource = query; ddlDelete.DataBind(); } } } else { Panel1.Visible = true; Panel2.Visible = false; User u = (User)Session["User"]; if (u != null) { var db = new oucITEntities(); var teac = (from a in db.Teacher where a.UserID == u.UserID select a).FirstOrDefault(); var query = (from a in db.Connection where a.UserID == u.UserID && a.Right == 2 select a.ITGroup.GroupName).ToList(); if (query.Count == 0) { Response.Redirect("Index.aspx"); } else { ddlGroup.DataSource = query; ddlGroup.DataBind(); } } lblName.Text = ""; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var db = new oucITEntities(); if (Request.QueryString["type"] != "组织机构") { Response.Redirect("index.aspx"); } string item = "党委团委"; if (Request.QueryString["item"] != null) { item = Request.QueryString["item"]; } // 绑定组织结构列表 if (item == "党委团委") { // 显示党委团委对应Panel,下同 Panel1.Visible = true; Panel2.Visible = false; Panel3.Visible = false; // 绑定右侧列表,下同 var ITgroup = GroupHelper.Select("学院党委"); if (ITgroup != null) { var xydwlist = from a in db.Connection where a.GroupID == ITgroup.GroupID orderby a.Class select a; Repeater1.DataSource = xydwlist.ToList(); Repeater1.DataBind(); } ITgroup = GroupHelper.Select("学院团委"); if (ITgroup != null) { var xytwlist = from a in db.Connection where a.GroupID == ITgroup.GroupID orderby a.Class select a; Repeater2.DataSource = xytwlist.ToList(); Repeater2.DataBind(); } ITgroup = GroupHelper.Select("教工党支部"); if (ITgroup != null) { var jgdzblist = from a in db.Connection where a.GroupID == ITgroup.GroupID orderby a.Class, a.Job select a; Repeater3.DataSource = jgdzblist.ToList(); Repeater3.DataBind(); } ITgroup = GroupHelper.Select("学生党支部"); if (ITgroup != null) { var xsdzblist = from a in db.Connection where a.GroupID == ITgroup.GroupID select new { Job = a.Job }; Repeater4.DataSource = xsdzblist.ToList(); Repeater4.DataBind(); } } else if (item == "院行政") { Panel1.Visible = false; Panel2.Visible = true; Panel3.Visible = false; var ITgroup = GroupHelper.Select("院行政"); if (ITgroup != null) { var xydwlist = from a in db.Connection where a.GroupID == ITgroup.GroupID orderby a.Class select a; Repeater5.DataSource = xydwlist.ToList(); Repeater5.DataBind(); } ITgroup = GroupHelper.Select("院办公室"); if (ITgroup != null) { var xydwlist = from a in db.Connection where a.GroupID == ITgroup.GroupID orderby a.Class select a; Repeater6.DataSource = xydwlist.ToList(); Repeater6.DataBind(); } ITgroup = GroupHelper.Select("物理系"); if (ITgroup != null) { var xydwlist = from a in db.Connection where a.GroupID == ITgroup.GroupID orderby a.Class select a; Repeater7.DataSource = xydwlist.ToList(); Repeater7.DataBind(); } ITgroup = GroupHelper.Select("电子工程系"); if (ITgroup != null) { var xydwlist = from a in db.Connection where a.GroupID == ITgroup.GroupID orderby a.Class select a; Repeater8.DataSource = xydwlist.ToList(); Repeater8.DataBind(); } ITgroup = GroupHelper.Select("计算机科学与技术系"); if (ITgroup != null) { var xydwlist = from a in db.Connection where a.GroupID == ITgroup.GroupID orderby a.Class select a; Repeater9.DataSource = xydwlist.ToList(); Repeater9.DataBind(); } ITgroup = GroupHelper.Select("海洋技术系"); if (ITgroup != null) { var xydwlist = from a in db.Connection where a.GroupID == ITgroup.GroupID orderby a.Class select a; Repeater10.DataSource = xydwlist.ToList(); Repeater10.DataBind(); } ITgroup = GroupHelper.Select("信息工程中心"); if (ITgroup != null) { var xydwlist = from a in db.Connection where a.GroupID == ITgroup.GroupID orderby a.Class select a; Repeater11.DataSource = xydwlist.ToList(); Repeater11.DataBind(); } } else if (item == "院工会妇委会") { Panel1.Visible = false; Panel2.Visible = false; Panel3.Visible = true; var ITgroup = GroupHelper.Select("院工会"); if (ITgroup != null) { var xydwlist = from a in db.Connection where a.GroupID == ITgroup.GroupID orderby a.Class select a; Repeater12.DataSource = xydwlist.ToList(); Repeater12.DataBind(); } ITgroup = GroupHelper.Select("院妇女委员会"); if (ITgroup != null) { var xydwlist = from a in db.Connection where a.GroupID == ITgroup.GroupID orderby a.Class select a; Repeater13.DataSource = xydwlist.ToList(); Repeater13.DataBind(); } } else { Response.Redirect("index.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { int page = 0; if (Request.QueryString["type"] != "合作办学") { Response.Redirect("index.aspx"); } First.Enabled = true; Prev.Enabled = true; Next.Enabled = true; Last.Enabled = true; lbType.Text = "合作办学"; lbEnglishType.Text = ArticleHelper.GetEnglishItems(lbType.Text); List <Introduce> ls = new List <Introduce>(); oucITEntities db = new oucITEntities(); ls = db.Introduce.Where(p => p.name.StartsWith("合作办学")).ToList(); if (!IsPostBack) { int i = 0; if (Request.QueryString["page"] != null) { page = int.TryParse(Request.QueryString["page"], out i) ? Convert.ToInt32(Request.QueryString["page"]) : 0; } } // 如为页面刷新则获取跳页输入框的值 else { if (turnTopage.Text.Length != 0) { page = Convert.ToInt32(turnTopage.Text) - 1; } } if (page > Math.Ceiling(ls.Count / 10.0) - 1 || page < 0) { page = 0; } rptList.DataSource = ls.Skip(10 * page).Take(10); rptList.DataBind(); TotalPage.Text = Math.Ceiling(ls.Count / 10.0).ToString(); currentPage.Text = (page + 1).ToString(); turnTopage.Text = (page + 1).ToString(); First.NavigateUrl = "cooperateLearning.aspx?type=合作办学" + "&page=0"; Prev.NavigateUrl = "cooperateLearning.aspx?type=合作办学" + "&page=" + (page - 1).ToString(); Next.NavigateUrl = "cooperateLearning.aspx?type=合作办学" + "&page=" + (page + 1).ToString(); Last.NavigateUrl = "cooperateLearning.aspx?type=合作办学" + "&page=" + ls.Count / 10; if (page == 0) { First.Enabled = false; Prev.Enabled = false; } if (page == (int)Math.Ceiling(ls.Count / 10.0) - 1 || (page == 0 && Math.Ceiling(ls.Count / 10.0) == 0)) { Next.Enabled = false; Last.Enabled = false; } }
private int courseID = 0;//修改模式下记录该课程的id protected void Page_Load(object sender, EventArgs e) { if (Session["User"] == null) { Response.Write("<script>alert('账户过期请重新登录!');window.parent.location.href='Login.aspx';</script>"); } #region //添加jQuery脚本 ScriptResourceDefinition myScriptResDef = new ScriptResourceDefinition(); myScriptResDef.Path = "~/Scripts/jquery-1.4.2.min.js"; myScriptResDef.DebugPath = "~/Scripts/jquery-1.4.2.js"; myScriptResDef.CdnPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js"; myScriptResDef.CdnDebugPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.js"; ScriptManager.ScriptResourceMapping.AddDefinition("jquery", null, myScriptResDef); #endregion try { courseID = int.Parse(Request.QueryString["id"]); } catch { courseID = 0; }; if (!IsPostBack) { User u = (User)Session["User"]; if (TeacherHelper.Select(u.UserID) == null) { Response.Redirect("Index.aspx"); } if (Request.QueryString["id"] != null)//如果是修改模式 { Button3.Visible = true; Button2.Text = "替换上传"; #region //为控件赋值 oucITEntities db = new oucITEntities(); Course co = CourseHelper.GetCourseById(courseID, db); courseName.Text = co.CourseName; department.SelectedValue = co.Department; major.SelectedValue = co.Major; courseType.SelectedValue = co.Type.ToString();//TODO: CoNumber.Text = co.Number; EnglishName.Text = co.EnglishName; TotalHours.Text = co.CourseHours.ToString(); TotalMark.Text = co.CourseMark.ToString(); Textbook.Text = co.Textbook; TextbookAuthor.Text = co.TextbookAuthor; TextbookPublisher.Text = co.TextbookPublisher; TextbookVersion.Text = co.TextbookVersion; CourseObject.Text = co.CourseObject; ExamType.Text = co.ExamType; reference.Text = co.Reference; HiddenField1.Value = co.ContentAndTimeArrange; if (co.Type == 3) { WeekHours.Text = co.WeekHours.ToString(); TermArrange.Text = co.TermArrange; ExperimentPlace.Text = co.ExperimentPlace; ExperimentObject.Text = co.ExperimentObject; } else if (co.Type == 2) { ExperimentMark.Text = co.ExperimentMark.ToString(); ExperimentHours.Text = co.ExperimentHours.ToString(); ExperimentPlace.Text = co.ExperimentPlace; ExperimentPartObject.Text = co.ExperimentPartObject; } #endregion } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string major = "physics"; if (Request.QueryString["type"] != "师资队伍") { Response.Redirect("index.aspx"); } if (Request.QueryString["item"] != null) { major = Request.QueryString["item"]; } panel1.Visible = true; panel2.Visible = false; panel3.Visible = false; panel4.Visible = false; //panel5.Visible = false; if (major == "physics") { lblMajor.Text = "物理系"; lblEnglishMajor.Text = "physics"; var db = new oucITEntities(); // 绑定教授 var list = (from a in db.Teacher where a.Department == "物理系" && a.JobTitle == 1 orderby a.Birthday select a).ToList(); Repeater1.DataSource = list; Repeater1.DataBind(); if (list.Count == 0) { Panel6.Visible = false; } // 绑定博士生导师 var list2 = (from a in db.Teacher where a.Department == "物理系" && a.Tutor == 1 orderby a.Job, a.Birthday select a).ToList(); Repeater3.DataSource = list2; Repeater3.DataBind(); if (list2.Count == 0) { Panel7.Visible = false; } // 绑定硕士生导师 var list3 = (from a in db.Teacher where a.Department == "物理系" && (a.Tutor == 1 || a.Tutor == 2) orderby a.Job, a.Tutor, a.Birthday select a).ToList(); Repeater4.DataSource = list3; Repeater4.DataBind(); // 绑定信息工程中心 var list4 = (from a in db.Teacher where a.Department == "物理系" && a.JobTitle == 2 orderby a.Birthday select a).ToList(); Repeater2.DataSource = list4; Repeater2.DataBind(); // 绑定高级工程师 var list5 = (from a in db.Teacher where a.Department == "物理系" && a.JobTitle == 3 orderby a.Birthday select a).ToList(); Repeater5.DataSource = list5; Repeater5.DataBind(); if (list5.Count == 0) { Panel5.Visible = false; } // 绑定高级实验师 var list6 = (from a in db.Teacher where a.Department == "物理系" && a.JobTitle == 4 orderby a.Birthday select a).ToList(); Repeater6.DataSource = list6; Repeater6.DataBind(); if (list6.Count == 0) { Panel8.Visible = false; } // 绑定讲师 var list7 = (from a in db.Teacher where a.Department == "物理系" && a.JobTitle == 5 orderby a.Birthday select a).ToList(); Repeater7.DataSource = list7; Repeater7.DataBind(); if (list7.Count == 0) { Panel9.Visible = false; } // 绑定助理工程师 var list8 = (from a in db.Teacher where a.Department == "物理系" && a.JobTitle == 6 orderby a.Birthday select a).ToList(); Repeater8.DataSource = list8; Repeater8.DataBind(); if (list8.Count == 0) { Panel10.Visible = false; } // 绑定助理实验师 var list9 = (from a in db.Teacher where a.Department == "物理系" && a.JobTitle == 7 orderby a.Birthday select a).ToList(); Repeater9.DataSource = list9; Repeater9.DataBind(); if (list9.Count == 0) { Panel11.Visible = false; } } else if (major == "electron") { panel1.Visible = true; panel4.Visible = false; lblMajor.Text = "电子工程系"; lblEnglishMajor.Text = "electronic engineering"; var db = new oucITEntities(); var list = (from a in db.Teacher where a.Department == "电子工程系" && a.JobTitle == 1 orderby a.Birthday select a).ToList(); Repeater1.DataSource = list; Repeater1.DataBind(); if (list.Count == 0) { Panel6.Visible = false; } var list2 = (from a in db.Teacher where a.Department == "电子工程系" && a.Tutor == 1 orderby a.Job, a.Birthday select a).ToList(); Repeater3.DataSource = list2; Repeater3.DataBind(); if (list2.Count == 0) { Panel7.Visible = false; } var list3 = (from a in db.Teacher where a.Department == "电子工程系" && (a.Tutor == 1 || a.Tutor == 2) orderby a.Job, a.Tutor, a.Birthday select a).ToList(); Repeater4.DataSource = list3; Repeater4.DataBind(); var list4 = (from a in db.Teacher where a.Department == "电子工程系" && a.JobTitle == 2 orderby a.UserID select a).ToList(); Repeater2.DataSource = list4; Repeater2.DataBind(); var list5 = (from a in db.Teacher where a.Department == "电子工程系" && a.JobTitle == 3 orderby a.Birthday select a).ToList(); Repeater5.DataSource = list5; Repeater5.DataBind(); if (list5.Count == 0) { Panel5.Visible = false; } var list6 = (from a in db.Teacher where a.Department == "电子工程系" && a.JobTitle == 4 orderby a.Birthday select a).ToList(); Repeater6.DataSource = list6; Repeater6.DataBind(); if (list6.Count == 0) { Panel8.Visible = false; } var list7 = (from a in db.Teacher where a.Department == "电子工程系" && a.JobTitle == 5 orderby a.Birthday select a).ToList(); Repeater7.DataSource = list7; Repeater7.DataBind(); if (list7.Count == 0) { Panel9.Visible = false; } var list8 = (from a in db.Teacher where a.Department == "电子工程系" && a.JobTitle == 6 orderby a.Birthday select a).ToList(); Repeater8.DataSource = list8; Repeater8.DataBind(); if (list8.Count == 0) { Panel10.Visible = false; } var list9 = (from a in db.Teacher where a.Department == "电子工程系" && a.JobTitle == 7 orderby a.Birthday select a).ToList(); Repeater9.DataSource = list9; Repeater9.DataBind(); if (list9.Count == 0) { Panel11.Visible = false; } } else if (major == "computer") { lblMajor.Text = "计算机科学与技术系"; lblEnglishMajor.Text = "computer science and technology"; var db = new oucITEntities(); var list = (from a in db.Teacher where a.Department == "计算机科学与技术系" && a.JobTitle == 1 orderby a.Birthday select a).ToList(); Repeater1.DataSource = list; Repeater1.DataBind(); if (list.Count == 0) { Panel6.Visible = false; } var list2 = (from a in db.Teacher where a.Department == "计算机科学与技术系" && a.Tutor == 1 orderby a.Job, a.Birthday select a).ToList(); Repeater3.DataSource = list2; Repeater3.DataBind(); if (list2.Count == 0) { Panel7.Visible = false; } var list3 = (from a in db.Teacher where a.Department == "计算机科学与技术系" && (a.Tutor == 1 || a.Tutor == 2) orderby a.Job, a.Tutor, a.Birthday select a).ToList(); Repeater4.DataSource = list3; Repeater4.DataBind(); var list4 = (from a in db.Teacher where a.Department == "计算机科学与技术系" && a.JobTitle == 2 orderby a.UserID select a).ToList(); Repeater2.DataSource = list4; Repeater2.DataBind(); var list5 = (from a in db.Teacher where a.Department == "计算机科学与技术系" && a.JobTitle == 3 orderby a.Birthday select a).ToList(); Repeater5.DataSource = list5; Repeater5.DataBind(); if (list5.Count == 0) { Panel5.Visible = false; } var list6 = (from a in db.Teacher where a.Department == "计算机科学与技术系" && a.JobTitle == 4 orderby a.Birthday select a).ToList(); Repeater6.DataSource = list6; Repeater6.DataBind(); if (list6.Count == 0) { Panel8.Visible = false; } var list7 = (from a in db.Teacher where a.Department == "计算机科学与技术系" && a.JobTitle == 5 orderby a.Birthday select a).ToList(); Repeater7.DataSource = list7; Repeater7.DataBind(); if (list7.Count == 0) { Panel9.Visible = false; } var list8 = (from a in db.Teacher where a.Department == "计算机科学与技术系" && a.JobTitle == 6 orderby a.Birthday select a).ToList(); Repeater8.DataSource = list8; Repeater8.DataBind(); if (list8.Count == 0) { Panel10.Visible = false; } var list9 = (from a in db.Teacher where a.Department == "计算机科学与技术系" && a.JobTitle == 7 orderby a.Birthday select a).ToList(); Repeater9.DataSource = list9; Repeater9.DataBind(); if (list9.Count == 0) { Panel11.Visible = false; } } else if (major == "ocean") { lblMajor.Text = "海洋技术系"; lblEnglishMajor.Text = "marine technology"; var db = new oucITEntities(); var list = (from a in db.Teacher where a.Department == "海洋技术系" && a.JobTitle == 1 orderby a.Birthday select a).ToList(); Repeater1.DataSource = list; Repeater1.DataBind(); if (list.Count == 0) { Panel6.Visible = false; } var list2 = (from a in db.Teacher where a.Department == "海洋技术系" && a.Tutor == 1 orderby a.Job, a.Birthday select a).ToList(); Repeater3.DataSource = list2; Repeater3.DataBind(); if (list2.Count == 0) { Panel7.Visible = false; } var list3 = (from a in db.Teacher where a.Department == "海洋技术系" && (a.Tutor == 1 || a.Tutor == 2) orderby a.Job, a.Tutor, a.Birthday select a).ToList(); Repeater4.DataSource = list3; Repeater4.DataBind(); var list4 = (from a in db.Teacher where a.Department == "海洋技术系" && a.JobTitle == 2 orderby a.UserID select a).ToList(); Repeater2.DataSource = list4; Repeater2.DataBind(); var list5 = (from a in db.Teacher where a.Department == "海洋技术系" && a.JobTitle == 3 orderby a.Birthday select a).ToList(); Repeater5.DataSource = list5; Repeater5.DataBind(); if (list5.Count == 0) { Panel5.Visible = false; } var list6 = (from a in db.Teacher where a.Department == "海洋技术系" && a.JobTitle == 4 orderby a.Birthday select a).ToList(); Repeater6.DataSource = list6; Repeater6.DataBind(); if (list6.Count == 0) { Panel8.Visible = false; } var list7 = (from a in db.Teacher where a.Department == "海洋技术系" && a.JobTitle == 5 orderby a.Birthday select a).ToList(); Repeater7.DataSource = list7; Repeater7.DataBind(); if (list7.Count == 0) { Panel9.Visible = false; } var list8 = (from a in db.Teacher where a.Department == "海洋技术系" && a.JobTitle == 6 orderby a.Birthday select a).ToList(); Repeater8.DataSource = list8; Repeater8.DataBind(); if (list8.Count == 0) { Panel10.Visible = false; } var list9 = (from a in db.Teacher where a.Department == "海洋技术系" && a.JobTitle == 7 orderby a.Birthday select a).ToList(); Repeater9.DataSource = list9; Repeater9.DataBind(); if (list9.Count == 0) { Panel11.Visible = false; } } //else if (major == "it") //{ // lblMajor.Text = "行政人员"; // lblEnglishMajor.Text = "administrative staff"; // var db = new oucITEntities(); // var list10 = (from a in db.Teacher // where a.Department == "行政人员" // orderby a.JobTitle, a.UserID // select a).ToList(); // Repeater10.DataSource = list10; // Repeater10.DataBind(); // panel1.Visible = false; // panel4.Visible = true; // panelChoose.Visible = false; //} else if (major == "it") { lblMajor.Text = "信息工程中心"; lblEnglishMajor.Text = "information engineering center"; var db = new oucITEntities(); var list10 = (from a in db.Teacher where a.Department == "信息工程中心" orderby a.JobTitle, a.UserID select a).ToList(); Repeater10.DataSource = list10; Repeater10.DataBind(); panel1.Visible = false; panel4.Visible = true; panelChoose.Visible = false; } else { Response.Redirect("Index.aspx"); } } }
protected void Button1_Click(object sender, EventArgs e) { // string filename= UploadHelper.uploadText(FileUpload1); User u = (User)Session["User"]; if (TeacherHelper.Select(u.UserID).Department != department.SelectedValue) { Response.Write(JSHelper.ShowAlert("您没有权限添加该系的课程介绍!")); return; } if (HiddenField1.Value != "") { #region //以用户输入构建Course对象 Course co = new Course { CourseName = courseName.Text, Department = department.SelectedValue, Major = major.SelectedValue, Type = int.Parse(courseType.SelectedValue), Number = CoNumber.Text, EnglishName = EnglishName.Text, CourseHours = int.Parse(TotalHours.Text), CourseMark = float.Parse(TotalMark.Text), Textbook = Textbook.Text, TextbookAuthor = TextbookAuthor.Text, TextbookPublisher = TextbookPublisher.Text, TextbookVersion = TextbookVersion.Text, CourseObject = CourseObject.Text, ExamType = ExamType.Text.Length > 24 ? ExamType.Text.Substring(0, 23) : ExamType.Text, ContentAndTimeArrange = HiddenField1.Value, Reference = reference.Text }; if (co.Type == 3) { co.WeekHours = int.Parse(WeekHours.Text); co.TermArrange = TermArrange.Text; co.ExperimentPlace = ExperimentPlace.Text; co.ExperimentObject = ExperimentObject.Text; } else if (co.Type == 2) { co.ExperimentHours = int.Parse(ExperimentHours.Text); co.ExperimentMark = float.Parse(ExperimentMark.Text); co.ExperimentPlace = ExperimentPlace.Text; co.ExperimentPartObject = ExperimentPartObject.Text; } #endregion // 判断是添加还是修改,修改数据库 if (courseID == 0) { oucITEntities db = new oucITEntities(); if (CourseHelper.AddCourse(co, db)) { Response.Write("<script>alert('添加成功!');window.parent.location.href='CourseList.aspx';</script>"); } else { Response.Write(JSHelper.ShowAlert("添加失败!")); } } else { co.CourseID = courseID; oucITEntities db = new oucITEntities(); if (CourseHelper.ChangeCourse(co, db)) { Response.Write("<script>alert('修改成功!');window.parent.location.href='CourseList.aspx';</script>"); } else { Response.Write(JSHelper.ShowAlert("修改失败!")); } } } else { Response.Write(JSHelper.ShowAlert("添加失败!")); } }