예제 #1
0
        /// <summary>
        /// 加载已选课程
        /// </summary>
        public void BindSelectCourese()
        {
            DALstudent_course            dal = new DALstudent_course();
            IList <student_courseEntity> scs = dal.Getstudent_coursesbyCondition("StudentId='" + Session["name"].ToString() + "'");

            if (scs.Count > 0)
            {
                Button1.Enabled = false;
                Button2.Enabled = false;
                Button3.Enabled = false;
                Button3.ToolTip = "您已经选过课程了,只能查看!";
                lb2.Items.Clear();//先清空,再绑定已选择的课程
                DALcourse    dalc = new DALcourse();
                courseEntity c    = new courseEntity();
                foreach (student_courseEntity sc in scs)
                {
                    c = dalc.Getcourse(int.Parse(sc.CourseId));//通过选课存储的课程号,到课程表中取出该课程的课程名称等信息
                    ListItem li = new ListItem(c.CourseName, c.Id.ToString());
                    lb2.Items.Add(li);
                }
            }
            else
            {
                Button1.Enabled = true;
                Button2.Enabled = true;
                Button3.Enabled = true;
            }
        }
예제 #2
0
        /// <summary>
        /// DropDownList1加载已有的全部课程名称
        /// </summary>
        protected void BindCourse()
        {
            string conditon = string.Empty;

            conditon = " StudentId='" + Session["id"] + "'";
            DALstudent_course            dal    = new DALstudent_course();
            IList <student_courseEntity> course = dal.Getstudent_coursesbyCondition(conditon);//按照条件来查询数据

            GridView1.DataSource = course;
            GridView1.DataBind();



            //string condition = string.Empty;
            //DropDownList1.Items.Clear();//避免重复加载

            //condition = " id in (select CourseId from student_course where StudentId='" + Session["id"] + "')";
            //DALcourse dal = new DALcourse();
            //IList<courseEntity> courses = dal.GetcoursesbyCondition(condition);
            //DropDownList1.DataSource = courses;
            //DropDownList1.DataTextField = "CourseName";
            //DropDownList1.DataValueField = "Id";
            //DropDownList1.DataBind();
            //DropDownList1.Items.Insert(0, new ListItem("请选择要查询的课程", "0"));
        }
예제 #3
0
        public void LoadData()
        {
            string conditon = string.Empty;

            conditon = "CourseId='" + DropDownList1.SelectedValue + "'";
            DALstudent_course            dal    = new DALstudent_course();
            IList <student_courseEntity> course = dal.Getstudent_coursesbyCondition(conditon);

            grdCourse.DataSource = course;
            grdCourse.DataBind();
        }
예제 #4
0
        public void LoadData()
        {
            string conditon = string.Empty;

            conditon = "(StudentId is not null and StudentId<>' ')";
            if (!string.IsNullOrEmpty(DropDownList1.SelectedValue))
            {
                conditon += " and CourseId='" + DropDownList1.SelectedValue + "' and StudentId='" + Session["uName"] + "'";
            }
            DALstudent_course            dal    = new DALstudent_course();
            IList <student_courseEntity> Course = dal.Getstudent_coursesbyCondition(conditon);

            GridView1.DataSource = Course;
            GridView1.DataBind();
        }
예제 #5
0
        /// <summary>
        /// 根据选择的课程,加载选修该课程的学生信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DALstudent_course            dal = new DALstudent_course();
            IList <student_courseEntity> scs = dal.Getstudent_coursesbyCondition("CourseId='" + DropDownList1.SelectedValue + "'");

            GridView1.DataSource = scs;
            GridView1.DataBind();
            if (scs.Count > 0)
            {
                Button1.Visible = true;
            }
            else
            {
                Button1.Visible = false;
            }
        }
예제 #6
0
        /// <summary>
        /// 加载已选课程
        /// </summary>
        public void BindSelectCourese()
        {
            DALstudent_course            dal = new DALstudent_course();
            IList <student_courseEntity> scs = dal.Getstudent_coursesbyCondition("StudentId='" + Session["id"].ToString() + "'");

            if (scs.Count > 0)
            {
                this.Page.RegisterStartupScript("", "<script>alert(您已选择过课程!);</script>");
                Response.Redirect("CourseSelectList.aspx");
            }
            else
            {
                Button1.Enabled = true;
                Button2.Enabled = true;
                Button3.Enabled = true;
            }
        }