Exemplo n.º 1
0
        public void AddInDictionary()
        {
            Initialize();
            var dictionary = studentCollection.Add(DataSource.GetStudent(), "Maths");


            var str = studentCollection.Retrieve(DataSource.GetStudent());

            //Assert.IsTrue(string.Equals(str, "Maths", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(str, dictionary[DataSource.GetStudent()], StringComparison.OrdinalIgnoreCase));

            // Debug.WriteLine(dict.Count);
        }
Exemplo n.º 2
0
        public static StudentCollection SelectAll()
        {
            DataTable         dt     = database.DBLayer.ExecuteQuery("select * from Student");
            StudentCollection result = new StudentCollection();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Department dept     = new Department();
                Admin      adm      = new Admin();
                int        id       = Convert.ToInt32(dt.Rows[i]["id"]);
                string     userName = dt.Rows[i]["st_userName"].ToString();
                string     name     = dt.Rows[i]["st_Name"].ToString();
                string     address  = dt.Rows[i]["st_address"].ToString();
                string     phone    = dt.Rows[i]["st_phone"].ToString();
                string     email    = dt.Rows[i]["st_email"].ToString();
                int        age      = Convert.ToInt32(dt.Rows[i]["st_age"]);
                int        flag     = Convert.ToInt32(dt.Rows[i]["ins_flag"]);
                adm.Id  = Convert.ToInt32(dt.Rows[i]["FK_AdminID"]);
                dept.Id = Convert.ToInt32(dt.Rows[i]["FK_DeptID"]);
                string  pass    = dt.Rows[i]["st_password"].ToString();
                Student session = new Student(id, userName, name, age, address, phone, email, pass, adm, dept);
                result.Add(session);
            }
            return(result);
        }
