public FactsObj_big(CLUBRecord cr) { Club = cr; StudentList_1 = new List <StudentRecord>(); StudentList_2 = new List <StudentRecord>(); StudentList_3 = new List <StudentRecord>(); }
private void NowSetRow(DataGridViewRow row, CLUBRecord club, StudRecord stud, string v) { row.Cells[colSelectClub.Index].Value = "" + club.ClubName; row.Cells[colSelectClub.Index].Tag = club; club.NewCount++; //新加入多少人 if (ClubAddDic.ContainsKey(club.UID)) { ClubAddDic[club.UID].Add(stud.id); } if (v == "1") { club.NewGrade1Limit++; } else if (v == "2") { club.NewGrade2Limit++; } else if (v == "3") { club.NewGrade3Limit++; } }
private void btnSave_Click(object sender, EventArgs e) { //資料是否輸入檢查 if (!CheckDataIsError()) { MsgBox.Show("請輸入必填欄位!!"); return; } if (!CheckClubName()) { MsgBox.Show("社團名稱重覆!!"); return; } CLUBRecord club = GetClub(); BackgroundWorker BGW_Save = new BackgroundWorker(); BGW_Save.DoWork += new DoWorkEventHandler(BGW_Save_DoWork); BGW_Save.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BGW_Save_RunWorkerCompleted); //開始儲存資料 this.Text = "新增社團(儲存中...)"; SetFrom = false; BGW_Save.RunWorkerAsync(new List <CLUBRecord>() { club }); }
/// <summary> /// 當按鈕被按下 /// </summary> void item1_Click(object sender, EventArgs e) { ButtonX item1 = (ButtonX)sender; CLUBRecord cr = (CLUBRecord)item1.Tag; //int count = 0; //foreach (DataGridViewRow row in dataGridViewX1.SelectedRows) //{ // StudentJoinRow scjRow = (StudentJoinRow)row.DataBoundItem; // if (scjRow.SCJoinList.Count > 1) // { // count++; // } //} //if (count != 0) // MsgBox.Show("有重覆參與社團之學生「" + count + "」名\n無法設定為「" + cr.ClubName + "」"); foreach (DataGridViewRow row in dataGridViewX1.SelectedRows) { StudentJoinRow scjRow = (StudentJoinRow)row.DataBoundItem; if (scjRow.SCJoinList.Count > 1) { continue; } scjRow.ChangeCLUB(cr); ((DataGridViewColorBallTextCell)row.Cells[7]).Color = _ClubColorList[((CLUBRecord)item1.Tag).UID]; ((DataGridViewColorBallTextCell)row.Cells[7]).Value = _ClubNameList[((CLUBRecord)item1.Tag).UID]; } CountStudents(); }
private void btnSave_Click(object sender, EventArgs e) { //將指定好的學生 //建立社團參與記錄 //並加入該社團內 btnSave.Enabled = false; List <SCJoin> SCJoinList = new List <SCJoin>(); sb_log = new StringBuilder(); sb_log.AppendLine(string.Format("「{0}」學年度 第「{1}」學期 未選社團學生分發:", seting_school_year, seting_school_semester)); foreach (DataGridViewRow row in dataGridViewX1.Rows) { if (row.Cells[colSelectClub.Index].Tag != null) { StudRecord sr = (StudRecord)row.Tag; CLUBRecord cr = (CLUBRecord)row.Cells[colSelectClub.Index].Tag; SCJoin sc = new SCJoin(); sc.RefClubID = cr.UID; sc.RefStudentID = sr.id; SCJoinList.Add(sc); sb_log.AppendLine(string.Format("班級「{0}」學生「{1}」社團指定為「{2}」", sr.class_name, sr.name, cr.ClubName)); } } BGWSave.RunWorkerAsync(SCJoinList); }
/// <summary> /// 設定課程Button /// </summary> private ButtonX SetBotton(CLUBRecord cr) { //顏色每7個社團,顏色重置 if (ButtonCount > 6) { ButtonCount = 0; } ButtonX item1 = new ButtonX(); item1.FocusCuesEnabled = false; item1.Style = eDotNetBarStyle.Office2007; item1.ColorTable = eButtonColor.Flat;// eButtonColor.Office2007WithBackground; //item1.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.ImageAndText; //item1.ImagePaddingHorizontal = 8; item1.AutoSize = true; item1.Shape = new DevComponents.DotNetBar.RoundRectangleShapeDescriptor(15); item1.TextAlignment = eButtonTextAlignment.Left; item1.Size = new Size(110, 23); item1.Text = cr.ClubName; item1.Image = GetColorBallImage(colors[ButtonCount]); _ClubNameList.Add("" + cr.UID, cr.ClubName); _ClubColorList.Add("" + cr.UID, colors[ButtonCount++]); item1.Tag = cr; item1.Click += new EventHandler(item1_Click); return(item1); }
public void SetClub(IRowStream Row, CLUBRecord club) { club.ClubNumber = Row.GetValue("代碼"); club.Location = Row.GetValue("場地"); club.ClubCategory = Row.GetValue("類型"); club.Level = Row.GetValue("評等"); club.RefTeacherID = checkTeacherName("" + Row.GetValue("老師1")); club.RefTeacherID2 = checkTeacherName("" + Row.GetValue("老師2")); club.RefTeacherID3 = checkTeacherName("" + Row.GetValue("老師3")); club.About = Row.GetValue("簡介"); club.GenderRestrict = Row.GetValue("限制:性別"); club.DeptRestrict = GetDeptXML(Row.GetValue("限制:科別")); int x = 0; if (int.TryParse("" + Row.GetValue("限制:一年級人數"), out x)) { club.Grade1Limit = x; } if (int.TryParse("" + Row.GetValue("限制:二年級人數"), out x)) { club.Grade2Limit = x; } if (int.TryParse("" + Row.GetValue("限制:三年級人數"), out x)) { club.Grade3Limit = x; } if (int.TryParse("" + Row.GetValue("限制:人數上限"), out x)) { club.Limit = x; } }
/// <summary> /// 調整參與社團為newCLUB /// </summary> /// <param name="newCLUB"></param> public void ChangeCLUB(CLUBRecord newCLUB) { AdjustClubRecord = newCLUB; if (PropertyChanged != null) { PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs("AdjustClubName")); } }
void btnItem_Click(object sender, EventArgs e) { if (itmPnlTimeName.SelectedItems.Count == 1) { List <CLUBRecord> clubList = new List <CLUBRecord>(); //取得目前所選擇的Button ButtonItem Buttonitem = itmPnlTimeName.SelectedItems[0] as ButtonItem; //取得課程Record CLUBRecord club = (CLUBRecord)Buttonitem.Tag; clubList.Add(club); //該課程目前有多少選課學生 int count = 0; if (ScjDic.ContainsKey(club.UID)) { count = ScjDic[club.UID].Count; } // foreach (DataGridViewRow row in dataGridViewX1.SelectedRows) { //先清除原本的 if (row.Cells[colSelectClub.Index].Tag != null) { CLUBRecord reClub = (CLUBRecord)row.Cells[colSelectClub.Index].Tag; StudRecord stud = (StudRecord)row.Tag; if (ClubAddDic.ContainsKey(reClub.UID)) { ClubAddDic[reClub.UID].Remove(stud.id); } if (!clubList.Contains(reClub)) { clubList.Add(reClub); } } //填入學生所選的社團資料 row.Cells[colSelectClub.Index].Value = "" + club.ClubName; row.Cells[colSelectClub.Index].Tag = club; //統計,此按鈕造成新增多少學生(不重複) if (ClubAddDic.ContainsKey(club.UID)) { //不包含此學生則加入 StudRecord stud = (StudRecord)row.Tag; if (!ClubAddDic[club.UID].Contains(stud.id)) { ClubAddDic[club.UID].Add(stud.id); } } } RefreshButtonItem(clubList); } }
/// <summary> /// 重新處理畫面顯示 /// </summary> private void RefreshButtonItem(List <CLUBRecord> ClubList) { foreach (CLUBRecord club in ClubList) { foreach (ButtonItem Buttonitem in itmPnlTimeName.Items) { CLUBRecord record = (CLUBRecord)Buttonitem.Tag; if (club.UID == record.UID) { //使用者若使用過按鈕分配,就會儲存在 ClubAddDic if (ClubAddDic.ContainsKey(record.UID)) { int count = 0; if (ScjDic.ContainsKey(record.UID)) { count += ScjDic[record.UID].Count; } count += ClubAddDic[record.UID].Count; if (record.Limit.HasValue) { if (count == record.Limit.Value) { Buttonitem.Text = record.ClubName + string.Format("(人數:{0}/{1}) +{2} 額滿", count, record.Limit.Value, ClubAddDic[record.UID].Count); Buttonitem.ForeColor = Color.Blue; } else if (count > record.Limit.Value) { Buttonitem.Text = record.ClubName + string.Format("(人數:{0}/{1}) +{2} 超額", count, record.Limit.Value, ClubAddDic[record.UID].Count); Buttonitem.ForeColor = Color.Red; } else if (ClubAddDic[record.UID].Count == 0) { Buttonitem.Text = record.ClubName + string.Format("(人數:{0}/{1})", count, record.Limit.Value); Buttonitem.ForeColor = Color.Blue; } else { Buttonitem.Text = record.ClubName + string.Format("(人數:{0}/{1}) +{2}", count, record.Limit.Value, ClubAddDic[record.UID].Count); Buttonitem.ForeColor = Color.Blue; } } else { Buttonitem.Text = record.ClubName + string.Format("(人數:{0}/{1}) +{2}", count, "無限制", ClubAddDic[record.UID].Count); Buttonitem.ForeColor = Color.Blue; } } } } } itmPnlTimeName.ResumeLayout(); itmPnlTimeName.Refresh(); }
public CopyClubRecord(CLUBRecord club) { _Club = club; //建立一個社團 / 社團學生的物件 //並且傳入新社團的相關資料 //本物件的功能 //就是傳入新社團的ID //而本物件依據ID來建立學生記錄 }
/// <summary> /// 排序社團依據:代碼/名稱排序 /// </summary> static private int SortClub(CLUBRecord cr1, CLUBRecord cr2) { string Comp1 = cr1.ClubNumber.PadLeft(5, '0'); Comp1 += cr1.ClubName.PadLeft(20, '0'); string Comp2 = cr2.ClubNumber.PadLeft(5, '0'); Comp2 += cr2.ClubName.PadLeft(20, '0'); return(Comp1.CompareTo(Comp2)); }
public 一個社團檢查(CLUBRecord ClubObj) { _ClubObj = ClubObj; _SCJDic = new Dictionary <string, SCJoin>(); _Now_ClubStudentCount = 0; _Now_GradeYear1 = 0; _Now_GradeYear2 = 0; _Now_GradeYear3 = 0; DeptList = new List <string>(); //選社之科系限制 GetDept(); }
void BGW_DoWork(object sender, DoWorkEventArgs e) { //取得社團資料 List <CLUBRecord> ClubPrimaryList = _AccessHelper.Select <CLUBRecord>(string.Format("UID = '{0}'", this.PrimaryKey)); if (ClubPrimaryList.Count != 1) { //如果取得2門以上 或 沒取得社團時 e.Cancel = true; return; } ClubPrimary = ClubPrimaryList[0]; }
private void 清除指定社團ToolStripMenuItem_Click(object sender, EventArgs e) { List <CLUBRecord> clublist = new List <CLUBRecord>(); foreach (DataGridViewRow row in dataGridViewX1.SelectedRows) { //取得課程Record CLUBRecord club = (CLUBRecord)row.Cells[colSelectClub.Index].Tag; clublist.Add(club); //該課程目前有多少選課學生 int count = 0; if (ScjDic.ContainsKey(club.UID)) { count = ScjDic[club.UID].Count; } row.Cells[colSelectClub.Index].Value = null; row.Cells[colSelectClub.Index].Tag = null; //統計,此按鈕造成新增多少學生(不重複) if (ClubAddDic.ContainsKey(club.UID)) { //包含此學生,則移除學生 StudRecord stud = (StudRecord)row.Tag; if (ClubAddDic[club.UID].Contains(stud.id)) { ClubAddDic[club.UID].Remove(stud.id); } club.NewCount--; if (stud.grade_year == "1" || stud.grade_year == "7") { club.NewGrade1Limit--; } else if (stud.grade_year == "2" || stud.grade_year == "8") { club.NewGrade2Limit--; } else if (stud.grade_year == "3" || stud.grade_year == "9") { club.NewGrade3Limit--; } } } RefreshButtonItem(clublist); }
void BGW_DoWork(object sender, DoWorkEventArgs e) { List <CLUBRecord> ClubPrimaryList = tool._A.Select <CLUBRecord>(string.Format("UID = '{0}'", this.PrimaryKey)); if (ClubPrimaryList.Count != 1) { //如果取得2門以上 或 沒取得社團時 e.Cancel = true; return; } _CLUBRecord = ClubPrimaryList[0]; //本社團的學生參與記錄 scMAG = new ScJoinMag(this.PrimaryKey); ClassDic = tool.GetClassDic(scMAG.SCJoinStudent_LIst); }
/// <summary> /// 取得老師名稱 /// </summary> private string GetTeacherName(CLUBRecord cr) { string name = ""; //老師1 if (!string.IsNullOrEmpty(cr.RefTeacherID)) { TeacherRecord tr = GetPoint.TeacherDic[cr.RefTeacherID]; if (string.IsNullOrEmpty(tr.Nickname)) { name += tr.Name; } else { name += tr.Name + "(" + tr.Nickname + ")"; } } //老師2 if (!string.IsNullOrEmpty(cr.RefTeacherID2)) { TeacherRecord tr = GetPoint.TeacherDic[cr.RefTeacherID2]; if (string.IsNullOrEmpty(tr.Nickname)) { name += "/" + tr.Name; } else { name += "/" + tr.Name + "(" + tr.Nickname + ")"; } } //老師3 if (!string.IsNullOrEmpty(cr.RefTeacherID3)) { TeacherRecord tr = GetPoint.TeacherDic[cr.RefTeacherID3]; if (string.IsNullOrEmpty(tr.Nickname)) { name += "/" + tr.Name; } else { name += "/" + tr.Name + "(" + tr.Nickname + ")"; } } return(name); }
void BGW_DoWork(object sender, DoWorkEventArgs e) { //取得社團資料 List <CLUBRecord> ClubPrimaryList = _AccessHelper.Select <CLUBRecord>(string.Format("UID = '{0}'", this.PrimaryKey)); if (ClubPrimaryList.Count != 1) { //如果取得2門以上 或 沒取得社團時 e.Cancel = true; return; } ClubPrimary = ClubPrimaryList[0]; Log_ClubPrimary = ClubPrimary.CopyExtension(); //取得科別資料 deptList = tool.GetQueryDeptList(); }
public void RunInsert(SCJoin scj) { if (tool._StudentDic.ContainsKey(scj.RefStudentID)) { //社團 CLUBRecord cr = tool._ClubDic[scj.RefClubID]; //學生 StudentRecord sr = tool._StudentDic[scj.RefStudentID]; ResultScoreRecord rsr = new ResultScoreRecord(); rsr.SchoolYear = cr.SchoolYear; rsr.Semester = cr.Semester; rsr.RefClubID = cr.UID; //社團ID rsr.RefStudentID = sr.ID; //學生ID rsr.RefSCJoinID = scj.UID; //參與記錄ID rsr.ClubName = cr.ClubName; rsr.ClubLevel = cr.Level; //社團評等 if (!string.IsNullOrEmpty(scj.Score)) { rsr.ResultScore = tool.GetDecimalValue(scj); //成績 } #region 幹部 if (CadreDic.ContainsKey(cr.UID)) { if (CadreDic[cr.UID]._Cadre1.ContainsKey(sr.ID)) { rsr.CadreName = CadreDic[cr.UID]._Cadre1[sr.ID]; } else { rsr.CadreName = ""; } } #endregion InsertScoreList.Add(rsr); } }
public 社團幹部obj(CLUBRecord Club) { _Club = Club; _Cadre1 = new Dictionary <string, string>(); if (!string.IsNullOrEmpty(_Club.President)) { _Cadre1.Add(_Club.President, "社長"); } if (!string.IsNullOrEmpty(_Club.VicePresident)) { if (_Cadre1.ContainsKey(_Club.VicePresident)) { _Cadre1[_Club.VicePresident] += ",副社長"; } else { _Cadre1.Add(_Club.VicePresident, "副社長"); } } }
private int SortClub(CLUBRecord cr1, CLUBRecord cr2) { return(cr1.ClubCategory.CompareTo(cr2.ClubCategory)); }
void BGW_DoWork(object sender, DoWorkEventArgs e) { ReportConfiguration ConfigurationInCadre = new ReportConfiguration(ClassPrint_Config_1); Aspose.Words.Document Template; if (ConfigurationInCadre.Template == null) { //如果範本為空,則建立一個預設範本 ReportConfiguration ConfigurationInCadre_1 = new ReportConfiguration(ClassPrint_Config_1); ConfigurationInCadre_1.Template = new ReportTemplate(Properties.Resources.社團點名單_套表列印1, TemplateType.docx); //ConfigurationInCadre_1.Template = new Campus.Report.ReportTemplate(Properties.Resources.社團點名表_合併欄位總表, Campus.Report.TemplateType.Word); //Jean Template = new Document(ConfigurationInCadre_1.Template.GetStream()); } else { //如果已有範本,則取得樣板 Template = new Document(ConfigurationInCadre.Template.GetStream()); } string[] fieldNames = Template.MailMerge.GetFieldNames(); foreach (var item in fieldNames) { if (item.Contains("姓名")) { 學生多少個++; } } SCJoinDataLoad crM = new SCJoinDataLoad(); #region 日期 List <string> config = new List <string>(); XmlElement day = (XmlElement)e.Argument; if (day == null) { MsgBox.Show("第一次使用報表請先進行[日期設定]"); return; } else { config.Clear(); foreach (XmlElement xml in day.SelectNodes("item")) { config.Add(xml.InnerText); } } #endregion DataTable table = new DataTable(); table.Columns.Add("學校名稱"); table.Columns.Add("社團名稱"); table.Columns.Add("學年度"); table.Columns.Add("學期"); table.Columns.Add("上課地點"); table.Columns.Add("社團類型"); table.Columns.Add("社團代碼"); //2016/9/22 - 新增 table.Columns.Add("指導老師1"); table.Columns.Add("指導老師2"); table.Columns.Add("指導老師3"); table.Columns.Add("列印日期"); table.Columns.Add("上課開始"); table.Columns.Add("上課結束"); table.Columns.Add("人數"); for (int x = 1; x <= 日期多少天; x++) { table.Columns.Add(string.Format("日期_{0}", x)); } for (int x = 1; x <= 學生多少個; x++) { table.Columns.Add(string.Format("班級_{0}", x)); } for (int x = 1; x <= 學生多少個; x++) { table.Columns.Add(string.Format("座號_{0}", x)); } for (int x = 1; x <= 學生多少個; x++) { table.Columns.Add(string.Format("姓名_{0}", x)); } for (int x = 1; x <= 學生多少個; x++) { table.Columns.Add(string.Format("學號_{0}", x)); } for (int x = 1; x <= 學生多少個; x++) { table.Columns.Add(string.Format("性別_{0}", x)); } foreach (string each in crM.CLUBRecordDic.Keys) { //社團資料 CLUBRecord cr = crM.CLUBRecordDic[each]; #region row 各種基本資料 DataRow row = table.NewRow(); row["學校名稱"] = K12.Data.School.ChineseName; row["社團名稱"] = cr.ClubName; row["學年度"] = cr.SchoolYear; row["學期"] = cr.Semester; row["上課地點"] = cr.Location; row["社團類型"] = cr.ClubCategory; row["社團代碼"] = cr.ClubNumber; if (crM.TeacherDic.ContainsKey(cr.RefTeacherID)) { row["指導老師1"] = crM.TeacherDic[cr.RefTeacherID].Name; } if (crM.TeacherDic.ContainsKey(cr.RefTeacherID2)) { row["指導老師2"] = crM.TeacherDic[cr.RefTeacherID2].Name; } if (crM.TeacherDic.ContainsKey(cr.RefTeacherID3)) { row["指導老師3"] = crM.TeacherDic[cr.RefTeacherID3].Name; } //row["外聘老師"] = ""; row["列印日期"] = DateTime.Today.ToShortDateString(); row["上課開始"] = config[0]; row["上課結束"] = config[config.Count - 1]; row["人數"] = crM.ClubByStudentList[each].Count; for (int x = 1; x <= config.Count; x++) { row[string.Format("日期_{0}", x)] = config[x - 1]; } #endregion int y = 1; foreach (StudentRecord obj in crM.ClubByStudentList[each]) { if (y <= 學生多少個) //限制畫面到100名學生 { row[string.Format("班級_{0}", y)] = obj.Class != null ? obj.Class.Name : ""; row[string.Format("座號_{0}", y)] = obj.SeatNo.HasValue ? obj.SeatNo.Value.ToString() : ""; row[string.Format("姓名_{0}", y)] = obj.Name; row[string.Format("學號_{0}", y)] = obj.StudentNumber; row[string.Format("性別_{0}", y)] = obj.Gender; y++; if (y == (學生多少個 + 1)) { y = 1; table.Rows.Add(row); row = table.NewRow(); #region row 各種基本資料 row["學校名稱"] = K12.Data.School.ChineseName; row["社團名稱"] = cr.ClubName; row["學年度"] = cr.SchoolYear; row["學期"] = cr.Semester; row["上課地點"] = cr.Location; row["社團類型"] = cr.ClubCategory; row["社團代碼"] = cr.ClubNumber; if (crM.TeacherDic.ContainsKey(cr.RefTeacherID)) { row["指導老師1"] = crM.TeacherDic[cr.RefTeacherID].Name; } if (crM.TeacherDic.ContainsKey(cr.RefTeacherID2)) { row["指導老師2"] = crM.TeacherDic[cr.RefTeacherID2].Name; } if (crM.TeacherDic.ContainsKey(cr.RefTeacherID3)) { row["指導老師3"] = crM.TeacherDic[cr.RefTeacherID3].Name; } //row["外聘老師"] = ""; row["列印日期"] = DateTime.Today.ToShortDateString(); row["上課開始"] = config[0]; row["上課結束"] = config[config.Count - 1]; row["人數"] = crM.ClubByStudentList[each].Count; for (int x = 1; x <= config.Count; x++) { row[string.Format("日期_{0}", x)] = config[x - 1]; } #endregion } } } table.Rows.Add(row); } Document PageOne = (Document)Template.Clone(true); PageOne.MailMerge.Execute(table); e.Result = PageOne; }
void BGW_DoWork(object sender, DoWorkEventArgs e) { //取得目前選擇課程 tool = new 成績取得器(); tool.GetSCJoinByClubIDList(ClubAdmin.Instance.SelectedSource); //取得運算比例 tool.SetWeightProportion(); //社團ID : 社團幹部obj CadreDic = new Dictionary <string, 社團幹部obj>(); #region 處理幹部記錄 foreach (CLUBRecord each in tool._ClubDic.Values) { if (!CadreDic.ContainsKey(each.UID)) { CadreDic.Add(each.UID, new 社團幹部obj(each)); } } string qr = string.Join("','", tool._ClubDic.Keys); List <CadresRecord> list = _AccessHelper.Select <CadresRecord>("ref_club_id in ('" + qr + "')"); foreach (CadresRecord cr in list) { if (!CadreDic[cr.RefClubID]._Cadre1.ContainsKey(cr.RefStudentID)) { CadreDic[cr.RefClubID]._Cadre1.Add(cr.RefStudentID, cr.CadreName); } else { CadreDic[cr.RefClubID]._Cadre1[cr.RefStudentID] += "," + cr.CadreName; } } #endregion #region 結算回學務幹部 List <string> dataList = new List <string>(); foreach (社團幹部obj cadre in CadreDic.Values) { string clubID = cadre._Club.UID; string clubName = cadre._Club.ClubName; int _schoolYear = cadre._Club.SchoolYear; int _semester = cadre._Club.Semester; if (cadre._Cadre1.Count == 0) //如果沒有社團幹部資料 { string data = string.Format(@" SELECT {0}::TEXT AS ref_student_id , '{1}'::TEXT AS schoolyear , '{2}'::TEXT AS semester , {3}::TEXT AS cadrename , '社團幹部'::TEXT AS referencetype , '{4}'::TEXT AS text -- 放社團名稱 ", "null", _schoolYear, _semester, "null", clubName); dataList.Add(data); } if (cadre._Cadre1.Count > 0) { foreach (string _cadre in cadre._Cadre1.Keys) // StudentID,CadreName { string studentID = _cadre; string cadreName = cadre._Cadre1[_cadre]; string data = string.Format(@" SELECT '{0}'::TEXT AS ref_student_id , '{1}'::TEXT AS schoolyear , '{2}'::TEXT AS semester , '{3}'::TEXT AS cadrename , '社團幹部'::TEXT AS referencetype , '{4}'::TEXT AS text -- 放社團名稱 ", studentID, _schoolYear, _semester, cadreName, clubName); dataList.Add(data); } } } string dataRow = string.Join(" UNION ALL", dataList); #region SQL // 判斷條件: 學生ID、學年度、學期、社團名稱 string sql = string.Format(@" WITH data_row AS( {0} ) ,run_update AS( UPDATE $behavior.thecadre SET cadrename = data_row.cadrename FROM data_row WHERE data_row.schoolyear = $behavior.thecadre .schoolyear AND data_row.semester = $behavior.thecadre .semester AND data_row.text = $behavior.thecadre .text AND data_row.referencetype = $behavior.thecadre .referencetype AND data_row.ref_student_id = $behavior.thecadre .studentid AND data_row.ref_student_id IS NOT NULL RETURNING $behavior.thecadre.* ) , run_insert AS( INSERT INTO $behavior.thecadre( studentid , schoolyear , semester , referencetype , cadrename , text ) SELECT data_row.ref_student_id , data_row.schoolyear , data_row.semester , data_row.referencetype , data_row.cadrename , data_row.text FROM data_row LEFT OUTER JOIN $behavior.thecadre AS cadre ON cadre.schoolyear = data_row.schoolyear AND cadre.semester = data_row.semester AND cadre.text = data_row.text AND cadre.referencetype = data_row.referencetype AND cadre.studentid = data_row.ref_student_id WHERE cadre.uid IS NULL AND data_row.ref_student_id IS NOT NULL RETURNING $behavior.thecadre.* ) ,delete_data AS( SELECT uid FROM( SELECT cadre.uid , cadre.studentid , row_number() OVER ( PARTITION BY cadre.studentid, cadre.text ) as row_index FROM data_row LEFT OUTER JOIN $behavior.thecadre AS cadre ON cadre.schoolyear = data_row.schoolyear AND cadre.semester = data_row.semester AND cadre.text = data_row.text AND cadre.referencetype = data_row.referencetype AND cadre.studentid = data_row.ref_student_id ) AS target_club WHERE target_club.studentid NOT IN (SELECT ref_student_id FROM data_row) OR row_index >= 2 ) DELETE FROM $behavior.thecadre WHERE uid IN (SELECT * FROM delete_data) ", dataRow); #endregion UpdateHelper up = new UpdateHelper(); up.Execute(sql); #endregion List <string> list_2 = new List <string>(); foreach (List <SCJoin> each in tool._SCJoinDic.Values) { foreach (SCJoin scj in each) { list_2.Add(scj.UID); } } //string uq = string.Join("','", list_2); string studentIDs = string.Join("','", tool._StudentDic.Keys); List <string> clubNameList = new List <string>(); string schoolYear = "", semester = ""; foreach (string clubID in tool._ClubDic.Keys) { string clubName = tool._ClubDic[clubID].ClubName; schoolYear = "" + tool._ClubDic[clubID].SchoolYear; semester = "" + tool._ClubDic[clubID].Semester; clubNameList.Add("'" + clubName + "'"); } string clubNames = string.Join(",", clubNameList); // 201/03/22 羿均 更新: 修改讀取學期結算成績的KEY值為 studentID、clubName、schoolYear、semester string condition = string.Format("ref_student_id IN ('{0}') AND school_year = {1} AND semester = {2} AND club_name IN ({3}) ", studentIDs, schoolYear, semester, clubNames); List <ResultScoreRecord> ResultList = _AccessHelper.Select <ResultScoreRecord>(condition); Dictionary <string, Dictionary <string, ResultScoreRecord> > ResultScoreDic = new Dictionary <string, Dictionary <string, ResultScoreRecord> >(); foreach (ResultScoreRecord rsr in ResultList) { //學生有社團成績 if (!ResultScoreDic.ContainsKey(rsr.RefStudentID)) { ResultScoreDic.Add(rsr.RefStudentID, new Dictionary <string, ResultScoreRecord>()); ResultScoreDic[rsr.RefStudentID].Add(rsr.RefClubID, rsr); } else { if (!ResultScoreDic[rsr.RefStudentID].ContainsKey(rsr.RefClubID)) { ResultScoreDic[rsr.RefStudentID].Add(rsr.RefClubID, rsr); } } } UPDateScoreList = new List <ResultScoreRecord>(); InsertScoreList = new List <ResultScoreRecord>(); //DeleteScoreList = new List<ResultScoreRecord>(); //_AccessHelper.DeletedValues(ResultList); foreach (List <SCJoin> scjList in tool._SCJoinDic.Values) { foreach (SCJoin scj in scjList) { //有學生紀錄 if (ResultScoreDic.ContainsKey(scj.RefStudentID)) { //相同社團 if (ResultScoreDic[scj.RefStudentID].ContainsKey(scj.RefClubID)) { #region 如果有原資料 if (tool._StudentDic.ContainsKey(scj.RefStudentID)) { //社團 CLUBRecord cr = tool._ClubDic[scj.RefClubID]; //學生 StudentRecord sr = tool._StudentDic[scj.RefStudentID]; //原有社團成績記錄 ResultScoreRecord update_rsr = ResultScoreDic[scj.RefStudentID][scj.RefClubID]; update_rsr.SchoolYear = cr.SchoolYear; update_rsr.Semester = cr.Semester; update_rsr.RefClubID = cr.UID; //社團ID update_rsr.RefStudentID = sr.ID; //學生ID update_rsr.RefSCJoinID = scj.UID; //參與記錄ID update_rsr.ClubName = cr.ClubName; update_rsr.ClubLevel = cr.Level; //社團評等 #region 成績 if (!string.IsNullOrEmpty(scj.Score)) { update_rsr.ResultScore = tool.GetDecimalValue(scj); //成績 } else { //當成績已被清空,結算內容也被清空 update_rsr.ResultScore = null; } #endregion #region 幹部 if (CadreDic.ContainsKey(cr.UID)) { if (CadreDic[cr.UID]._Cadre1.ContainsKey(sr.ID)) { update_rsr.CadreName = CadreDic[cr.UID]._Cadre1[sr.ID]; } else { update_rsr.CadreName = ""; } } else { update_rsr.CadreName = ""; } #endregion UPDateScoreList.Add(update_rsr); } } else { //學生有社團紀錄,但社團不相同 RunInsert(scj); } #endregion } else { //完全沒有成績記錄 RunInsert(scj); } } } try { _AccessHelper.InsertValues(InsertScoreList); _AccessHelper.UpdateValues(UPDateScoreList); } catch (Exception ex) { MsgBox.Show("新增社團成績發生錯誤!!\n" + ex.Message); e.Cancel = true; return; } #region 社團成績Log處理 StringBuilder _sbLog = new StringBuilder(); _sbLog.AppendLine("已進行社團結算:"); if (InsertScoreList.Count > 0) { _sbLog.AppendLine("共新增「" + InsertScoreList.Count + "」筆成績記錄"); } if (UPDateScoreList.Count > 0) { _sbLog.AppendLine("共更新「" + UPDateScoreList.Count + "」筆成績記錄"); } _sbLog.AppendLine(""); _sbLog.AppendLine("簡要明細如下:"); if (InsertScoreList.Count > 0) { foreach (ResultScoreRecord each in InsertScoreList) { if (tool._StudentDic.ContainsKey(each.RefStudentID)) { if (string.IsNullOrEmpty(each.CadreName)) { StudentRecord sr = tool._StudentDic[each.RefStudentID]; string de = each.ResultScore.HasValue ? each.ResultScore.Value.ToString() : ""; _sbLog.AppendLine(string.Format("學生新增「{0}」社團成績「{1}」", sr.Name, de)); } else { StudentRecord sr = tool._StudentDic[each.RefStudentID]; string de = each.ResultScore.HasValue ? each.ResultScore.Value.ToString() : ""; _sbLog.AppendLine(string.Format("學生新增「{0}」社團成績「{1}」幹部記錄「{2}」", sr.Name, de, each.CadreName)); } } } } if (UPDateScoreList.Count > 0) { _sbLog.AppendLine(""); foreach (ResultScoreRecord each in UPDateScoreList) { if (tool._StudentDic.ContainsKey(each.RefStudentID)) { if (string.IsNullOrEmpty(each.CadreName)) { StudentRecord sr = tool._StudentDic[each.RefStudentID]; string de = each.ResultScore.HasValue ? each.ResultScore.Value.ToString() : ""; _sbLog.AppendLine(string.Format("學生更新「{0}」社團成績「{1}」", sr.Name, de)); } else { StudentRecord sr = tool._StudentDic[each.RefStudentID]; string de = each.ResultScore.HasValue ? each.ResultScore.Value.ToString() : ""; _sbLog.AppendLine(string.Format("學生更新「{0}」社團成績「{1}」幹部記錄「{2}」", sr.Name, de, each.CadreName)); } } } } if (InsertScoreList.Count + UPDateScoreList.Count > 0) { try { FISCA.LogAgent.ApplicationLog.Log("社團", "成績結算", _sbLog.ToString()); } catch (Exception ex) { MsgBox.Show("上傳Log記錄發生錯誤!!\n" + ex.Message); e.Cancel = true; return; } } #endregion }
void BGW_DoWork(object sender, DoWorkEventArgs e) { //取得社團資料 List <CLUBRecord> ClubPrimaryList = _AccessHelper.Select <CLUBRecord>(string.Format("UID = '{0}'", this.PrimaryKey)); if (ClubPrimaryList.Count != 1) { //如果取得2門以上 或 沒取得社團時 e.Cancel = true; return; } ClubPrimary = ClubPrimaryList[0]; List <string> studList = new List <string>(); StringBuilder sb = new StringBuilder(); sb.Append(string.Format("ref_club_id='{0}'", ClubPrimary.UID)); List <SCJoin> SCJoin_LIst = _AccessHelper.Select <SCJoin>(sb.ToString()); foreach (SCJoin scj in SCJoin_LIst) { if (!studList.Contains(scj.RefStudentID)) { studList.Add(scj.RefStudentID); } } #region 社長 if (!string.IsNullOrEmpty(ClubPrimary.President)) { if (studList.Contains(ClubPrimary.President)) { StudPresident = Student.SelectByID(ClubPrimary.President); } else { StudPresident = null; } } else { StudPresident = null; } #endregion #region 副社長 if (!string.IsNullOrEmpty(ClubPrimary.VicePresident)) { if (studList.Contains(ClubPrimary.VicePresident)) { StudVicePresident = Student.SelectByID(ClubPrimary.VicePresident); } else { StudVicePresident = null; } } else { StudVicePresident = null; } #endregion //取得老師指定的幹部資料CadresRecord CadresList = _AccessHelper.Select <CadresRecord>(string.Format("ref_club_id = '{0}'", this.PrimaryKey)); //取得社團學生 //建立下拉式選單內的學生清單 StudentDic.Clear(); StudentIDIndexDic.Clear(); Log_StudentDic.Clear(); List <StudentRecord> _StudRecordlist = Student.SelectByIDs(studList); _StudRecordlist = SortClassIndex.K12Data_StudentRecord(_StudRecordlist); //studlist.Sort(); StudRecordlist = new List <CadreStudentObj>(); foreach (StudentRecord stud in _StudRecordlist) { CadreStudentObj obj = new CadreStudentObj(); StringBuilder sb1 = new StringBuilder(); sb1.Append(stud.Class != null ? stud.Class.Name : ""); sb1.Append(" "); sb1.Append(stud.SeatNo.HasValue ? stud.SeatNo.Value.ToString() : ""); sb1.Append(" "); sb1.Append(stud.Name); obj.TolName = sb1.ToString(); obj.stuent = stud; StudRecordlist.Add(obj); if (!StudentDic.ContainsKey(sb1.ToString())) { StudentDic.Add(sb1.ToString(), stud); } if (!Log_StudentDic.ContainsKey(stud.ID)) { Log_StudentDic.Add(stud.ID, stud); } } }
void BGW_DoWork(object sender, DoWorkEventArgs e) { //檢查目標學年期,是否有相同名稱之社團資料 //如果有則移除該社團 //並透過覆製功能進行新增動作 _SkipList = GetExistClub(); var copyClubList = new List <CLUBRecord>(); var copyClubIDList = new List <string>(); foreach (var item in _CopyList) { //如果是重覆社團則不處理 if (!_SkipList.Contains(item.ClubName)) { copyClubList.Add(item); copyClubIDList.Add(item.UID); } } if (copyClubList.Count == 0) { return; } int LogSchoolYear = 90; int LogSemester = 1; if (copyClubList.Count > 0) { LogSchoolYear = copyClubList[0].SchoolYear; LogSemester = copyClubList[0].Semester; } StringBuilder sb = new StringBuilder(); sb.AppendLine("已進行複製社團作業:"); sb.AppendLine(string.Format("由學年度「{0}」學期「{1}」複製至學年度「{2}」學期「{3}」", LogSchoolYear.ToString(), LogSemester.ToString(), _SchoolYear.ToString(), _Semester.ToString())); if (_CopyOtherStudent) { sb.AppendLine("(已勾選複製學生選項)"); } sb.AppendLine(""); sb.AppendLine("新學期社團清單如下:"); foreach (CLUBRecord each in copyClubList) { #region 複製社團基本資料 //如果是重覆社團則不處理 if (_SkipList.Contains(each.ClubName)) { continue; } CLUBRecord cr = new CLUBRecord(); cr.About = each.About; cr.ClubNumber = each.ClubNumber; cr.ClubCategory = each.ClubCategory; cr.ClubName = each.ClubName; cr.DeptRestrict = each.DeptRestrict; cr.GenderRestrict = each.GenderRestrict; cr.Grade1Limit = each.Grade1Limit; cr.Grade2Limit = each.Grade2Limit; cr.Grade3Limit = each.Grade3Limit; cr.Limit = each.Limit; cr.Location = each.Location; cr.Photo1 = each.Photo1; cr.Photo2 = each.Photo2; cr.RefTeacherID = each.RefTeacherID; cr.RefTeacherID2 = each.RefTeacherID2; cr.RefTeacherID3 = each.RefTeacherID3; cr.Level = each.Level; if (_CopyPresidentStudent) { //社長,副社長 cr.President = each.President; cr.VicePresident = each.VicePresident; } //使用者所設定之學年度學期 cr.SchoolYear = _SchoolYear; cr.Semester = _Semester; _NewInsertList.Add(cr); sb.AppendLine(string.Format("學年度「{0}」學期「{1}」社團名稱「{2}」", cr.SchoolYear.ToString(), cr.Semester.ToString(), cr.ClubName)); #endregion } //新增之社團ID List <string> newIDList = new List <string>(); try { newIDList = _AccessHelper.InsertValues(_NewInsertList); } catch (Exception ex) { SmartSchool.ErrorReporting.ReportingService.ReportException(ex); e.Cancel = true; return; } FISCA.LogAgent.ApplicationLog.Log("社團", "複製社團", sb.ToString()); if (_CopyOtherStudent || _CopyCadresStudent || _CopyPresidentStudent) { #region 複製社團學生 //取得社團 List <CLUBRecord> newClubRecord = _AccessHelper.Select <CLUBRecord>(string.Format("UID in('{0}')", string.Join("','", newIDList))); Dictionary <string, List <CadresRecord> > studentCadreDic = new Dictionary <string, List <CadresRecord> >(); Dictionary <string, List <SCJoin> > studentSCJDic = new Dictionary <string, List <SCJoin> >(); //取得原有社團之學生社團記錄 List <SCJoin> scjStudentList = _AccessHelper.Select <SCJoin>(string.Format("ref_club_id in ('{0}')", string.Join("','", copyClubIDList))); foreach (SCJoin each in scjStudentList) { if (!studentSCJDic.ContainsKey(each.RefClubID)) { studentSCJDic.Add(each.RefClubID, new List <SCJoin>()); } studentSCJDic[each.RefClubID].Add(each); } //取得原有社團之學生幹部記錄 List <CadresRecord> cadreStudentList = _AccessHelper.Select <CadresRecord>(string.Format("ref_club_id in ('{0}')", string.Join("','", copyClubIDList))); foreach (CadresRecord each in cadreStudentList) { if (!studentCadreDic.ContainsKey(each.RefClubID)) { studentCadreDic.Add(each.RefClubID, new List <CadresRecord>()); } studentCadreDic[each.RefClubID].Add(each); } _InsertSCJList = new List <SCJoin>(); List <CadresRecord> newCadresRecordList = new List <CadresRecord>(); foreach (CLUBRecord newClubRec in newClubRecord) { foreach (CLUBRecord copyClubRec in copyClubList) { if (newClubRec.ClubName == copyClubRec.ClubName) { if (studentSCJDic.ContainsKey(copyClubRec.UID)) { foreach (var scjRec in studentSCJDic[copyClubRec.UID]) { if (_CopyPresidentStudent && (copyClubRec.President == scjRec.RefStudentID || copyClubRec.VicePresident == scjRec.RefStudentID)) { #region 複製社長副社長 SCJoin scj = new SCJoin(); scj.RefStudentID = scjRec.RefStudentID; scj.RefClubID = newClubRec.UID; //鎖定狀態 - 2021/4/15(鎖定狀態,依原鎖定狀態) if (IsNowLock) { scj.Lock = scjRec.Lock; } else { scj.Lock = true; } _InsertSCJList.Add(scj); #endregion continue; } if (_CopyCadresStudent && studentCadreDic.ContainsKey(copyClubRec.UID)) { bool match = false; #region 複製社團幹部 foreach (var cadresRec in studentCadreDic[copyClubRec.UID]) { if (cadresRec.RefStudentID == scjRec.RefStudentID) { CadresRecord cadre = new CadresRecord(); cadre.RefStudentID = cadresRec.RefStudentID; //學生 cadre.CadreName = cadresRec.CadreName; //幹部名稱 cadre.RefClubID = newClubRec.UID; newCadresRecordList.Add(cadre); SCJoin scj = new SCJoin(); scj.RefStudentID = scjRec.RefStudentID; scj.RefClubID = newClubRec.UID; //鎖定狀態 - 2021/4/15(鎖定狀態,依原鎖定狀態) if (IsNowLock) { scj.Lock = scjRec.Lock; } else { scj.Lock = true; } _InsertSCJList.Add(scj); match = true; break; } } #endregion if (match) { continue; } } if (_CopyOtherStudent) { #region 複製一般社員 SCJoin scj = new SCJoin(); scj.RefStudentID = scjRec.RefStudentID; scj.RefClubID = newClubRec.UID; //鎖定狀態 - 2021/4/15(鎖定狀態,依原鎖定狀態) if (IsNowLock) { scj.Lock = scjRec.Lock; } else { scj.Lock = true; } _InsertSCJList.Add(scj); #endregion continue; } } } } } } try { _AccessHelper.InsertValues(_InsertSCJList); _AccessHelper.InsertValues(newCadresRecordList); } catch (Exception ex) { SmartSchool.ErrorReporting.ReportingService.ReportException(ex); e.Cancel = true; return; } #endregion } }
void BGW_DoWork(object sender, DoWorkEventArgs e) { //取得相關的學生資料 //1.基本資料 //2.社團結算成績 GetPoint = new ClubTraMag(); //取得範本 #region 建立範本 Workbook template = new Workbook(); template.Open(new MemoryStream(Properties.Resources.社團成績單_範本), FileFormatType.Excel97To2003); //Style sy = template.Worksheets[0].Cells[3, 0].Style; //每一張 Workbook prototype = new Workbook(); prototype.Copy(template); Worksheet ptws = prototype.Worksheets[0]; #region 建立標頭Column 評量比例 評 = new 評量比例(); ColumnNameList = new List <string>(); ColumnNameList.Add("班級名稱"); ColumnNameList.Add("座號"); ColumnNameList.Add("姓名"); ColumnNameList.Add("學號"); ColumnNameList.Add("性別"); foreach (string each in 評.ColumnDic.Keys) { ColumnNameList.Add(each + "(" + 評.ProportionDic[each] + "%)"); } ColumnNameList.Add("學期成績"); ColumnNameList.Add("社團幹部"); int ColumnNameIndex = 0; //Jean 更新Aspose Style style = prototype.CreateStyle(); style.IsTextWrapped = true; foreach (string each in ColumnNameList) { ptws.Cells[2, ColumnNameIndex].SetStyle(style); ptws.Cells[2, ColumnNameIndex].PutValue(each); if (ColumnNameIndex >= 5) { ptws.Cells.SetColumnWidth(ColumnNameIndex, 8); tool.SetCellBro(ptws, 2, ColumnNameIndex, 1, 1); } ColumnNameIndex++; } #endregion Range ptHeader = ptws.Cells.CreateRange(0, 3, false); Range ptEachRow = ptws.Cells.CreateRange(3, 1, false); //建立Excel檔案 Workbook wb = new Workbook(); wb.Copy(prototype); //取得第一張 Worksheet ws = wb.Worksheets[0]; int dataIndex = 0; int CountPage = 1; int DetalIndex = 5; #endregion #region 填資料 foreach (string clubID in GetPoint.TraDic.Keys) { //每一個社團 ws.Cells.CreateRange(dataIndex, 3, false).CopyStyle(ptHeader); ws.Cells.CreateRange(dataIndex, 3, false).CopyValue(ptHeader); CLUBRecord cr = GetPoint.CLUBDic[clubID]; //第一行 - 建立標頭內容 ws.Cells.Merge(dataIndex, 0, 1, ColumnNameList.Count); string TitleName = string.Format("{0}學年度 第{1}學期 {2} 社團成績單", cr.SchoolYear.ToString(), cr.Semester.ToString(), cr.ClubName); ws.Cells[dataIndex, 0].PutValue(TitleName); dataIndex++; //第二行 - 代碼 ws.Cells.Merge(dataIndex, 0, 1, 3); ws.Cells[dataIndex, 0].PutValue("代碼:" + cr.ClubNumber); //第二行 - 老師 //教師 ColumnDic大小後的一格 ws.Cells.Merge(dataIndex, ColumnNameList.Count - 3, 1, 3); string TeacherString = "教師:" + GetTeacherName(cr); ws.Cells[dataIndex, ColumnNameList.Count - 3].PutValue(TeacherString); //SetCellBro(ws, dataIndex, 0, 1, ColumnNameList.Count); dataIndex += 2; GetPoint.TraDic[clubID].Sort(SortTraDic); foreach (ClubTraObj each in GetPoint.TraDic[clubID]) { ws.Cells.CreateRange(dataIndex, 1, false).CopyStyle(ptEachRow); ws.Cells.CreateRange(dataIndex, 1, false).CopyValue(ptEachRow); //基本資料 tool.SetCellBro(ws, dataIndex, 0, 1, 1); ws.Cells[dataIndex, 0].PutValue(each.student.Class != null ? each.student.Class.Name : ""); tool.SetCellBro(ws, dataIndex, 1, 1, 1); ws.Cells[dataIndex, 1].PutValue(each.student.SeatNo.HasValue ? each.student.SeatNo.Value.ToString() : ""); tool.SetCellBro(ws, dataIndex, 2, 1, 1); ws.Cells[dataIndex, 2].PutValue(each.student.Name); tool.SetCellBro(ws, dataIndex, 3, 1, 1); ws.Cells[dataIndex, 3].PutValue(each.student.StudentNumber); tool.SetCellBro(ws, dataIndex, 4, 1, 1); ws.Cells[dataIndex, 4].PutValue(each.student.Gender); if (!string.IsNullOrEmpty(each.SCJ.Score)) { XmlElement xml = DSXmlHelper.LoadXml(each.SCJ.Score); foreach (XmlElement each1 in xml.SelectNodes("Item")) { string name = each1.GetAttribute("Name"); if (評.ColumnDic.ContainsKey(name)) { tool.SetCellBro(ws, dataIndex, DetalIndex + 評.ColumnDic[name], 1, 1); ws.Cells[dataIndex, DetalIndex + 評.ColumnDic[name]].PutValue(each1.GetAttribute("Score")); } } } else { for (int x = 4; x < ColumnNameList.Count; x++) { tool.SetCellBro(ws, dataIndex, x, 1, 1); } } //學期成績 if (each.RSR != null) { ws.Cells.SetColumnWidth(ColumnNameList.Count - 2, 8); tool.SetCellBro(ws, dataIndex, ColumnNameList.Count - 2, 1, 1); string Score = each.RSR.ResultScore.HasValue ? each.RSR.ResultScore.Value.ToString() : ""; ws.Cells[dataIndex, ColumnNameList.Count - 2].PutValue(Score); //ws.Cells[dataIndex, ColumnNameList.Count - 1].Style = sy; } //社團幹部 if (each.RSR != null) { ws.Cells.SetColumnWidth(ColumnNameList.Count - 1, 8); tool.SetCellBro(ws, dataIndex, ColumnNameList.Count - 1, 1, 1); string CardreName = each.RSR.CadreName; ws.Cells[dataIndex, ColumnNameList.Count - 1].PutValue(CardreName); //ws.Cells[dataIndex, ColumnNameList.Count - 1].Style = sy; } dataIndex++; } //頁數 string DateName = "日期:" + DateTime.Now.ToString("yyyy/MM/dd HH:mm") + " 頁數:" + CountPage.ToString(); CountPage++; ws.Cells.Merge(dataIndex, 0, 1, 5); //SetCellBro(ws, dataIndex, 0, 1, ColumnNameList.Count); ws.Cells[dataIndex, 0].PutValue(DateName); //ws.Cells[dataIndex, 0].Style = sy; ws.HPageBreaks.Add(dataIndex + 1, ColumnNameList.Count); dataIndex++; } #endregion e.Result = wb; }
void BGW_DoWork(object sender, DoWorkEventArgs e) { BGW.ReportProgress(0, "取得社團志願設定..."); By_V = new Setup_ByV(); //取得狀態合理之學生基本資料(狀態一般/延修) BGW.ReportProgress(15, "取得學生基本資料..."); StudentList = GetVolunteerData.GetStudentData(); StudentDic = GetVolunteerData.GetStudentDic(StudentList); //取得畫面可顯示的Row資料 BGW.ReportProgress(25, "建立班級學生資料..."); Dictionary <string, 社團志願分配的Row> VolClassRowDic = GetVolClassRow(StudentList); //取得學生選社物件 BGW.ReportProgress(35, "取得學生志願資料..."); Dictionary <string, VolunteerRecord> VolDic = GetVolunteerData.GetVolunteerDic(); //本學年度學期的社團清單 BGW.ReportProgress(45, "取得本期社團資料..."); CLUBDic = GetVolunteerData.GetSchoolYearClub(); //取得目前系統內Lock之學生清單 BGW.ReportProgress(53, "取得社團學生資料..."); SCJLockDic = GetVolunteerData.GetSCJDic(CLUBDic.Keys.ToList()); //社團選社限制檢查工具 BGW.ReportProgress(60, "取得社團選社限制..."); CLUBCheckDic = GetCLUBCheckDic(); Increase(CLUBCheckDic, SCJLockDic); BGW.ReportProgress(75, "建立畫面資料樣式..."); //取出班級 foreach (社團志願分配的Row each in VolClassRowDic.Values) { //取出學生 foreach (一名學生 student in each._StudentDic.Values) { //學生志願選填分配 if (VolDic.ContainsKey(student.student_id)) { each._Volunteer.Add(student.student_id, VolDic[student.student_id]); } //學生已參與社團分配 if (SCJLockDic.ContainsKey(student.student_id)) { each._SCJDic.Add(student.student_id, SCJLockDic[student.student_id]); //順便取得此社團記錄 if (CLUBDic.ContainsKey(SCJLockDic[student.student_id].RefClubID)) { CLUBRecord club = CLUBDic[SCJLockDic[student.student_id].RefClubID]; if (!each._ClubDic.ContainsKey(club.UID)) { each._ClubDic.Add(club.UID, club); } } } } } _RowList = VolClassRowDic.Values.ToList(); _RowList.Sort(SortClass); BGW.ReportProgress(100, "學生志願檢查完成!"); }
public override string Import(List <Campus.DocumentValidator.IRowStream> Rows) { if (mOption.Action == ImportAction.InsertOrUpdate) { List <CLUBRecord> ClubInsertList = new List <CLUBRecord>(); List <CLUBRecord> ClubUpdateList = new List <CLUBRecord>(); foreach (IRowStream Row in Rows) { //教師名稱 string SchoolYear = Row.GetValue("學年度"); string Semester = Row.GetValue("學期"); string CLUBName = Row.GetValue("社團名稱"); string name = SchoolYear + "," + Semester + "," + CLUBName; if (Importbot.ClubDic.ContainsKey(name)) //更新 { CLUBRecord club = Importbot.ClubDic[name]; if (!Log_Dic.ContainsKey(club.UID)) { ImputLog i_n = new ImputLog(); i_n.lo_CLUB = club.CopyExtension(); Log_Dic.Add(club.UID, i_n); } Importbot.SetClub(Row, club); ClubUpdateList.Add(club); } else { //新增 CLUBRecord club = new CLUBRecord(); club.SchoolYear = int.Parse(SchoolYear); club.Semester = int.Parse(Semester); club.ClubName = CLUBName; Importbot.SetClub(Row, club); ClubInsertList.Add(club); } } if (ClubInsertList.Count > 0) { StringBuilder mstrLog1 = new StringBuilder(); mstrLog1.AppendLine("新增匯入社團:"); foreach (CLUBRecord each in ClubInsertList) { mstrLog1.AppendLine(Importbot.GetLogString(each)); } tool._A.InsertValues(ClubInsertList); FISCA.LogAgent.ApplicationLog.Log("社團", "新增匯入", mstrLog1.ToString()); } if (ClubUpdateList.Count > 0) { StringBuilder mstrLog2 = new StringBuilder(); mstrLog2.AppendLine("更新匯入社團:"); foreach (CLUBRecord each in ClubUpdateList) { if (Log_Dic.ContainsKey(each.UID)) { Log_Dic[each.UID].New_club = each.CopyExtension(); mstrLog2.AppendLine(Importbot.SetLog(Log_Dic[each.UID])); } } tool._A.UpdateValues(ClubUpdateList); FISCA.LogAgent.ApplicationLog.Log("社團", "更新匯入", mstrLog2.ToString()); } ClubEvents.RaiseAssnChanged(); } return(""); }
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("資料取得動作已取消"); } }
public string GetLogString(CLUBRecord each) { StringBuilder log = new StringBuilder(); log.AppendLine(string.Format("學年度「{0}」學期「{1}」社團名稱「{2}」", each.SchoolYear, each.Semester, each.ClubName)); if (!string.IsNullOrEmpty(each.ClubNumber)) { log.AppendLine(string.Format("代碼「{0}」", each.ClubNumber)); } if (!string.IsNullOrEmpty(each.Location)) { log.AppendLine(string.Format("場地「{0}」", each.Location)); } if (!string.IsNullOrEmpty(each.ClubCategory)) { log.AppendLine(string.Format("類型「{0}」", each.ClubCategory)); } if (!string.IsNullOrEmpty(each.RefTeacherID)) { if (TeacherIDDic.ContainsKey(each.RefTeacherID)) { log.AppendLine(string.Format("老師1「{0}」", GetTeacherName(TeacherIDDic[each.RefTeacherID]))); } } if (!string.IsNullOrEmpty(each.RefTeacherID2)) { if (TeacherIDDic.ContainsKey(each.RefTeacherID2)) { log.AppendLine(string.Format("老師2「{0}」", GetTeacherName(TeacherIDDic[each.RefTeacherID2]))); } } if (!string.IsNullOrEmpty(each.RefTeacherID3)) { if (TeacherIDDic.ContainsKey(each.RefTeacherID3)) { log.AppendLine(string.Format("老師3「{0}」", GetTeacherName(TeacherIDDic[each.RefTeacherID3]))); } } if (!string.IsNullOrEmpty(each.About)) { log.AppendLine(string.Format("簡介「{0}」", each.About)); } if (!string.IsNullOrEmpty(each.GenderRestrict)) { log.AppendLine(string.Format("限制:性別「{0}」", each.GenderRestrict)); } if (!string.IsNullOrEmpty(GetDeptName(each.DeptRestrict))) { log.AppendLine(string.Format("限制:科別「{0}」", GetDeptName(each.DeptRestrict))); } if (each.Grade1Limit.HasValue) { log.AppendLine(string.Format("限制:一年級人數「{0}」", each.Grade1Limit.Value.ToString())); } if (each.Grade2Limit.HasValue) { log.AppendLine(string.Format("限制:二年級人數「{0}」", each.Grade2Limit.Value.ToString())); } if (each.Grade3Limit.HasValue) { log.AppendLine(string.Format("限制:三年級人數「{0}」", each.Grade3Limit.Value.ToString())); } if (each.Limit.HasValue) { log.AppendLine(string.Format("限制:人數上限「{0}」", each.Limit.Value.ToString())); } return(log.ToString()); }