Exemple #1
0
        public void BindData()
        {
            List<JiaJiao.Model.ClassInfo> list = new List<JiaJiao.Model.ClassInfo>();
            JiaJiao.BLL.Teacher bllTeacher = new JiaJiao.BLL.Teacher();
            JiaJiao.BLL.ClassSetting classSetting=new BLL.ClassSetting();

            var classlist = bll.GetModelList("").GroupBy(key => key.Day);
            foreach (var item in classlist)
            {
                list.Add(new JiaJiao.Model.ClassInfo() { Day = item.Key });
            }

               var teacherlist = bllTeacher.GetModelList("");
               teachers = teacherlist;
               var clsSetting = classSetting.GetModelList("").GroupBy(key => key.DayId);
               int index = 0;

               foreach (var item in classlist)
               {
               int index1 = 0;
               foreach (var item0 in item)
               {
                  var templist =clsSetting.Where(key => key.Key == item0.ID);
                  if (templist.Count() > 0)
                  {
                      foreach (var item1 in templist.FirstOrDefault())
                      {
                         var teacher=  teacherlist.Where(t => t.ID == item1.TeacherId).FirstOrDefault();
                         if (teacher != null)
                         {
                             switch (index1)
                             {
                                 case 0:
                                     list[index].Time1 += teacher.TeacherName+" ";
                                     break;
                                 case 1:
                                     list[index].Time2 += teacher.TeacherName + " ";
                                     break;
                                 case 2:
                                     list[index].Time3 += teacher.TeacherName + " ";
                                     break;
                                 case 3:
                                     list[index].Time4 += teacher.TeacherName + " ";
                                     break;
                                 case 4:
                                     list[index].Time5 += teacher.TeacherName + " ";
                                     break;
                                 case 5:
                                     list[index].Time6 += teacher.TeacherName + " ";
                                     break;
                                 case 6:
                                     list[index].Time7 += teacher.TeacherName + " ";
                                     break;
                             }

                         }
                      }
                  }
                  index1++;
               }
               index++;
               }

            gridView.DataSource = list;
            gridView.DataBind();
        }
        public void BindData()
        {
            List<JiaJiao.Model.ClassInfo> list = new List<JiaJiao.Model.ClassInfo>();
            JiaJiao.BLL.Teacher bllTeacher = new JiaJiao.BLL.Teacher();
            JiaJiao.BLL.ClassSetting classSetting = new BLL.ClassSetting();
            JiaJiao.BLL.Class Classbll = new JiaJiao.BLL.Class();

            var classlist = Classbll.GetModelList("").GroupBy(key => key.Day);
            foreach (var item in classlist)
            {
                list.Add(new JiaJiao.Model.ClassInfo() { Day = item.Key, KeyValues = new Dictionary<int, Model.ClassSetting>() });
            }

            var teacherlist = bllTeacher.GetModelList("");
            var teacher = teacherlist.Where(t => t.ID.ToString() == Request.QueryString["id"]).FirstOrDefault();
            if (teacher != null)
            {
                Image1.ImageUrl= teacher.Image;
                Label1.Text = teacher.TeacherName;
                Label2.Text = teacher.TeacherDescribe;
            }

            var clsSetting = classSetting.GetModelList("teacherid=" + Request.QueryString["id"]).GroupBy(key => key.DayId);
            int index = 0;

            foreach (var item in classlist)
            {
                int index1 = 0;
                foreach (var item0 in item)
                {
                    var templist = clsSetting.Where(key => key.Key == item0.ID);
                    if (templist.Count() > 0)
                    {
                        foreach (var item1 in templist.FirstOrDefault())
                        {
                            switch (index1)
                            {
                                case 0:
                                    list[index].Time1 += item1.Count + "/" + item1.Total;
                                    break;
                                case 1:
                                    list[index].Time2 += item1.Count + "/" + item1.Total;
                                    break;
                                case 2:
                                    list[index].Time3 += item1.Count + "/" + item1.Total;
                                    break;
                                case 3:
                                    list[index].Time4 += item1.Count + "/" + item1.Total;
                                    break;
                                case 4:
                                    list[index].Time5 += item1.Count + "/" + item1.Total;
                                    break;
                                case 5:
                                    list[index].Time6 += item1.Count + "/" + item1.Total;
                                    break;
                                case 6:
                                    list[index].Time7 += item1.Count + "/" + item1.Total;
                                    break;
                            }
                            list[index].KeyValues.Add(index1, item1);
                        }
                    }
                    else
                    {
                        list[index].KeyValues.Add(index1, null);
                    }
                    index1++;
                }
                index++;
            }

            gridView.DataSource = list;
            gridView.DataBind();
        }