public VolunteerStudentForm(社團志願分配的Row VolRow, Setup_ByV By_V) { InitializeComponent(); _VolRow = VolRow; _By_V = By_V; }
private void ReViewStudentDetail(DataGridViewRow dataGridViewRow) { 社團志願分配的Row VolRow = (社團志願分配的Row)dataGridViewRow.DataBoundItem; VolunteerStudentForm f = new VolunteerStudentForm(VolRow, By_V); f.ShowDialog(); }
/// <summary> /// 排序 /// </summary> private int SortClass(社團志願分配的Row row1, 社團志願分配的Row row2) { string Grat1 = row1._GradeYear.PadLeft(1, '0'); Grat1 += row1._Class_display_order.PadLeft(3, '9'); Grat1 += row1._Class.PadLeft(10, '0'); string Grat2 = row2._GradeYear.PadLeft(1, '0'); Grat2 += row2._Class_display_order.PadLeft(3, '9'); Grat2 += row2._Class.PadLeft(10, '0'); return(Grat1.CompareTo(Grat2)); }
/// <summary> /// 取得學生基本資料與建置RowData /// </summary> private Dictionary <string, 社團志願分配的Row> GetVolClassRow(List <一名學生> StudentList) { Dictionary <string, 社團志願分配的Row> VolClassRowDic = new Dictionary <string, 社團志願分配的Row>(); foreach (一名學生 each in StudentList) { if (VolClassRowDic.ContainsKey(each.class_id)) { if (!VolClassRowDic[each.class_id]._StudentDic.ContainsKey(each.student_id)) { VolClassRowDic[each.class_id]._StudentDic.Add(each.student_id, each); } } else { 社團志願分配的Row classRow = new 社團志願分配的Row(); classRow._Class = each.class_name; classRow._GradeYear = each.grade_year; classRow._Class_display_order = each.display_order; classRow._teacher = each.teacher_name; if (!string.IsNullOrEmpty(each.nickname)) { classRow._teacher += "(" + each.nickname + ")"; } if (!classRow._StudentDic.ContainsKey(each.student_id)) { classRow._StudentDic.Add(each.student_id, each); } VolClassRowDic.Add(each.class_id, classRow); } } return(VolClassRowDic); }
void BGW_Save_DoWork(object sender, DoWorkEventArgs e) { BGW_Save.ReportProgress(0, "志願分配作業..."); //已有社團參與者略過或覆蓋 DeleteList = new List <SCJoin>(); InsertList1 = new List <SCJoin>(); InsertList2 = new List <SCJoin>(); //增加退社相關作業(2015/9/14) if (By_V.已有社團記錄時) //有社團記錄時,不進行退社(True覆蓋,False略過) { //進行已選學生的退社處理 foreach (DataGridViewRow row in dataGridViewX1.SelectedRows) { if (row.DataBoundItem is 社團志願分配的Row) { 社團志願分配的Row 班級 = (社團志願分配的Row)row.DataBoundItem; foreach (一名學生 一學生 in 班級._StudentDic.Values) { if (SCJLockDic.ContainsKey(一學生.student_id)) { SCJoin scj_del = SCJLockDic[一學生.student_id]; if (!scj_del.Lock) //不是鎖定的學生 { scj_del.Deleted = true; scj_del.Save(); //設定社團人數 一個社團檢查 一社團 = CLUBCheckDic[scj_del.RefClubID]; SetClubGradeYearCount(一社團, 一學生, false); } } } } } } #region 社團參與依據 //用條件進行排序的物件 List <學生選社亂數檔> RunList = new List <學生選社亂數檔>(); if (By_V.社團分配優先序) { #region 使用獎懲依據 BGW_Save.ReportProgress(10, "取得獎懲資料..."); 獎懲換算機制 m = new 獎懲換算機制(); BGW_Save.ReportProgress(20, "取得資料模型..."); Dictionary <string, int> StudentMeritDic = m.GetMerit(StudentList); BGW_Save.ReportProgress(20, "取得資料模型..."); List <社團志願分配的Row> IsRowList = new List <社團志願分配的Row>(); foreach (DataGridViewRow row in dataGridViewX1.SelectedRows) { if (row.DataBoundItem is 社團志願分配的Row) { IsRowList.Add((社團志願分配的Row)row.DataBoundItem); } } foreach (社團志願分配的Row each in IsRowList) { foreach (VolunteerRecord vol in each._Volunteer.Values) { if (StudentMeritDic.ContainsKey(vol.RefStudentID)) { 學生選社亂數檔 rr = new 學生選社亂數檔(vol, StudentMeritDic[vol.RefStudentID]); RunList.Add(rr); } } } #endregion } else { #region 使用亂數依據 BGW_Save.ReportProgress(10, "使用亂數依據..."); Random _r = new Random(); BGW_Save.ReportProgress(20, "取得資料模型..."); List <社團志願分配的Row> IsRowList = new List <社團志願分配的Row>(); foreach (DataGridViewRow row in dataGridViewX1.SelectedRows) { if (row.DataBoundItem is 社團志願分配的Row) { IsRowList.Add((社團志願分配的Row)row.DataBoundItem); } } foreach (社團志願分配的Row each in IsRowList) { foreach (VolunteerRecord vol in each._Volunteer.Values) { 學生選社亂數檔 rr = new 學生選社亂數檔(vol, _r.Next(99999)); RunList.Add(rr); } } #endregion } BGW_Save.ReportProgress(30, "資料排序作業..."); RunList.Sort(SortRandom); int _index = 1; foreach (學生選社亂數檔 rr in RunList) { rr._Index = _index; _index++; } #endregion //2016/9/7 - 略過功能不需要再一次進行人數統計 //if (!By_V.已有社團記錄時) //True為覆蓋 //{ // //要略過的話 // //要先進行資料的檢查 // SetCount(RunList); //} #region 開始分配學生社團狀態(相關狀態與學生都應該已處理) if (By_V.已有社團記錄時) { sb_Log.AppendLine("選社設定:覆蓋"); } else { sb_Log.AppendLine("選社設定:略過"); } sb_Log.AppendLine("每名學生志願數:" + By_V.學生選填志願數.ToString()); //取志願 BGW_Save.ReportProgress(45, "志願選填作業..."); for (int x = 1; x <= By_V.學生選填志願數; x++) { BGW_Save.ReportProgress(65, string.Format("志願選填作業...{0}", x)); sb_Log.AppendLine(""); sb_Log.AppendLine(string.Format("═══開始進行第「{0}」志願分配═══", x.ToString())); sb_Log.AppendLine(""); Judge(RunList, x); } #endregion //新增資料 if (By_V.已有社團記錄時) //覆蓋 { BGW_Save.ReportProgress(77, "清除學生選社..."); //刪除學生社團參與記錄 tool._A.DeletedValues(DeleteList); //新增未選社之學生 BGW_Save.ReportProgress(84, "新增選社記錄..1"); tool._A.InsertValues(InsertList1); //新增已選社之學生 BGW_Save.ReportProgress(88, "新增選社記錄..2"); tool._A.InsertValues(InsertList2); } else //略過資料 { BGW_Save.ReportProgress(85, "新增選社記錄..1"); //只新增未選社之學生 tool._A.InsertValues(InsertList1); } BGW_Save.ReportProgress(100, "選社分配完成!!"); ApplicationLog.Log("社團志願序模組", "志願分配", sb_Log.ToString()); VolunteerLog logForm = new VolunteerLog(sb_Log.ToString()); logForm.ShowDialog(); }