Ejemplo n.º 1
0
        /// <summary>
        /// 根據總時數更新班級列表,同時考量到關鍵字搜尋
        /// </summary>
        private void RefreshByTotalHour(string idWhom)
        {
            int Total = 0;

            //根據分課的總時數進行分類
            SortedDictionary<int, List<string>> TotalWhoms = new SortedDictionary<int, List<string>>();

            foreach (Class Whom in schLocal.Classes)
            {
                if (Whom.Name.Equals("無"))
                    continue;

                int TotalHour = Whom.TotalHour;

                if (!TotalWhoms.ContainsKey(TotalHour))
                    TotalWhoms.Add(TotalHour, new List<string>());

                if (IsAddWhom(Whom.Name))
                    if (!TotalWhoms[TotalHour].Contains(Whom.ClassID))
                        TotalWhoms[TotalHour].Add(Whom.ClassID);
            }

            nodeTree.Nodes.Clear();

            Node nodeRoot = new Node("所有班級");
            nodeRoot.TagString = "所有班級";

            Node nodeNull = new Node("無班級");
            nodeNull.TagString = "無";

            nodeTree.Nodes.Add(nodeRoot);
            nodeTree.Nodes.Add(nodeNull);

            foreach (int vTotalHour in TotalWhoms.Keys.ToList().OrderByDescending(x => x))
            {
                Node nodeTotalHour = new Node("" + vTotalHour);
                List<string> Names = new List<string>();

                foreach (string vWhomID in TotalWhoms[vTotalHour])
                {
                    if (schLocal.Classes.Exists(vWhomID))
                    {
                        Class whomPaint = schLocal.Classes[vWhomID];

                        if (whomPaint.TotalHour > 0)
                        {
                            int UnAllocHour = whomPaint.TotalHour - whomPaint.AllocHour;

                            Node nodeWhom = new Node(whomPaint.Name + "(" + UnAllocHour + "/" + whomPaint.TotalHour + ")");
                            nodeWhom.TagString = whomPaint.ClassID;
                            Names.Add(whomPaint.ClassID);
                            nodeTotalHour.Nodes.Add(nodeWhom);
                            Total++;
                        }
                    }
                }

                if (nodeTotalHour.Nodes.Count > 0)
                {
                    nodeTotalHour.Text = nodeTotalHour.Text + "(" + nodeTotalHour.Nodes.Count + ")";
                    nodeTotalHour.TagString = string.Join(";", Names.ToArray());
                    nodeRoot.Nodes.Add(nodeTotalHour);
                    nodeRoot.Expand();
                }
            }

            nodeRoot.Text = nodeRoot.Text + "(" + schLocal.Classes.HasTotalHourCount + ")";
            nodeRoot.ExpandAll();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根據未排時數更新班級列表,同時考量到關鍵字搜尋
        /// </summary>
        private void RefreshByUnAlloc(string idWho)
        {
            int Total = 0;

            //根據分課的未排時數進行分類
            SortedDictionary<int, List<string>> UnAllocWhos = new SortedDictionary<int, List<string>>();

            foreach (Class Whom in schLocal.Classes)
            {
                if (Whom.Name.Equals("無"))
                    continue;

                int UnAlloc = Whom.TotalHour - Whom.AllocHour;

                //若未排時數不在字典中則新增
                if (!UnAllocWhos.ContainsKey(UnAlloc))
                    UnAllocWhos.Add(UnAlloc, new List<string>());

                if (IsAddWhom(Whom.ClassID))
                    if (!UnAllocWhos[UnAlloc].Contains(Whom.ClassID))
                        UnAllocWhos[UnAlloc].Add(Whom.ClassID);
            }

            nodeTree.Nodes.Clear();

            Node nodeRoot = new Node("所有班級");
            nodeRoot.TagString = "所有班級";

            Node nodeNull = new Node("無班級");
            nodeNull.TagString = "無";

            nodeTree.Nodes.Add(nodeRoot);
            nodeTree.Nodes.Add(nodeNull);

            foreach (int vUnAlloc in UnAllocWhos.Keys.ToList().OrderByDescending(x => x))
            {
                Node UnAlloc = new Node("" + vUnAlloc);
                List<string> Names = new List<string>();

                foreach (string vWhomID in UnAllocWhos[vUnAlloc])
                {
                    if (schLocal.Classes.Exists(vWhomID))
                    {
                        Class whomPaint = schLocal.Classes[vWhomID];

                        if (whomPaint.TotalHour > 0)
                        {
                            int UnAllocHour = whomPaint.TotalHour - whomPaint.AllocHour;

                            Node nodeWhom = new Node(whomPaint.Name + "(" + UnAllocHour + "/" + whomPaint.TotalHour + ")");
                            nodeWhom.TagString = whomPaint.ClassID;
                            Names.Add(whomPaint.ClassID);
                            UnAlloc.Nodes.Add(nodeWhom);
                            Total++;
                        }
                    }
                }

                if (UnAlloc.Nodes.Count > 0)
                {
                    UnAlloc.Text = UnAlloc.Text + "(" + UnAlloc.Nodes.Count + ")";
                    UnAlloc.TagString = string.Join(";", Names.ToArray());
                    nodeRoot.Nodes.Add(UnAlloc);
                    nodeRoot.Expand();
                }
            }

            nodeRoot.Text = nodeRoot.Text + "(" + schLocal.Classes.HasTotalHourCount + ")";
            nodeRoot.ExpandAll();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根據年級更新班級表,同時考量到關鍵字搜尋
        /// </summary>
        private void GradeYear(string idWhom)
        {
            int Total = 0;

            //根據分課的年級進行分類
            SortedDictionary<string, List<string>> GradeYearWhoms = new SortedDictionary<string, List<string>>();

            foreach (Class vWhom in schLocal.Classes)
            {
                //取得年級
                string GradeYear = vWhom.GradeYear;

                //若年級名稱不在字典中則新增
                if (!GradeYearWhoms.ContainsKey(GradeYear))
                    GradeYearWhoms.Add(GradeYear, new List<string>());

                if (IsAddWhom(vWhom.ClassID))
                    if (!GradeYearWhoms[GradeYear].Contains(vWhom.ClassID))
                        GradeYearWhoms[GradeYear].Add(vWhom.ClassID);
            }

            nodeTree.Nodes.Clear();

            Node nodeRoot = new Node("所有年級");
            nodeRoot.TagString = "所有年級";
            Node nodeNull = new Node("無班級");
            nodeNull.TagString = "無";

            nodeTree.Nodes.Add(nodeRoot);
            nodeTree.Nodes.Add(nodeNull);

            foreach (string GradeYear in GradeYearWhoms.Keys)
            {
                Node nodeGradeYear = new Node(GradeYear);
                List<string> Names = new List<string>();

                foreach (string WhomID in GradeYearWhoms[GradeYear])
                {
                    if (schLocal.Classes.Exists(WhomID))
                    {
                        Class whomPaint = schLocal.Classes[WhomID];

                        if (whomPaint.TotalHour > 0)
                        {
                            int UnAllocHour = whomPaint.TotalHour - whomPaint.AllocHour;

                            Node nodeWho = new Node(whomPaint.Name + "(" + UnAllocHour + "/" + whomPaint.TotalHour + ")");
                            nodeWho.TagString = whomPaint.ClassID;
                            nodeGradeYear.Nodes.Add(nodeWho);
                            Names.Add(whomPaint.ClassID);
                            Total++;
                        }
                    }
                }

                if (nodeGradeYear.Nodes.Count > 0)
                {
                    nodeGradeYear.Text = nodeGradeYear.Text + "(" + nodeGradeYear.Nodes.Count + ")";
                    nodeGradeYear.TagString = string.Join(";", Names.ToArray());
                    nodeRoot.Nodes.Add(nodeGradeYear);
                    nodeRoot.Expand();
                }
            }

            nodeRoot.Text = nodeRoot.Text + "(" + schLocal.Classes.HasTotalHourCount + ")";
            nodeRoot.ExpandAll();
        }