// Start is called before the first frame update
 void Start()
 {
     studentControl = FindObjectOfType <StudentControl>();
     if (studentControl.isLoggedIn())
     {
         ShowName();
     }
 }
Example #2
0
        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            var studentView = new StudentControl();

            newWindow = new Window
            {
                Title   = "Add new student",
                Content = studentView,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };
            newWindow.ShowDialog();
        }
Example #3
0
 private void Awake()
 {
     teacherControl = FindObjectOfType <TeacherControl>();
     studentControl = FindObjectOfType <StudentControl>();
 }
Example #4
0
 /// <summary>
 /// 右键菜单处理。
 /// </summary>
 /// <param name="sc"></param>
 /// <param name="type"></param>
 protected void SCContextMenu(StudentControl sc, StudentControl.EnumContextMenuType type)
 {
     try
     {
         UserInfo info = this.UserInfo;
         if (sc == null || sc.UserInfo == null || info == null)
         {
             return;
         }
         StudentEx stu = Program.STUDENTS[sc.UserInfo.UserID];
         if (stu == null)
         {
             return;
         }
         switch (type)
         {
             case StudentControl.EnumContextMenuType.Offline:
                 {
                     #region 强制学生离线。
                     if (this.NetService != null)
                     {
                         HostCloseBroadcast data = new HostCloseBroadcast();
                         data.HostID = data.UID = info.UserID;
                         if (this.NetService.SendBroadcastPortMSG(data, sc.UserIP))
                         {
                             if ((stu.Status & StudentControl.EnumStudentState.Online) == StudentControl.EnumStudentState.Online)
                             {
                                 stu.Status &= ~StudentControl.EnumStudentState.Online;
                             }
                             stu.Status |= StudentControl.EnumStudentState.Offline;
                             this.UpdateStudentControl(stu);
                         }
                     }
                     #endregion
                 }
                 break;
             case StudentControl.EnumContextMenuType.TemplateDelete:
                 {
                     #region 删除学生。
                     if (!string.IsNullOrEmpty(this.ClassID) && !string.IsNullOrEmpty(this.CatalogID))
                     {
                         LocalStudentWorkStore store = LocalStudentWorkStore.DeSerializer(info.UserID, this.CatalogID, this.ClassID);
                         if (store != null && store.Students != null)
                         {
                             LocalStudent ls = store.Students[sc.UserInfo.UserID];
                             if (ls != null && store.Students.Remove(ls))
                             {
                                 WorkStoreHelper.DeleteStudentToQueueStore(new WorkStoreHelper.DeleteStudentQueueEntity(ls.StudentID, store.FileSavePath()));
                                 StudentEx stuEx = Program.STUDENTS[ls.StudentID];
                                 if (Program.STUDENTS.Remove(stuEx))
                                 {
                                     this.menuItemRefresh_Click(null, null);
                                 }
                             }
                         }
                     }
                     #endregion
                 }
                 break;
         }
     }
     catch (Exception x)
     {
         this.OnMessageEvent(MessageType.PopupWarn, string.Format("右键菜单处理:{0}", x.Message));
         Program.GlobalExceptionHandler(x);
     }
 }
Example #5
0
        /// <summary>
        /// 分发资源数据。
        /// </summary>
        /// <param name="sc"></param>
        /// <param name="urls"></param>
        protected void IssueResourceData(StudentControl sc, string[] urls)
        {
            try
            {
                UserInfo info = this.UserInfo;
                if (info != null && this.NetService != null &&
                    sc != null && ((sc.State & StudentControl.EnumStudentState.Online) == StudentControl.EnumStudentState.Online) &&
                    urls != null && urls.Length > 0)
                {
                    IssueWorkFile data = new IssueWorkFile();
                    data.UID = info.UserID;
                    data.StudentID = sc.UserInfo.UserID;
                    data.WorkName = System.IO.Path.GetFileName(urls[0]);
                    data.Data = ZipUtils.Zip(urls);

                    this.OnMessageEvent(MessageType.Normal, string.Format("给[{0},{1}]下发资源:{2}", sc.UserInfo.UserName, sc.UserInfo.UserCode, data.WorkName));
                    this.NetService.SendIssueWork(data);
                }
            }
            catch (Exception x)
            {
                this.OnMessageEvent(MessageType.PopupWarn, string.Format("分发资源时发生异常:{0}", x.Message));
                Program.GlobalExceptionHandler(x);
            }
        }
