Ejemplo n.º 1
0
        private student2 GetLastStudent()
        {
            var      mNum        = -1;
            student2 lastStudent = null;

            foreach (student2 s in dgStudent.Items.SourceCollection)
            {
                if (s.num > mNum)
                {
                    mNum        = s.num;
                    lastStudent = s;
                }
            }
            return(lastStudent);
        }
Ejemplo n.º 2
0
 private string GetName(object obj)
 {
     if (obj is student2)
     {
         student2 s   = ((student2)obj);
         int      cnt = S.DB.history.Count(history => history.sid == s.sid);
         return($"{s.num:D2}. {s.name} ({cnt})");
     }
     if (obj is @group2)
     {
         @group2 g = ((@group2)obj);
         return($"{g.name}");
     }
     return("");
 }
Ejemplo n.º 3
0
        private void DrawLots(object sender, RoutedEventArgs e)
        {
            student2[] sPool = GetStudentPool();
            student2   s     = sPool[rand.Next(sPool.Length)];

            ShowDynamicResults(sPool, s, new Action(() =>
            {
                S.DB.history.Add(new history2()
                {
                    sid  = s.sid,
                    cid  = s.cid,
                    date = DateTime.Now,
                });
                S.DB.SaveChanges();
            }), new Action(LoadStudents));
        }
Ejemplo n.º 4
0
        private void SelectStudentGroup(@group2 g)
        {
            student2[]    ss    = S.DB.student.Where(s => s.cid == cid && s.gid == g.gid).ToArray();
            var           panel = NamePanel;
            List <object> objs  = new List <object>();

            foreach (object obj in panel.Children)
            {
                if (obj is ToggleButton)
                {
                    if (((ToggleButton)obj).Tag is student2)
                    {
                        student2 s = ((ToggleButton)obj).Tag as student2;
                        ((ToggleButton)obj).IsChecked = ss.Contains(s);
                    }
                }
            }
        }