Beispiel #1
0
        /// <summary>
        /// 单击课程名时显示课程详细信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lb1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DALcourse    dal    = new DALcourse();
            courseEntity course = dal.Getcourse(int.Parse(lb1.SelectedValue));

            Literal1.Text = "课程名称:" + course.CourseName + ";<br/>授课教师:" + course.CourseTeacher + ";<br/>课程简介:" + course.CourseInfo + ";<br/>限选人数:" + course.CourseStudentNum;
        }
        /// <summary>
        /// 当行数据绑定的时候,进行必要的翻译处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //翻译课程
                DALcourse    dalc = new DALcourse();
                courseEntity c    = dalc.Getcourse(int.Parse(e.Row.Cells[1].Text));
                if (c != null)                          //判断是否有值
                {
                    e.Row.Cells[1].Text = c.CourseName; //有值才能使用
                }
                //else
                //{
                //    Response.Write("<script>alert('kongde');</script>");
                //}

                //翻译学生
                DALstudent_info            dals = new DALstudent_info();
                IList <student_infoEntity> ss   = dals.Getstudent_infosbyCondition("studentId='" + e.Row.Cells[0].Text + "'");
                if (ss.Count > 0)
                {
                    e.Row.Cells[0].Text = ss[0].StudentId;
                }
            }
        }
        /// <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;
            }
        }
Beispiel #4
0
 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         //翻译课程号->名称
         DALcourse    dalc = new DALcourse();
         courseEntity c    = dalc.Getcourse(int.Parse(e.Row.Cells[0].Text));
         if (c != null)
         {
             e.Row.Cells[0].Text = c.CourseName;
         }
     }
 }
Beispiel #5
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            DALcourse    dal    = new DALcourse();                                 //定义针对admin_user表的操作对象
            string       Id     = GridView1.DataKeys[e.RowIndex].Value.ToString(); //获取操作行数据的主键Id
            courseEntity course = dal.Getcourse(int.Parse(Id));

            course.CourseName       = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim();
            course.CourseTeacher    = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim();
            course.CourseInfo       = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim();
            course.CourseStudentNum = int.Parse(((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim());
            dal.Modcourse(course);
            GridView1.EditIndex = -1;
            LoadData();//重新加载数据,验证是否重置
        }
Beispiel #6
0
        /// <summary>
        /// 当行数据绑定的时候,进行必要的翻译处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //翻译课程编号->名称
                DALcourse    dalc = new DALcourse();
                courseEntity c    = dalc.Getcourse(int.Parse(e.Row.Cells[1].Text));
                if (c != null)
                {
                    e.Row.Cells[1].Text = c.CourseName;
                }

                //翻译学生编号->姓名
                DALstudent_info            dals = new DALstudent_info();
                IList <student_infoEntity> ss   = dals.Getstudent_infosbyCondition("Id='" + e.Row.Cells[0].Text + "'");
                if (ss.Count > 0)
                {
                    e.Row.Cells[0].Text = ss[0].StudentName;
                }
            }
        }