Exemplo n.º 3
0
        private static void addStudent()
        {
            System.Console.Write("Student Name: ");
            string studentName = Console.ReadLine();

            System.Console.Write("Student Number: ");
            string number = Console.ReadLine();

            System.Console.Write("Course Name: ");
            string courseName = Console.ReadLine();

            students.Add(studentName, number, courses.Set(courseName));
            Console.WriteLine("Student Added.");
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            StudentCollection students = new StudentCollection();

            students.Add(new Student(1, "Артем", "KhAI", 100));
            students.Add(new Student(2, "Вас", "KhNURE", 75));
            students.Add(new Student(3, "Петя", "KhNURE", 70));
            students.Add(new Student(4, "Герман", "Karazina", 30));
            students.Add(new Student(5, "Яся", "KhAI", 50));
            students.Add(new Student(6, "Артур", "Karazina", 65));
            students.Add(new Student(7, "Олег", "Karazina", 45));

            //students.Add(new Student(7, "Олег", "Karazina", 45)); //Исключение(описано в комментариях) - существующий студент

            //students.SortById();
            students.SortByName();
            //students.SortByUniversity();
            Console.WriteLine("Сортировка по имени");
            foreach (Student item in students)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine();
            Console.WriteLine("Выбираем студента через ID");
            Console.WriteLine(students[1]);
            Console.WriteLine();
            //Console.WriteLine(students[50]); //Исключение(описано в комментариях) - такого студента нет

            Student studentForRemove = new Student(4, "Герман", "Karazina", 30);

            students.Remove(studentForRemove);

            students.SortByAssessment();
            Console.WriteLine("Сортировка по оценками");
            foreach (Student item in students)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine();

            Console.WriteLine("Выбираем студентов по ВУЗу");
            foreach (Student item in students.GetStudentsByUniversity("KhAI"))
            {
                Console.WriteLine(item);
            }
            Console.WriteLine();
        }
        protected override Entity OnAdd()
        {
            var newItem = new Dll.Student.Student();

            using (var frm = new frmStudent_Add())
            {
                frm.ItemData = newItem;
                if (frm.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return(null);
                }
            }

            App.LogAction("Student", "Created Student : " + newItem.StudentNumber.ToString());

            ItemDataCollection.Add(newItem);
            return(newItem);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Populates the Student combobox
 /// </summary>
 public void PopulateStudentsCbo()
 {
     try
     {
         using (var context = new SchoolU_DBEntities())
         {
             context.Database.Connection.Open();
             StudentCollection.Clear();
             StudentCollection.Add(new Student {
                 StudentFirstName = "None", StudentLastName = "None"
             });
             IList <Student> allStudentsFN = context.Students.Where(i => i.StudentId != 0).ToList();
             foreach (var item in allStudentsFN)
             {
                 StudentCollection.Add(item);
             }
         }
     }
     catch (Exception ex)
     {
         //MessageBox.Show(ex.Message);
         return;
     }
 }
Exemplo n.º 7
0
        void _bgworker_DoWork(object sender, DoWorkEventArgs e)
        {
            object[]           obj              = (object[])e.Argument;
            AccessHelper       helper           = (AccessHelper)obj[0];
            List <ClassRecord> selected_classes = (List <ClassRecord>)obj[1];
            ReportOptions      option           = (ReportOptions)obj[2];


            _bgworker.ReportProgress(0);

            StudentCollection student_collection = new StudentCollection();
            //List<StudentRecord> failed = new List<StudentRecord>();
            double student_counter = 1;
            double student_total   = 0;
            List <StudentRecord> selected_students = new List <StudentRecord>();

            foreach (ClassRecord classRec in selected_classes)
            {
                student_total += classRec.Students.Count;
                selected_students.AddRange(classRec.Students);
            }
            #region 資料取得與整理

            int package_size = 50;
            List <StudentRecord> packaged_students = new List <StudentRecord>();
            foreach (StudentRecord record in selected_students)
            {
                packaged_students.Add(record);
                if (packaged_students.Count >= package_size)
                {
                    helper.StudentHelper.FillSemesterSubjectScore(true, packaged_students);
                    helper.StudentHelper.FillSemesterEntryScore(true, packaged_students);
                    packaged_students.Clear();
                }
                _bgworker.ReportProgress((int)(student_counter++ *40.0 / student_total));
            }
            if (packaged_students.Count > 0)
            {
                helper.StudentHelper.FillSemesterSubjectScore(true, packaged_students);
                helper.StudentHelper.FillSemesterEntryScore(true, packaged_students);
                packaged_students.Clear();
            }

            foreach (ClassRecord classRec in selected_classes)
            {
                List <Student> list = new List <Student>();
                foreach (StudentRecord each_stu in classRec.Students)
                {
                    Student student = new Student(each_stu, option.ScoreType, option.PrintSemester, option.PrintEntries);
                    list.Add(student);
                    if (!student_collection.ContainsKey(each_stu.StudentID))
                    {
                        student_collection.Add(each_stu.StudentID, student);
                    }
                }
                #region 科目班排名
                List <string> rankedSubject = new List <string>();
                foreach (Student stu in list)
                {
                    foreach (string subject in stu.SubjectCollection.Keys)
                    {
                        if (rankedSubject.Contains(subject))
                        {
                            continue;
                        }
                        List <decimal> scores = new List <decimal>();
                        Dictionary <decimal, List <SubjectInfo> > rank = new Dictionary <decimal, List <SubjectInfo> >();
                        foreach (Student student in list)
                        {
                            if (student.SubjectCollection.ContainsKey(subject))
                            {
                                decimal score = student.SubjectCollection[subject].GetAverange();
                                scores.Add(score);
                                if (!rank.ContainsKey(score))
                                {
                                    rank.Add(score, new List <SubjectInfo>());
                                }
                                rank[score].Add(student.SubjectCollection[subject]);
                            }
                        }
                        scores.Sort();
                        scores.Reverse();

                        decimal lastscore = decimal.MinValue;
                        int     count     = scores.Count;
                        foreach (decimal score in scores)
                        {
                            if (lastscore != score)
                            {
                                int place = scores.IndexOf(score) + 1;
                                lastscore = score;
                                foreach (SubjectInfo s in rank[lastscore])
                                {
                                    s.Place = place;
                                    s.Radix = count;
                                }
                            }
                        }

                        rankedSubject.Add(subject);
                    }
                }
                #endregion
                #region 分項班排名
                List <string> rankedEntrys = new List <string>();
                foreach (Student stu in list)
                {
                    foreach (string entry in stu.EntryCollection.Keys)
                    {
                        if (rankedEntrys.Contains(entry))
                        {
                            continue;
                        }
                        List <decimal> scores = new List <decimal>();
                        Dictionary <decimal, List <EntryInfo> > rank = new Dictionary <decimal, List <EntryInfo> >();
                        foreach (Student student in list)
                        {
                            if (student.EntryCollection.ContainsKey(entry))
                            {
                                decimal score = student.EntryCollection[entry].GetAverange();
                                scores.Add(score);
                                if (!rank.ContainsKey(score))
                                {
                                    rank.Add(score, new List <EntryInfo>());
                                }
                                rank[score].Add(student.EntryCollection[entry]);
                            }
                        }
                        scores.Sort();
                        scores.Reverse();

                        decimal lastscore = decimal.MinValue;
                        int     count     = scores.Count;
                        //把排名填回每一個成績資料中
                        foreach (decimal score in scores)
                        {
                            if (lastscore != score)
                            {
                                int place = scores.IndexOf(score) + 1;
                                lastscore = score;
                                foreach (EntryInfo s in rank[lastscore])
                                {
                                    s.Place = place;
                                    s.Radix = count;
                                    //處理德行不允許破百
                                    if (s.Name == "德行" && option.FixMoralScore)
                                    {
                                        s.FixToLimit(100);
                                    }
                                }
                            }
                        }

                        rankedEntrys.Add(entry);
                    }
                }
                #endregion
            }
            #endregion
            student_counter = 1;
            #region 產生報表及SnapShop
            MemoryStream template = GetTemplate(option);
            Document     doc      = new Document();
            doc.Sections.Clear();
            List <SmartSchool.Feature.Student.StudentSnapShop> snapShops            = new List <SmartSchool.Feature.Student.StudentSnapShop>();
            MultiThreadWorker <SmartSchool.Feature.Student.StudentSnapShop> mWorker = new MultiThreadWorker <SmartSchool.Feature.Student.StudentSnapShop>();
            mWorker.MaxThreads     = 3;
            mWorker.PackageSize    = 50;
            mWorker.PackageWorker += new EventHandler <PackageWorkEventArgs <SmartSchool.Feature.Student.StudentSnapShop> >(mWorker_PackageWorker);

            foreach (string stuid in student_collection.Keys)
            {
                Student each_stu = student_collection[stuid];
                #region 一個學生產生一個新的Document
                //一個學生產生一個新的Document
                Document each_page = new Document(template, "", LoadFormat.Doc, "");
                #region 建立此學生的成績單
                //合併基本資料
                List <string> merge_keys   = new List <string>();
                List <object> merge_values = new List <object>();
                merge_keys.AddRange(new string[] { "學校名稱", "科別名稱", "班級名稱", "座號", "學號", "姓名", "排名", "各學期成績" });
                merge_values.AddRange(new object[] {
                    SmartSchool.Customization.Data.SystemInformation.SchoolChineseName,
                    each_stu.Department,
                    each_stu.ClassName,
                    each_stu.SeatNo,
                    each_stu.StudentNumber,
                    each_stu.StudentName,
                    option.RatingMethod.ToString(),
                    each_stu
                });
                each_page.MailMerge.MergeField += new Aspose.Words.Reporting.MergeFieldEventHandler(MailMerge_MergeField);
                each_page.MailMerge.Execute(merge_keys.ToArray(), merge_values.ToArray());
                #endregion
                #endregion
                #region 加入新的SnapShop
                SmartSchool.Feature.Student.StudentSnapShop newSnapShop = new SmartSchool.Feature.Student.StudentSnapShop();
                newSnapShop.SnapshopName = "多學期成績單";
                newSnapShop.RefStudentID = stuid;
                newSnapShop.PresentType  = ".Doc";
                MemoryStream stream = new MemoryStream();
                each_page.Save(stream, SaveFormat.Doc);
                newSnapShop.PresentContent = Convert.ToBase64String(stream.ToArray());
                stream.Close();
                snapShops.Add(newSnapShop);
                #endregion
                //每300人次就直接上傳一次snapShops
                #region 每300人次就直接上傳一次
                if (snapShops.Count == 300)
                {
                    mWorker.Run(snapShops);
                    snapShops.Clear();
                }
                #endregion
                //合併成績單至一個檔案
                doc.Sections.Add(doc.ImportNode(each_page.Sections[0], true));
                //回報進度
                _bgworker.ReportProgress((int)(student_counter++ *60.0 / student_total) + 40);
            }
            //將最後一段的SnapShop上傳
            if (snapShops.Count > 0)
            {
                mWorker.Run(snapShops);
                snapShops.Clear();
            }
            #endregion

            e.Result = doc;
        }
Exemplo n.º 8
0
        public StudentCollection QueryAll()
        {
            StudentCollection result = new StudentCollection();

            IEnumerator<Student> iterator = this.dataContext.StudentTable.GetEnumerator();
            while (iterator.MoveNext())
            {
                result.Add(iterator.Current);
            }
            return result;
        }
Exemplo n.º 9
0
        private void _disciplineLoader_DoWork(object sender, DoWorkEventArgs e)
        {
            _disciplineLoader.ReportProgress(0);

            _students.Clear();
            Dictionary <string, List <Discipline> > studentDisciplines = new Dictionary <string, List <Discipline> >();

            #region 抓所有獎懲紀錄

            DSXmlHelper helper = new DSXmlHelper("Request");
            helper.AddElement("Field");
            helper.AddElement("Field", "All");
            helper.AddElement("Condition");
            helper.AddElement("Condition", "SchoolYear", _school_year.ToString());
            helper.AddElement("Condition", "Semester", _semester.ToString());
            DSResponse dsrsp = DSAServices.CallService("SmartSchool.Student.Discipline.GetDiscipline", new DSRequest(helper));

            double dis_amount = dsrsp.GetContent().GetElements("Discipline").Length;
            double dis_count  = 0;

            foreach (XmlElement disElement in dsrsp.GetContent().GetElements("Discipline"))
            {
                dis_count++;

                DSXmlHelper disHelper = new DSXmlHelper(disElement);

                string id   = disHelper.GetText("RefStudentID");
                string kind = "";
                switch (disHelper.GetText("MeritFlag"))
                {
                case "1":
                    kind = "獎勵";
                    break;

                case "0":
                    kind = "懲罰";
                    break;

                case "2":
                    kind = "留校察看";
                    break;

                default:
                    break;
                }

                Discipline dis = new Discipline(id, kind);

                if (disHelper.GetText("MeritFlag") == "1")
                {
                    dis.AwardA = int.Parse(disHelper.GetText("Detail/Discipline/Merit/@A"));
                    dis.AwardB = int.Parse(disHelper.GetText("Detail/Discipline/Merit/@B"));
                    dis.AwardC = int.Parse(disHelper.GetText("Detail/Discipline/Merit/@C"));
                }

                if (disHelper.GetText("MeritFlag") == "0")
                {
                    dis.FaultA = int.Parse(disHelper.GetText("Detail/Discipline/Demerit/@A"));
                    dis.FaultB = int.Parse(disHelper.GetText("Detail/Discipline/Demerit/@B"));
                    dis.FaultC = int.Parse(disHelper.GetText("Detail/Discipline/Demerit/@C"));

                    dis.Cleared = (disHelper.GetText("Detail/Discipline/Demerit/@Cleared") == "是") ? true : false;
                }
                if (!dis.Cleared)
                {
                    if (!studentDisciplines.ContainsKey(dis.StudentID))
                    {
                        studentDisciplines.Add(dis.StudentID, new List <Discipline>());
                    }
                    studentDisciplines[dis.StudentID].Add(dis);
                }

                _disciplineLoader.ReportProgress((int)((dis_count * 30) / dis_amount));
            }

            #endregion

            AccessHelper accessHelper = new AccessHelper();

            //抓有獎懲的學生
            List <StudentRecord> studentRecs = accessHelper.StudentHelper.GetStudents(studentDisciplines.Keys);

            double stu_amount = studentRecs.Count;
            double stu_count  = 0;

            #region 填入學生學期歷程(作廢)
            //填入學生學期歷程
            //List<StudentRecord> partList = new List<StudentRecord>();
            //int size = 50;
            //foreach (StudentRecord stu in studentRecs)
            //{
            //    stu_count++;

            //    partList.Add(stu);
            //    if (partList.Count == size)
            //    {
            //        accessHelper.StudentHelper.FillSemesterHistory(partList);
            //        partList.Clear();
            //    }

            //    _disciplineLoader.ReportProgress(30 + (int)((stu_count * 50) / stu_amount));
            //}
            //if (partList.Count > 0)
            //    accessHelper.StudentHelper.FillSemesterHistory(partList);
            #endregion

            #region 整理成好用的學生資料

            stu_count = 0;

            foreach (StudentRecord studentRec in studentRecs)
            {
                stu_count++;

                Student stu = new Student(studentRec.StudentID);
                stu.Name          = studentRec.StudentName;
                stu.StudentNumber = studentRec.StudentNumber;
                stu.Gender        = studentRec.Gender;
                stu.Department    = studentRec.Department;
                stu.ClassName     = studentRec.RefClass != null ? studentRec.RefClass.ClassName : "";
                stu.GradeYear     = studentRec.RefClass != null ? studentRec.RefClass.GradeYear : "";

                // 作廢
                //foreach (SemesterHistory his in studentRec.SemesterHistoryList)
                //{
                //    if (his.SchoolYear == _school_year && his.Semester == _semester)
                //    {
                //        stu.GradeYear = "" + his.GradeYear;
                //        break;
                //    }
                //}

                foreach (Discipline dis in studentDisciplines[studentRec.StudentID])
                {
                    if (dis.Kind == "留校察看")
                    {
                        stu.UltimateAdmonition = true;
                    }
                    stu.AwardA += dis.AwardA;
                    stu.AwardB += dis.AwardB;
                    stu.AwardC += dis.AwardC;
                    stu.FaultA += dis.FaultA;
                    stu.FaultB += dis.FaultB;
                    stu.FaultC += dis.FaultC;
                }

                _students.Add(stu.ID, stu);

                _disciplineLoader.ReportProgress(80 + (int)((stu_count * 20) / stu_amount));
            }

            #endregion
        }
 private void AddStudent()
 {
     StudentCollection.Add(new StudentModel(Student));
 }
Exemplo n.º 11
0
 public void AddStudent(Student student)
 {
     StudentCollection.Add(student);
 }
Exemplo n.º 12
0
 private void AddStudentInCollection(StudentModel student)
 {
     StudentCollection.Add(student);
 }