/// <summary>
        /// 開始進行志願序資料整合
        /// </summary>
        public void 開始進行志願序資料整合()
        {
            //整理志願序資料
            foreach (OnlineVolunteer each in VolunteerList)
            {
                if (StudentDic.ContainsKey(each.RefStudentId))
                {
                    //學生
                    OnlineStudent OnlineStud = StudentDic[each.RefStudentId];

                    if (!string.IsNullOrEmpty(each.Content))
                    {
                        XmlElement xml        = DSXmlHelper.LoadXml(each.Content);
                        int        ClubNumber = 1;
                        foreach (XmlElement node in xml.SelectNodes("Club"))
                        {
                            if (node.GetAttribute("Index") == ClubNumber.ToString())
                            {
                                string clubID = node.GetAttribute("Ref_Club_ID");
                                if (ClubDic.ContainsKey(clubID))
                                {
                                    //社團
                                    OnlineClub OnlineClub = ClubDic[clubID];
                                    if (!OnlineStud.VolunteerList.ContainsKey(ClubNumber))
                                    {
                                        OnlineStud.VolunteerList.Add(ClubNumber, OnlineClub);
                                    }
                                }
                            }
                            ClubNumber++;
                        }
                    }
                }
            }
        }
コード例 #2
0
        void BGW_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            dataGridViewX1.Enabled = true;
            this.Text = "學生選填明細";

            if (!e.Cancelled)
            {
                if (e.Error == null)
                {
                    SetColumn();

                    #region 建立Row

                    //取得該班級的學生基本資料
                    List <一名學生> list = _VolRow._StudentDic.Values.ToList();
                    //依座號排序
                    list.Sort(SortMergeList);

                    foreach (一名學生 each in list)
                    {
                        DataGridViewRow row = new DataGridViewRow();
                        row.CreateCells(dataGridViewX1);
                        row.Cells[0].Value = each.seat_no.HasValue ? each.seat_no.Value.ToString() : ""; //座號
                        row.Cells[1].Value = each.student_name;                                          //姓名
                        row.Cells[2].Value = each.gender;                                                //姓名


                        if (_VolRow._Volunteer.ContainsKey(each.student_id))
                        {
                            #region 必須有填志願才會被填入社團資料
                            //學生基本資料
                            VolunteerRecord obj = _VolRow._Volunteer[each.student_id];

                            //ClubDic社團是從選社志願內的資料
                            //因此它為0時,就表示多數數資料都沒有填志願
                            if (ClubDic.Count != 0)
                            {
                                //取得單一學生志願序選填狀況
                                if (!string.IsNullOrEmpty(obj.Content))
                                {
                                    XmlElement Element = XmlHelper.LoadXml(obj.Content);
                                    foreach (XmlElement xml in Element.SelectNodes("Club"))
                                    {
                                        //所選填的必須只有設定之數量
                                        int ClubIndex = 0;
                                        int.TryParse(xml.GetAttribute("Index"), out ClubIndex);
                                        if (ClubIndex <= _By_V.學生選填志願數 && ClubIndex != 0)
                                        {
                                            string clubID = xml.GetAttribute("Ref_Club_ID");
                                            //是否包含此社團
                                            if (ClubDic.ContainsKey(clubID))
                                            {
                                                CLUBRecord cr = ClubDic[clubID];
                                                //+3是因為由第 3 Column起始
                                                row.Cells[ClubIndex + 2].Value    = cr.ClubName;
                                                row.Cells[ClubIndex + 2].ReadOnly = true;
                                            }
                                        }
                                    }
                                }
                            }
                            #endregion
                        }

                        if (_VolRow._SCJDic.ContainsKey(each.student_id))
                        {
                            #region 當此學生有社團參與記錄時

                            SCJoin scj = _VolRow._SCJDic[each.student_id];
                            if (_VolRow._ClubDic.ContainsKey(scj.RefClubID))
                            {
                                CLUBRecord club = _VolRow._ClubDic[scj.RefClubID];
                                row.Cells[1].Value += "(" + club.ClubName + ")";

                                if (scj.Lock)
                                {
                                    foreach (DataGridViewCell cell in row.Cells)
                                    {
                                        cell.Style.BackColor = Color.GreenYellow;
                                    }
                                }
                                else
                                {
                                    foreach (DataGridViewCell cell in row.Cells)
                                    {
                                        cell.Style.BackColor = Color.Yellow;
                                    }
                                }
                            }

                            #endregion
                        }
                        else
                        {
                            StudentIDList.Add(each.student_id);
                        }

                        dataGridViewX1.Rows.Add(row);
                    }


                    #endregion
                }
                else
                {
                    MsgBox.Show("已發生錯誤!!\n" + e.Error.Message);
                }
            }
            else
            {
                MsgBox.Show("資料取得動作已取消");
            }
        }