private void ProduceData(List <SHStudentRecord> pStudents) { List <MeritRecord> meritRecords = Merit.SelectByStudentIDs(pStudents.Select(x => x.ID)); foreach (MeritRecord mr in meritRecords) { if (!_PersonalMeritRecordInfo.ContainsKey(mr.RefStudentID)) { _PersonalMeritRecordInfo.Add(mr.RefStudentID, new List <MeritRecord>()); } _PersonalMeritRecordInfo[mr.RefStudentID].Add(mr); } List <DemeritRecord> demeritRecords = Demerit.SelectByStudentIDs(pStudents.Select(x => x.ID)); foreach (DemeritRecord dr in demeritRecords) { if (!_PersonalDemeritRecordInfo.ContainsKey(dr.RefStudentID)) { _PersonalDemeritRecordInfo.Add(dr.RefStudentID, new List <DemeritRecord>()); } _PersonalDemeritRecordInfo[dr.RefStudentID].Add(dr); } }
private void GetMeDemrit(Dictionary <string, StudRecord> studDic) { //取得學生所有的獎懲紀錄 List <MeritRecord> meriteList = Merit.SelectByStudentIDs(studDic.Keys); foreach (MeritRecord each in meriteList) { if (studDic.ContainsKey(each.RefStudentID)) { studDic[each.RefStudentID].MeritList.Add(each); } } List <DemeritRecord> demeriteList = Demerit.SelectByStudentIDs(studDic.Keys); foreach (DemeritRecord each in demeriteList) { if (studDic.ContainsKey(each.RefStudentID)) { studDic[each.RefStudentID].DemeritList.Add(each); //懲戒資料內包含留查資料 } } }
// GET: Demerits/Delete public ActionResult DemeritDelete(int?id) { Demerit demerit = db.Demerits.Find(id); db.Demerits.Remove(demerit); db.SaveChanges(); return(RedirectToAction("DemeritIndex")); }
public ActionResult DemeritEdit([Bind(Include = "Demerit1,Student_ID,DemeritDescription,DemeritDate")] Demerit demerit) { if (ModelState.IsValid) { db.Entry(demerit).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("DemeritIndex")); } ViewBag.Student_ID = new SelectList(db.Students, "Student_ID", "Student_ID", demerit.Student_ID); return(View(demerit)); }
public ActionResult DemeritCreate([Bind(Include = "Demerit1,Student_ID,DemeritDescription,DemeritDate")] Demerit demerit) { if (ModelState.IsValid) { db.Demerits.Add(demerit); db.SaveChanges(); return(RedirectToAction("DemeritIndex")); } ViewBag.Student_ID = new SelectList(db.Students, "Student_ID", "Student_ID", demerit.Student_ID); return(View(demerit)); }
// GET: Demerits/Edit public ActionResult DemeritEdit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Demerit demerit = db.Demerits.Find(id); if (demerit == null) { return(HttpNotFound()); } ViewBag.Student_ID = new SelectList(db.Students, "Student_ID", "Student_ID", demerit.Student_ID); return(View(demerit)); }
/// <summary> /// 取得所有資料 /// </summary> private void SetStudentBoxs() { List <string> StudentIDList = K12.Presentation.NLDPanels.Student.SelectedSource; ListStudent = Student.SelectByIDs(StudentIDList); //取得學生 ListStudent.Sort(new Comparison <StudentRecord>(ParseStudent)); ListPhone = Phone.SelectByStudentIDs(StudentIDList); //取得電話資料 ListParent = Parent.SelectByStudentIDs(StudentIDList); //取得監護人資料 ListAddress = Address.SelectByStudentIDs(StudentIDList); //取得地址資料 ListMerit = Merit.SelectByStudentIDs(StudentIDList); //取得獎勵資料(一對多) ListDeMerit = Demerit.SelectByStudentIDs(StudentIDList); //取得懲戒資料(一對多) ListMoralScore = SHMoralScore.SelectByStudentIDs(StudentIDList); //取得日常生活表現資料(一對多) ListUpdataRecord = UpdateRecord.SelectByStudentIDs(StudentIDList); //取得異動資料(一對多) ListJHSemesterHistory = SemesterHistory.SelectByStudentIDs(StudentIDList); //取得學生學期歷程 //ListAssnCode = _accessHelper.Select<AssnCode>(); //取得所有社團記錄 ListAutoSummary = AutoSummary.Select(StudentIDList, null); ListAutoSummary.Sort(SortSchoolYearSemester); }
private void _BGWDisciplineNotification_DoWork(object sender, DoWorkEventArgs e) { #region Report if (entityName.ToLower() == "student") //學生模式 { SelectedStudents = K12.Data.Student.SelectByIDs(K12.Presentation.NLDPanels.Student.SelectedSource); } else if (entityName.ToLower() == "class") //班級模式 { SelectedStudents = new List <StudentRecord>(); foreach (StudentRecord each in Student.SelectByClassIDs(K12.Presentation.NLDPanels.Class.SelectedSource)) { if (each.Status != StudentRecord.StudentStatus.一般) { continue; } SelectedStudents.Add(each); } } else { throw new NotImplementedException(); } SelectedStudents.Sort(new Comparison <StudentRecord>(CommonMethods.ClassSeatNoComparer)); #endregion //超級資訊物件 Dictionary <string, StudentOBJ> StudentSuperOBJ = new Dictionary <string, StudentOBJ>(); //所有學生ID List <string> allStudentID = new List <string>(); //學生人數 int currentStudentCount = 1; int totalStudentNumber = 0; #region 依據 ClassID 建立班級學生清單 //List<StudentRecord> classStudent = SelectedStudents; //加總用 Dictionary <string, int> StudMeritSum = new Dictionary <string, int>(); foreach (StudentRecord aStudent in SelectedStudents) { //string aStudentID = aStudent.ID; if (!StudentSuperOBJ.ContainsKey(aStudent.ID)) { StudentSuperOBJ.Add(aStudent.ID, new StudentOBJ()); } //學生ID清單 if (!allStudentID.Contains(aStudent.ID)) { allStudentID.Add(aStudent.ID); } StudentSuperOBJ[aStudent.ID].student = aStudent; StudentSuperOBJ[aStudent.ID].TeacherName = aStudent.Class != null ? (aStudent.Class.Teacher != null ? aStudent.Class.Teacher.Name : "") : ""; StudentSuperOBJ[aStudent.ID].ClassName = aStudent.Class != null ? aStudent.Class.Name : ""; StudentSuperOBJ[aStudent.ID].SeatNo = aStudent.SeatNo.HasValue ? aStudent.SeatNo.Value.ToString() : ""; StudentSuperOBJ[aStudent.ID].StudentNumber = aStudent.StudentNumber; } #endregion #region 取得獎懲資料(日期區間) List <DemeritRecord> DemeritList = new List <DemeritRecord>(); if (obj.IsInsertDate) //發生日期 { DemeritList = Demerit.SelectByOccurDate(allStudentID, obj.StartDate, obj.EndDate); } else //登錄入期 { DemeritList = Demerit.SelectByRegisterDate(allStudentID, obj.StartDate, obj.EndDate); } string reportName = "留察通知單(" + obj.StartDate.ToString("yyyy-MM-dd") + "至" + obj.EndDate.ToString("yyyy-MM-dd") + ")"; //依日期排序 DemeritList.Sort(SortDateTime); foreach (DemeritRecord var in DemeritList) { string occurMonthDay = var.OccurDate.Month + "/" + var.OccurDate.Day; string reason = var.Reason; if (var.MeritFlag == "2") //1是獎勵 { #region 留察 StringBuilder detailString = new StringBuilder(); detailString.Append(occurMonthDay + " "); //日期 if (!string.IsNullOrEmpty(reason)) { detailString.Append(reason + " "); //事由 } detailString.Append("(留校察看) "); //明細資料 StudentSuperOBJ[var.RefStudentID].DemeritStringList.Add(detailString.ToString()); #endregion } } #endregion #region 取得學生通訊地址資料 foreach (AddressRecord record in Address.SelectByStudentIDs(allStudentID)) { if (obj.ReceiveAddress == "戶籍地址") { if (!string.IsNullOrEmpty(record.PermanentAddress)) { StudentSuperOBJ[record.RefStudentID].address = record.Permanent.County + record.Permanent.Town + record.Permanent.District + record.Permanent.Area + record.Permanent.Detail; } if (!string.IsNullOrEmpty(record.PermanentZipCode)) { StudentSuperOBJ[record.RefStudentID].ZipCode = record.PermanentZipCode; if (record.PermanentZipCode.Length >= 1) { StudentSuperOBJ[record.RefStudentID].ZipCode1 = record.PermanentZipCode.Substring(0, 1); } if (record.PermanentZipCode.Length >= 2) { StudentSuperOBJ[record.RefStudentID].ZipCode2 = record.PermanentZipCode.Substring(1, 1); } if (record.PermanentZipCode.Length >= 3) { StudentSuperOBJ[record.RefStudentID].ZipCode3 = record.PermanentZipCode.Substring(2, 1); } if (record.PermanentZipCode.Length >= 4) { StudentSuperOBJ[record.RefStudentID].ZipCode4 = record.PermanentZipCode.Substring(3, 1); } if (record.PermanentZipCode.Length >= 5) { StudentSuperOBJ[record.RefStudentID].ZipCode5 = record.PermanentZipCode.Substring(4, 1); } } } else if (obj.ReceiveAddress == "聯絡地址") { if (!string.IsNullOrEmpty(record.MailingAddress)) { StudentSuperOBJ[record.RefStudentID].address = record.Mailing.County + record.Mailing.Town + record.Mailing.District + record.Mailing.Area + record.Mailing.Detail; //再處理 } if (!string.IsNullOrEmpty(record.MailingZipCode)) { StudentSuperOBJ[record.RefStudentID].ZipCode = record.MailingZipCode; if (record.MailingZipCode.Length >= 1) { StudentSuperOBJ[record.RefStudentID].ZipCode1 = record.MailingZipCode.Substring(0, 1); } if (record.MailingZipCode.Length >= 2) { StudentSuperOBJ[record.RefStudentID].ZipCode2 = record.MailingZipCode.Substring(1, 1); } if (record.MailingZipCode.Length >= 3) { StudentSuperOBJ[record.RefStudentID].ZipCode3 = record.MailingZipCode.Substring(2, 1); } if (record.MailingZipCode.Length >= 4) { StudentSuperOBJ[record.RefStudentID].ZipCode4 = record.MailingZipCode.Substring(3, 1); } if (record.MailingZipCode.Length >= 5) { StudentSuperOBJ[record.RefStudentID].ZipCode5 = record.MailingZipCode.Substring(4, 1); } } } else if (obj.ReceiveAddress == "其他地址") { if (!string.IsNullOrEmpty(record.Address1Address)) { StudentSuperOBJ[record.RefStudentID].address = record.Address1.County + record.Address1.Town + record.Address1.District + record.Address1.Area + record.Address1.Detail; //再處理 } if (!string.IsNullOrEmpty(record.Address1ZipCode)) { StudentSuperOBJ[record.RefStudentID].ZipCode = record.Address1ZipCode; if (record.Address1ZipCode.Length >= 1) { StudentSuperOBJ[record.RefStudentID].ZipCode1 = record.Address1ZipCode.Substring(0, 1); } if (record.Address1ZipCode.Length >= 2) { StudentSuperOBJ[record.RefStudentID].ZipCode2 = record.Address1ZipCode.Substring(1, 1); } if (record.Address1ZipCode.Length >= 3) { StudentSuperOBJ[record.RefStudentID].ZipCode3 = record.Address1ZipCode.Substring(2, 1); } if (record.Address1ZipCode.Length >= 4) { StudentSuperOBJ[record.RefStudentID].ZipCode4 = record.Address1ZipCode.Substring(3, 1); } if (record.Address1ZipCode.Length >= 5) { StudentSuperOBJ[record.RefStudentID].ZipCode5 = record.Address1ZipCode.Substring(4, 1); } } } } #endregion #region 取得學生監護人父母親資料 List <ParentRecord> ParentList = Parent.SelectByStudentIDs(allStudentID); foreach (ParentRecord record in ParentList) { StudentSuperOBJ[record.RefStudentID].CustodianName = record.CustodianName; StudentSuperOBJ[record.RefStudentID].FatherName = record.FatherName; StudentSuperOBJ[record.RefStudentID].MotherName = record.MotherName; } #endregion #region 產生報表 Aspose.Words.Document template = new Aspose.Words.Document(obj.Template); template.MailMerge.Execute( new string[] { "學校名稱", "學校地址", "學校電話" }, new object[] { School.ChineseName, School.Address, School.Telephone } ); Aspose.Words.Document doc = new Aspose.Words.Document(); doc.RemoveAllChildren(); Aspose.Words.Node sectionNode = template.Sections[0].Clone(); //取得學生人數 totalStudentNumber = StudentSuperOBJ.Count; foreach (string student in StudentSuperOBJ.Keys) { //如果沒有學生就離開 if (obj.PrintHasRecordOnly) { if (StudentSuperOBJ.Count == 0) { continue; } } if (StudentSuperOBJ[student].DemeritStringList.Count == 0) { continue; } Aspose.Words.Document eachDoc = new Aspose.Words.Document(); eachDoc.RemoveAllChildren(); eachDoc.Sections.Add(eachDoc.ImportNode(sectionNode, true)); //合併列印的資料 Dictionary <string, object> mapping = new Dictionary <string, object>(); StudentOBJ eachStudentInfo = StudentSuperOBJ[student]; //學生資料 mapping.Add("系統編號", "系統編號{" + eachStudentInfo.student.ID + "}"); mapping.Add("學生姓名", eachStudentInfo.student.Name); mapping.Add("班級", eachStudentInfo.ClassName); mapping.Add("座號", eachStudentInfo.SeatNo); mapping.Add("學號", eachStudentInfo.StudentNumber); mapping.Add("導師", eachStudentInfo.TeacherName); mapping.Add("資料期間", obj.StartDate.ToShortDateString() + " 至 " + obj.EndDate.ToShortDateString()); //收件人資料 if (obj.ReceiveName == "監護人姓名") { mapping.Add("收件人姓名", eachStudentInfo.CustodianName); } else if (obj.ReceiveName == "父親姓名") { mapping.Add("收件人姓名", eachStudentInfo.FatherName); } else if (obj.ReceiveName == "母親姓名") { mapping.Add("收件人姓名", eachStudentInfo.MotherName); } else { mapping.Add("收件人姓名", eachStudentInfo.student.Name); } //收件人地址資料 mapping.Add("收件人地址", eachStudentInfo.address); mapping.Add("郵遞區號", eachStudentInfo.ZipCode); mapping.Add("0", eachStudentInfo.ZipCode1); mapping.Add("1", eachStudentInfo.ZipCode2); mapping.Add("2", eachStudentInfo.ZipCode3); mapping.Add("4", eachStudentInfo.ZipCode4); mapping.Add("5", eachStudentInfo.ZipCode5); mapping.Add("學年度", School.DefaultSchoolYear); mapping.Add("學期", School.DefaultSemester); //懲戒明細 object[] objectValues = new object[] { StudentSuperOBJ[student].DemeritStringList }; mapping.Add("懲戒明細", objectValues); string[] keys = new string[mapping.Count]; object[] values = new object[mapping.Count]; int i = 0; foreach (string key in mapping.Keys) { keys[i] = key; values[i++] = mapping[key]; } //合併列印 eachDoc.MailMerge.MergeField += new Aspose.Words.Reporting.MergeFieldEventHandler(DisciplineNotification_MailMerge_MergeField); eachDoc.MailMerge.RemoveEmptyParagraphs = true; eachDoc.MailMerge.Execute(keys, values); Aspose.Words.Node eachSectionNode = eachDoc.Sections[0].Clone(); doc.Sections.Add(doc.ImportNode(eachSectionNode, true)); //回報進度 _BGWDisciplineNotification.ReportProgress((int)(((double)currentStudentCount++ *100.0) / (double)totalStudentNumber)); } #endregion #region 產生學生清單 Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(); if (obj.PrintStudentList) { int CountRow = 0; wb.Worksheets[0].Cells[CountRow, 0].PutValue("班級"); wb.Worksheets[0].Cells[CountRow, 1].PutValue("座號"); wb.Worksheets[0].Cells[CountRow, 2].PutValue("學號"); wb.Worksheets[0].Cells[CountRow, 3].PutValue("學生姓名"); wb.Worksheets[0].Cells[CountRow, 4].PutValue("收件人姓名"); wb.Worksheets[0].Cells[CountRow, 5].PutValue("地址"); CountRow++; foreach (string each in StudentSuperOBJ.Keys) { //如果沒有學生就離開 if (obj.PrintHasRecordOnly) { if (StudentSuperOBJ.Count == 0) { continue; } } if (StudentSuperOBJ[each].DemeritStringList.Count == 0) { continue; } wb.Worksheets[0].Cells[CountRow, 0].PutValue(StudentSuperOBJ[each].ClassName); wb.Worksheets[0].Cells[CountRow, 1].PutValue(StudentSuperOBJ[each].SeatNo); wb.Worksheets[0].Cells[CountRow, 2].PutValue(StudentSuperOBJ[each].StudentNumber); wb.Worksheets[0].Cells[CountRow, 3].PutValue(StudentSuperOBJ[each].student.Name); //收件人資料 if (obj.ReceiveName == "監護人姓名") { wb.Worksheets[0].Cells[CountRow, 4].PutValue(StudentSuperOBJ[each].CustodianName); } else if (obj.ReceiveName == "父親姓名") { wb.Worksheets[0].Cells[CountRow, 4].PutValue(StudentSuperOBJ[each].FatherName); } else if (obj.ReceiveName == "母親姓名") { wb.Worksheets[0].Cells[CountRow, 4].PutValue(StudentSuperOBJ[each].MotherName); } else { wb.Worksheets[0].Cells[CountRow, 4].PutValue(StudentSuperOBJ[each].student.Name); } wb.Worksheets[0].Cells[CountRow, 5].PutValue(StudentSuperOBJ[each].ZipCode + " " + StudentSuperOBJ[each].address); CountRow++; } wb.Worksheets[0].AutoFitColumns(); } #endregion string path = Path.Combine(Application.StartupPath, "Reports"); string path2 = Path.Combine(Application.StartupPath, "Reports"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = Path.Combine(path, reportName + ".doc"); path2 = Path.Combine(path2, reportName + "(學生清單).xls"); string message = "【電子報表通知】您好 本期「{0}」已產生,可於電子報表中檢視「資料期間:{1} 至 {2}」"; e.Result = new object[] { reportName, path, doc, path2, obj.PrintStudentList, wb, string.Format(message, "留察通知單", obj.StartDate.ToShortDateString(), obj.EndDate.ToShortDateString()) }; }
public Dictionary <string, int> GetMerit(List <一名學生> StudentList) { //取得學生ID StudentDic = GetStudentIDList(StudentList); //取得獎懲資料 List <MeritRecord> MeritList = Merit.SelectByStudentIDs(StudentDic.Keys); List <DemeritRecord> DemeritList = Demerit.SelectByStudentIDs(StudentDic.Keys); //取得功過相抵換算值 _Reduce = K12.Data.MeritDemeritReduce.Select(); foreach (MeritRecord mr in MeritList) { if (StudentDic.ContainsKey(mr.RefStudentID)) { int studINT = 0; int a = mr.MeritA.HasValue ? mr.MeritA.Value : 0; int b = mr.MeritB.HasValue ? mr.MeritB.Value : 0; int c = mr.MeritC.HasValue ? mr.MeritC.Value : 0; if (_Reduce.MeritAToMeritB.HasValue) { int aa = a * _Reduce.MeritAToMeritB.Value; studINT += aa * _Reduce.MeritBToMeritC.Value; } if (_Reduce.MeritBToMeritC.HasValue) { studINT += b * _Reduce.MeritBToMeritC.Value; } studINT += c; StudentDic[mr.RefStudentID] += studINT; } } foreach (DemeritRecord mr in DemeritList) { if (mr.Cleared == "是") //銷過資料則離開 { continue; } if (mr.MeritFlag == "2") //留查資料則離開 { continue; } if (StudentDic.ContainsKey(mr.RefStudentID)) { int studINT = 0; int a = mr.DemeritA.HasValue ? mr.DemeritA.Value : 0; int b = mr.DemeritB.HasValue ? mr.DemeritB.Value : 0; int c = mr.DemeritC.HasValue ? mr.DemeritC.Value : 0; if (_Reduce.MeritAToMeritB.HasValue) { int aa = a * _Reduce.MeritAToMeritB.Value; studINT += aa * _Reduce.MeritBToMeritC.Value; } if (_Reduce.MeritBToMeritC.HasValue) { studINT += b * _Reduce.MeritBToMeritC.Value; } studINT += c; StudentDic[mr.RefStudentID] -= studINT; } } return(StudentDic); }