Example #6
0
        /// <summary>
        /// 绘制学生控件。
        /// </summary>
        /// <param name="students"></param>
        protected void DrawStudents(StudentsEx students)
        {
            ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object sender)
            {
                int len = 0;
                StudentControls controls = new StudentControls();
                if (students != null && (len = students.Count) > 0)
                {
                    for (int i = 0; i < len; i++)
                    {
                        if (students[i] != null)
                        {
                            StudentControl sc = new StudentControl();
                            sc.ColorSettings = this.settings;
                            sc.MachineName = students[i].MachineName;
                            sc.UserIP = students[i].IP;
                            sc.UserInfo = new UserInfo();
                            sc.UserInfo.UserID = students[i].StudentID;
                            sc.UserInfo.UserCode = students[i].StudentCode;
                            sc.UserInfo.UserName = students[i].StudentName;
                            sc.PropertyChanged += this.StudentControlPropertyChanged;
                            sc.DoubleClick += this.StudentControlDoubleClick;
                            sc.State = students[i].Status;
                            sc.DragDropData += this.IssueResourceData;
                            sc.ContextHandler += this.SCContextMenu;
                            controls.Add(sc);
                        }
                    }
                }
                //绘制界面。
                this.ThreadSafeMethod(this.panelWork, new MethodInvoker(delegate()
                {
                    controls.DrawToPanel(this.panelWork, 4, 5);
                }));

            }));
        }
        static void Main(string[] args)
        {
            var control = new StudentControl();

            var students = control.GetAllStudents();


            Console.WriteLine("Students\n-----------------------------------------------");
            foreach (var s in students)
            {
                Console.WriteLine("Name: " + s.People.FirstName + " " + s.People.LastName);
                foreach (var g in s.Grades)
                {
                    Console.WriteLine("Course: " + g.Courses.CourseName + " Grade: " + g.Grade);
                    Console.WriteLine("--------------------------------------------------------");
                }
            }

            var peopleCtx = new PeopleControl();

            //var people = peopleCtx.GetAllPeople();


            //// Insert
            //peopleCtx.InsertPeople(new People() { FirstName = "Algot", LastName = "Alfredsson", Email = "*****@*****.**" });

            //people.ToList().ForEach(x => Console.WriteLine($"{x.Id} {x.FirstName} {x.LastName} {x.Email}"));

            //Delete
            //var input = Console.ReadLine();

            //var toDelete = peopleCtx.PeopleByID(int.Parse(input));

            //peopleCtx.RemovePeople(toDelete);

            //var newPeople = peopleCtx.GetAllPeople();

            //newPeople.ToList().ForEach(x => Console.WriteLine($"{x.Id} {x.FirstName} {x.LastName} {x.Email}"));

            //Update
            //Console.WriteLine("id: ");
            //var nameID = Console.ReadLine();
            //Console.WriteLine("New Name:");
            //var namechange = Console.ReadLine();

            //var nameChangePerson = peopleCtx.PeopleByID(int.Parse(nameID));

            //nameChangePerson.FirstName = namechange;

            //peopleCtx.UpdatePeople(nameChangePerson);

            //var newPeople2 = peopleCtx.GetAllPeople();

            //newPeople2.ToList().ForEach(x => Console.WriteLine($"{x.Id} {x.FirstName} {x.LastName} {x.Email}"));

            //Insert Student
            var ppl = new People()
            {
                FirstName = "Lisa", LastName = "Sävås", Email = "Lisa@Sävås.se"
            };

            peopleCtx.InsertPeople(ppl);

            var studentClass = new StudentClasses()
            {
                ClassName = "WIN15"
            };

            var studentClassesCtx = new ClassesControl();

            studentClassesCtx.InsertorUpdateClass(studentClass);



            var educationCTX = new EducationsControl();

            var education = new Educations()
            {
                EducationName = "Administration"
            };

            educationCTX.InsertorUpdateEducation(education);


            var newStudent = new Students()
            {
                PersonId        = ppl.Id,
                StudentClass_Id = studentClass.Id,
                EducationId     = education.Id
            };

            control.InsertStudent(newStudent);

            var newStudentContext = new StudentControl();
            var studentsList      = newStudentContext.GetAllStudents().ToList();

            Console.WriteLine("Added new student Lisa");
            Console.WriteLine("-------Students Again-------");
            foreach (var stud in studentsList)
            {
                Console.WriteLine("Name: " + stud.People.FirstName + " " + stud.People.LastName);
                Console.WriteLine("CourseID: " + stud.StudentClasses.Id + " Class: " + stud.StudentClasses.ClassName);
                Console.WriteLine("ID: " + stud.Educations.Id + " Education Name: " + stud.Educations.EducationName);
                Console.WriteLine("--------------------------------------------------------------------------------");
            }

            var AttendanceControl = new AttendanceControl();

            Attendance att = new Attendance()
            {
                Date = new DateTime(2016, 11, 02), StudentID = newStudent.Id, CourseID = 2, Attendance1 = false
            };

            AttendanceControl.InsertAttendance(att);

            var lisa = newStudentContext.StudentsByID(newStudent.Id);

            var attendance = new AttendanceControl();

            var attendanceObj = attendance.AttendaceByStudentAndCourseID(newStudent.Id, 2);

            Console.WriteLine("Added new attendance for Lisa");
            Console.WriteLine("-----Attendance-----");
            Console.WriteLine($"{lisa.People.FirstName} {lisa.People.LastName} Närvaro i {attendanceObj.Courses.CourseName} den {attendanceObj.Date}: {attendanceObj.Attendance1}");
            Console.WriteLine();

            AttendanceControl.RemoveAttendance(att);
            //educationCTX.RemoveEducation(education);
            control.RemoveStudent(newStudent);
            studentClassesCtx.RemoveClass(studentClass);
            educationCTX.RemoveEducation(education);
            peopleCtx.RemovePeople(ppl);


            Console.ReadKey();
        }