/// <summary>
 /// 儲存學生資料
 /// </summary>
 /// <param name="rec"></param>
 public void SaveStudentRecForLog(StudentRecord rec)
 {
     
     if (!leaveInfoPairDic.ContainsKey(rec.ID))
         leaveInfoPairDic.Add(rec.ID, new ObjList());
     leaveInfoPairDic[rec.ID]._StudentRec = rec;
 }
Example #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Trim() == "")
            {
                return;
            }

            string Msg = "轉學生請利用「異動作業>轉入作業」或是「線上轉學」功能。若是以此「新增」功能新增學生,必須透過「調整班級」功能調整學生班級,且需要輸入編班委員會會議日期,並將傳送至局端備查。請確認是否新增學生?";

            if (FISCA.Presentation.Controls.MsgBox.Show(Msg, "新增學生", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
            {
                K12.Data.StudentRecord studRec = new K12.Data.StudentRecord();
                studRec.Name = txtName.Text;
                string            StudentID = K12.Data.Student.Insert(studRec);
                PermRecLogProcess prlp      = new PermRecLogProcess();
                if (chkInputData.Checked == true)
                {
                    if (StudentID != "")
                    {
                        JHSchool.Student.Instance.PopupDetailPane(StudentID);
                        JHSchool.Student.Instance.SyncDataBackground(StudentID);
                    }
                }
                JHSchool.Student.Instance.SyncDataBackground(StudentID);

                prlp.SaveLog("學籍.學生", "新增學生", "新增學生姓名:" + txtName.Text);
            }
            this.Close();
        }
        void BGW_DoWork(object sender, DoWorkEventArgs e)
        {
            //取得學生
            _Studentecord = Student.SelectByID(this.PrimaryKey);

            //取得本名學生的社團成績記錄 string.Format("ref_student_id = '{0}'", this.PrimaryKey)
            RSRList = _AccessHelper.Select<ResultScoreRecord>(string.Format("ref_student_id = '{0}'", this.PrimaryKey));
        }
 public StudentNotExamSearchForm_Sub1(List<UDTTimeSectionDef> TimeSectionList,List<UDTAttendanceDef> attendanceList,string CourseName,string CourseSeatNo,StudentRecord studRec)
 {
     InitializeComponent();
     _TimeSectionList = TimeSectionList;
     _AttendanceList = attendanceList;
     _CourseSeatNo = CourseSeatNo;            
     _studRec = studRec;
     _CourseName = CourseName;
 }
Example #5
0
 //依年級、班序、學號排序副程式
 static int CompareClassNumber(StudentRecord a, StudentRecord b)
 {
     if (a.Class.GradeYear == b.Class.GradeYear)
     {
         if (int.Parse(a.Class.DisplayOrder) == int.Parse(b.Class.DisplayOrder))
             return a.StudentNumber.CompareTo(b.StudentNumber);
         else
             return int.Parse(a.Class.DisplayOrder).CompareTo(int.Parse(b.Class.DisplayOrder));
     }
     else
         return int.Parse(a.Class.GradeYear.ToString()).CompareTo(int.Parse(b.Class.GradeYear.ToString()));
 }
 /// <summary>
 /// 學生個案會議
 /// </summary>
 public StudCaseMeetingRecordForm(DAO.UDT_CounselCaseMeetingRecordDef CounselCaseMeetingRecord,accessType accType)
 {
     InitializeComponent();
     _UDTTransfer = new DAO.UDTTransfer();
     _CounselCaseMeetingRecord = CounselCaseMeetingRecord;
     _accessType = accType;
     _studRec = Student.SelectByID(CounselCaseMeetingRecord.StudentID.ToString());
     _TeacherIDNameDict = Utility.GetCounselTeacherIDNameDict(CounselCaseMeetingRecord.StudentID.ToString ());
     _TeacherNameIDDict = Utility.GetCounselTeacherNameIDDict(CounselCaseMeetingRecord.StudentID.ToString());
     //if (_accessType == accessType.Insert)
     //    _CounselCaseMeetingRecord.AuthorID = Utility.GetAuthorID();
     _LogTransfer = new DAO.LogTransfer();
 }
        public FrmFitnessRecord(DAO.StudentFitnessRecord rec, accessType actType)
        {
            InitializeComponent();

            _studRec = Student.SelectByID(rec.StudentID);
            _fitnessRec = rec;
            _actType = actType;
            _LogTransfer = new Log.LogTransfer();

            if(_actType == accessType.Edit)
                this.TitleText = _FrmTitleEdit;
            else
                this.TitleText = _FrmTitleAdd;
        }
        public StudCareRecordForm(DAO.UDT_CounselCareRecordDef CareRecordDef,accessType accType)
        {
            InitializeComponent();
            this.MaximumSize = this.MinimumSize = this.Size;
            _accessType = accType;
            _CounselCareRecord = CareRecordDef;
            _itemListCategory = new List<string>();
            _itemListOrigin = new List<string>();

            _studRec = Student.SelectByID(_CounselCareRecord.StudentID.ToString());
            _UDTTransfer = new DAO.UDTTransfer();
            _LogTransfer = new DAO.LogTransfer();
            //if (accType == accessType.Insert)
            //    _CounselCareRecord.AuthorID = Utility.GetAuthorID();
        }
        public StudInterviewDataForm(DAO.UDT_CounselStudentInterviewRecordDef StudInterviewRecord,AccessType accType)
        {
            InitializeComponent();
            _StudInterviewRecord = StudInterviewRecord;
            _UDTTransfer = new DAO.UDTTransfer();
            _TeacherIDNameDict = new Dictionary<int, string>();
            _TeacherNameIDDict = new Dictionary<string, int>();
            _accessType = accType;
            _LogTransfer = new DAO.LogTransfer();
            //if (accType == AccessType.Insert)
            //{
            //    _StudInterviewRecord.AuthorID = FISCA.Authentication.DSAServices.UserAccount;
            //    _StudInterviewRecord.isPublic = true;
            //}

            _TeacherRecList = new List<TeacherRecord>();
            _studRec = Student.SelectByID(StudInterviewRecord.StudentID.ToString ());
            _TeacherIDNameDict = Utility.GetCounselTeacherIDNameDict(StudInterviewRecord.StudentID.ToString ());
            _TeacherNameIDDict = Utility.GetCounselTeacherNameIDDict(StudInterviewRecord.StudentID.ToString());
            LoadDefaultData();
            LoadDataToForm();
        }
Example #10
0
        //private int SortStudent(StudentRecord sr1, StudentRecord sr2)
        //{
        //    return sr1.Name.CompareTo(sr2.Name);
        //}

        public int SortStudent(K12.Data.StudentRecord x, K12.Data.StudentRecord y)
        {
            K12.Data.StudentRecord student1 = x;
            K12.Data.StudentRecord student2 = y;

            string ClassName1 = student1.Class != null ? student1.Class.Name : "";

            ClassName1 = ClassName1.PadLeft(5, '0');
            string ClassName2 = student2.Class != null ? student2.Class.Name : "";

            ClassName2 = ClassName2.PadLeft(5, '0');

            string Sean1 = student1.SeatNo.HasValue ? student1.SeatNo.Value.ToString() : "";

            Sean1 = Sean1.PadLeft(3, '0');
            string Sean2 = student2.SeatNo.HasValue ? student2.SeatNo.Value.ToString() : "";

            Sean2 = Sean2.PadLeft(3, '0');

            ClassName1 += Sean1;
            ClassName2 += Sean2;

            return(ClassName1.CompareTo(ClassName2));
        }
        /// <summary>
        /// 傳入學生後
        /// 設定ListView內容
        /// </summary>
        private ListViewItem SetListView(StudentRecord STUD)
        {
            #region 依學生建立ListView
            string ClassName = "";
            string Gen = "";

            //班級
            if (!string.IsNullOrEmpty(STUD.RefClassID))
            {
                if (ClassDic.ContainsKey(STUD.RefClassID))
                {
                    ClassRecord cr = ClassDic[STUD.RefClassID];
                    ClassName = cr.Name;
                    Gen = cr.GradeYear.HasValue ? cr.GradeYear.Value.ToString() : "";
                }
            }

            if (scMAG.SCJoin_Lock.Contains(STUD.ID))
            {
                //学号
                ListViewItem item = new ListViewItem(Gen);
                item.SubItems.Add(ClassName);
                item.SubItems.Add(STUD.SeatNo.HasValue ? STUD.SeatNo.Value.ToString() : "");
                item.SubItems.Add(STUD.Name);
                item.SubItems.Add(STUD.Gender);
                item.SubItems.Add(STUD.StudentNumber);
                ListViewItem.ListViewSubItem subItem = item.SubItems.Add(STUD.StatusStr);
                item.SubItems.Add("是");

                if (scMAG.SCJoin_Lock.Contains(STUD.ID))
                {
                    foreach (ListViewItem.ListViewSubItem each in item.SubItems)
                    {
                        each.BackColor = Color.GreenYellow;
                    }
                }

                //TAG應該儲存修課記錄
                if (scMAG.SCJoin_Dic.ContainsKey(STUD.ID))
                {
                    item.Tag = scMAG.SCJoin_Dic[STUD.ID][0];

                    if (scMAG.SCJoin_Dic[STUD.ID].Count > 1)
                    {
                        foreach (ListViewItem.ListViewSubItem each in item.SubItems)
                        {
                            each.BackColor = Color.Red;
                        }
                        subItem.Text = "错误,重复的记录";
                    }
                }

                return item;
            }
            else
            {
                //学号
                ListViewItem item = new ListViewItem(Gen);
                item.SubItems.Add(ClassName);
                item.SubItems.Add(STUD.SeatNo.HasValue ? STUD.SeatNo.Value.ToString() : "");
                item.SubItems.Add(STUD.Name);
                item.SubItems.Add(STUD.Gender);
                item.SubItems.Add(STUD.StudentNumber);
                ListViewItem.ListViewSubItem subItem = item.SubItems.Add(STUD.StatusStr);
                item.SubItems.Add(" ");

                if (scMAG.SCJoin_Lock.Contains(STUD.ID))
                {
                    foreach (ListViewItem.ListViewSubItem each in item.SubItems)
                    {
                        each.BackColor = Color.GreenYellow;
                    }
                }

                //TAG應該儲存修課記錄
                if (scMAG.SCJoin_Dic.ContainsKey(STUD.ID))
                {
                    item.Tag = scMAG.SCJoin_Dic[STUD.ID][0];
                    if (scMAG.SCJoin_Dic[STUD.ID].Count > 1)
                    {
                        foreach (ListViewItem.ListViewSubItem each in item.SubItems)
                        {
                            each.BackColor = Color.Red;
                        }
                        subItem.Text = "错误,重复的记录";
                    }
                }

                return item;
            }

            #endregion
        }
 public ServiceDataRow(StudentRecord student, SLRecord slr)
 {
     IsChange = false;
     _student = student;
     _slr = slr;
 }
 /// <summary>
 /// 確認學生狀態是否正確,
 /// True:一般或延修生
 /// </summary>
 static public bool CheckStatus(StudentRecord student)
 {
     if (student.Status == StudentRecord.StudentStatus.一般 || student.Status == StudentRecord.StudentStatus.延修)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
        string eveCount;                                //給Log使用


        void bkwNotPassComputer_DoWork(object sender, DoWorkEventArgs e)
        {
            SB = new StringBuilder(); //給Log使用
            SB.AppendLine("詳細資料:");   //給Log使用
            StudIDList.Clear();       //給Log使用

            string        fileName         = (string)((object[])e.Argument)[0];
            List <string> studentFieldList = (List <string>)((object[])e.Argument)[1];
            List <string> exportFieldList  = (List <string>)((object[])e.Argument)[2];
            Dictionary <ManualResetEvent, List <RowData> > Filler = (Dictionary <ManualResetEvent, List <RowData> >)((object[])e.Argument)[3];
            double   totleProgress   = 0.0;
            double   packageProgress = 100.0 / Filler.Count;
            Workbook report          = new Workbook();

            report.Worksheets[0].Name = _Title;
            ((BackgroundWorker)sender).ReportProgress(1, _Title + " 資料整理中...");
            int RowIndex = 0;
            int i        = 0;

            //填表頭
            for (; i < studentFieldList.Count; i++)
            {
                report.Worksheets[0].Cells[0, i].PutValue(studentFieldList[i]);
            }
            for (int j = 0; j < exportFieldList.Count; j++)
            {
                report.Worksheets[0].Cells[0, i + j].PutValue(exportFieldList[j]);
            }
            RowIndex = 1;
            foreach (ManualResetEvent eve in Filler.Keys)
            {
                eve.WaitOne();
                eveCount = Filler[eve].Count.ToString(); //給Log使用

                if (Filler[eve].Count != 0)
                {
                    K12.Data.StudentRecord stud = K12.Data.Student.SelectByID(Filler[eve][0].ID);
                }

                if (RowIndex <= 65535)
                {
                    double miniProgress = Filler[eve].Count == 0 ? 1 : packageProgress / Filler[eve].Count;
                    double miniTotle    = 0;
                    foreach (RowData row in Filler[eve])
                    {
                        K12.Data.StudentRecord student = null;
                        if (row.ID != "")
                        {
                            if (!StudIDList.Contains(row.ID)) //給Log使用
                            {
                                StudIDList.Add(row.ID);
                            }

                            student = K12.Data.Student.SelectByID(row.ID);
                        }

                        if (student != null)
                        {
                            if (RowIndex <= 65535)
                            {
                                i = 0;
                                for (; i < studentFieldList.Count; i++)
                                {
                                    switch (studentFieldList[i])
                                    {
                                    case "學生系統編號": report.Worksheets[0].Cells[RowIndex, i].PutValue(student.ID); break;

                                    case "學號": report.Worksheets[0].Cells[RowIndex, i].PutValue(student.StudentNumber); break;

                                    case "班級": report.Worksheets[0].Cells[RowIndex, i].PutValue(student.Class == null ? "" : student.Class.Name); break;

                                    case "座號": report.Worksheets[0].Cells[RowIndex, i].PutValue(student.SeatNo); break;

                                    case "姓名": report.Worksheets[0].Cells[RowIndex, i].PutValue(student.Name); break;

                                    default:
                                        break;
                                    }
                                }
                                for (int j = 0; j < exportFieldList.Count; j++)
                                {
                                    report.Worksheets[0].Cells[RowIndex, i + j].PutValue(row.ContainsKey(exportFieldList[j]) ? row[exportFieldList[j]] : "");
                                }
                            }
                            RowIndex++;
                        }
                        miniTotle += miniProgress;
                        ((BackgroundWorker)sender).ReportProgress((int)(totleProgress + miniTotle), _Title + " 處理中...");
                    }
                }
                totleProgress += packageProgress;
                ((BackgroundWorker)sender).ReportProgress((int)(totleProgress), _Title + " 處理中...");
            }
            for (int k = 0; k < studentFieldList.Count + exportFieldList.Count; k++)
            {
                report.Worksheets[0].AutoFitColumn(k, 0, 150);
            }
            report.Worksheets[0].FreezePanes(1, 0, 1, studentFieldList.Count + exportFieldList.Count);
            e.Result = new object[] { report, fileName, RowIndex > 65535 };
        }
Example #15
0
        public int CompareTo(StudentRecord other)
        {
            if (CompareStudentRecord != null)
            {
                CompareStudentRecordEventArgs args = new CompareStudentRecordEventArgs(this, other);
                CompareStudentRecord(null, args);
                return args.Result;
            }
            else
            {
                ClassRecord c1 = this.Class;
                ClassRecord c2 = other.Class;
                if (c1 == c2)
                {
                    int seatNo1 = int.MinValue, seatNo2 = int.MinValue;

                    seatNo1 = this.SeatNo.Value;
                    seatNo2 = other.SeatNo.Value;

                    if (seatNo1 == seatNo2)
                        return this.StudentNumber.CompareTo(other.StudentNumber);
                    else
                        return seatNo1.CompareTo(seatNo2);
                }
                else
                {
                    if (c1 == null)
                        return int.MinValue;
                    else if (c2 == null)
                        return int.MaxValue;
                    return c1.CompareTo(c2);
                }
            }


        #endregion
        }
        public StatusItem? GetStatusItem(StudentRecord.StudentStatus status)
        {
            foreach (StatusItem item in Program.StatusList)
                if (item.Status == status)
                    return item;

            return new StatusItem() { Text = "未知", Status = StudentRecord.StudentStatus.一般 };
        }
 void AddLog(StudentRecord obj, UDT.StudentBrief2 obj2)
 {
     this.logAgent.SetLogValue("班級", (obj.Class == null ? "" : obj.Class.Name));
     this.logAgent.SetLogValue("座號", (obj.SeatNo == null ? "" : obj.SeatNo.ToString()));
     this.logAgent.SetLogValue("學號", obj.StudentNumber + "");
     this.logAgent.SetLogValue("年級", obj2.GradeYear + "");
     this.logAgent.SetLogValue("入學年度", obj2.EnrollYear + "");
     this.logAgent.SetLogValue("系所組別", this.cboDepartmentGroup.Text);
 }
        private List<DataBindedSheet> GetDataBindedSheets(StudentRecord Student, UDT.TeacherStatistics Statistic, Dictionary<string, UDT.Hierarchy> dicQuestionHierarchies, Dictionary<string, Dictionary<string, Color>> dicQuestionBackgroundColor, Dictionary<string, Dictionary<string, Color>> dicEvaluationBackgroundColor)
        {
            Dictionary<UDT.Hierarchy, List<XElement>> dicHierarchyQuestions = new Dictionary<UDT.Hierarchy, List<XElement>>();

            XDocument xDocument = XDocument.Parse(Statistic.StatisticsList, LoadOptions.None);
            XElement xStatistics = xDocument.Element("Statistics");

            #region 表頭

            string CSAttendCount = xStatistics.Attribute("CSAttendCount").Value;    //  修課人數
            string FeedBackCount = xStatistics.Attribute("FeedBackCount").Value;    //  填答人數
            string TeacherName = HttpUtility.HtmlDecode(xStatistics.Attribute("TeacherName").Value);            //  授課教師
            string CourseName = HttpUtility.HtmlDecode(xStatistics.Attribute("CourseName").Value);              //  開課
            string SubjectName = HttpUtility.HtmlDecode(xStatistics.Attribute("SubjectName").Value);            //  課程
            string ClassName = xStatistics.Attribute("ClassName").Value;                    //  班次
            string SubjectCode = xStatistics.Attribute("SubjectCode").Value;                //  課程識別碼
            string NewSubjectCode = xStatistics.Attribute("NewSubjectCode").Value;  //  課號
            string SchoolYear = xStatistics.Attribute("SchoolYear").Value;                      //  學年度
            string Semester = xStatistics.Attribute("Semester").Value;                              //  學期
            string CourseID = xStatistics.Attribute("CourseID").Value;                              //  開課系統編號
            string TeacherID = xStatistics.Attribute("TeacherID").Value;                            //  授課教師系統編號
            string SurveyDate = xStatistics.Attribute("SurveyDate").Value;                      //  問卷調查日期
            string SurveyID = xStatistics.Attribute("SurveyID").Value;                              //  問卷系統編號

            //  開啟意見調查表樣版檔
            List<UDT.ReportTemplate> templates = Access.Select<UDT.ReportTemplate>(string.Format("ref_survey_id = {0}", SurveyID));
            byte[] _buffer = Convert.FromBase64String(templates.ElementAt(0).Template);
            MemoryStream ms = new MemoryStream(_buffer);
            Workbook wb = new Workbook();
            wb.Open(ms);
            List<string> workSheetNames = new List<string>();
            wb.Worksheets.Cast<Worksheet>().ToList().ForEach(x=>workSheetNames.Add(x.Name));

            List<DataBindedSheet> DataBindedSheets = new List<DataBindedSheet>();

            DataBindedSheet DataBindedSheet = new DataBindedSheet();
            DataBindedSheet.Worksheet = wb.Worksheets["報表標題"];
            DataBindedSheet.DataTables = new List<DataTable>();
            DataBindedSheet.DataTables.Add(SchoolYear.ToDataTable("學年度", "學年度"));
            DataBindedSheet.DataTables.Add(Semester.ToDataTable("學期", "學期"));
            DataBindedSheet.DataTables.Add(SubjectName.ToDataTable("科目名稱", "科目名稱"));
            DataBindedSheet.DataTables.Add(NewSubjectCode.ToDataTable("課號", "課號"));
            DataBindedSheet.DataTables.Add(ClassName.ToDataTable("班次", "班次"));
            DataBindedSheet.DataTables.Add(TeacherName.ToDataTable("任課教師", "任課教師"));
            DataBindedSheet.DataTables.Add(CSAttendCount.ToDataTable("修課人數", "修課人數"));
            DataBindedSheet.DataTables.Add(FeedBackCount.ToDataTable("填答人數", "填答人數"));
            DataBindedSheet.DataTables.Add(SurveyDate.ToDataTable("問卷調查日期", "問卷調查日期"));
            DataBindedSheets.Add(DataBindedSheet);

            #endregion

            #region 群組化題目並排序

            //  將所有題目加入「標題」群組
            foreach (XElement xElement in xDocument.Descendants("Question"))
            {
                string question_id = xElement.Attribute("ID").Value;
                if (dicQuestionHierarchies.ContainsKey(question_id))
                {
                    UDT.Hierarchy Hierarchy = dicQuestionHierarchies[question_id];
                    if (!dicHierarchyQuestions.ContainsKey(Hierarchy))
                        dicHierarchyQuestions.Add(Hierarchy, new List<XElement>());

                    dicHierarchyQuestions[Hierarchy].Add(xElement);
                }
            }

            //  依照標題之顯示順序及題號排序
            Dictionary<UDT.Hierarchy, List<XElement>> dicOrderedHierarchyQuestions = new Dictionary<UDT.Hierarchy, List<XElement>>();
            foreach (KeyValuePair<UDT.Hierarchy, List<XElement>> kv in dicHierarchyQuestions.OrderBy(x => x.Key.DisplayOrder))
            {
                if (!dicOrderedHierarchyQuestions.ContainsKey(kv.Key))
                    dicOrderedHierarchyQuestions.Add(kv.Key, new List<XElement>());

                dicOrderedHierarchyQuestions[kv.Key].AddRange(kv.Value.OrderBy(x => int.Parse(x.Attribute("No").Value)));
            }

            #endregion

            string report_name = SchoolYear + "-" + Semester + "-" + CourseName + "-" + TeacherName;
            Dictionary<ReportHelper.CellObject, ReportHelper.CellStyle> dicCellStyles = new Dictionary<CellObject, CellStyle>();

            #region 報表資料的部份

            //  先產生資料容器
            DataTable EnrollRecordTable = new DataTable("NoneSelfAssessmentContent");
            this.MakeTableColumn(EnrollRecordTable);

            //  接著將資料倒進容器中
            int i = 0;
            foreach (UDT.Hierarchy Hierarchy in dicOrderedHierarchyQuestions.Keys)
            {
                ////  群組首
                //this.MakeGroupData(EnrollRecordTable, Hierarchy, report_name, dicCellStyles);

                ////  題目及答案
                //this.MakeDetailOneData(EnrollRecordTable, Hierarchy, dicOrderedHierarchyQuestions[Hierarchy], report_name, dicCellStyles);
                //this.MakeDetailTwoData(EnrollRecordTable, Hierarchy, dicOrderedHierarchyQuestions[Hierarchy], xDocument.Descendants("StatisticsGroup"), report_name, dicCellStyles, dicQuestionBackgroundColor, dicEvaluationBackgroundColor, SurveyID);
                //this.MakeDetailThreeData(EnrollRecordTable, Hierarchy, dicOrderedHierarchyQuestions[Hierarchy], report_name, dicCellStyles);
                //this.MakeDetailFourData(EnrollRecordTable, Hierarchy, dicOrderedHierarchyQuestions[Hierarchy], report_name, dicCellStyles);

                if (!workSheetNames.Contains(Hierarchy.Title))
                    continue;

                //  群組標題
                DataBindedSheet = new DataBindedSheet();
                DataBindedSheet.Worksheet = wb.Worksheets[Hierarchy.Title + "-標題"];
                DataBindedSheet.DataTables = new List<DataTable>();
                DataBindedSheet.DataTables.Add(i.ToDataTable("項次", "項次"));
                DataBindedSheets.Add(DataBindedSheet);

                //  群組資料
                foreach (XElement xElement in dicOrderedHierarchyQuestions[Hierarchy])
                {
                    DataBindedSheet = new DataBindedSheet();
                    DataBindedSheet.Worksheet = wb.Worksheets[Hierarchy.Title + "-資料"];
                    DataBindedSheet.DataTables = new List<DataTable>();
                    //  項次
                    DataBindedSheet.DataTables.Add((xElement.Attribute("No").Value + ".").ToDataTable("項次", "項次"));
                    //  非基本資料的題目
                    if (Hierarchy.Title != "基本資料")
                        DataBindedSheet.DataTables.Add(HttpUtility.HtmlDecode(xElement.Attribute("Content").Value).ToDataTable("題目", "題目"));

                    IEnumerable<XElement> Options = xElement.Descendants("Option");
                    if (Options.Count() > 0) Options = Options.OrderBy(x => int.Parse(x.Attribute("No").Value));

                    string question_content = string.Empty;
                    foreach (XElement xOption in Options)
                    {
                        //  選項做答人數
                        DataBindedSheet.DataTables.Add(xOption.Attribute("AnswerCount").Value.ToDataTable("做答人數-" + xOption.Attribute("No").Value, "做答人數-" + xOption.Attribute("No").Value));
                        question_content += "(" + xOption.Attribute("No").Value + ")" + HttpUtility.HtmlDecode(xOption.Attribute("Content").Value);
                    }
                    //  基本資料的題目
                    if (Hierarchy.Title == "基本資料")
                    {
                        DataBindedSheet.DataTables.Add(HttpUtility.HtmlDecode(xElement.Attribute("Content").Value + question_content).ToDataTable("題目", "題目"));
                    }
                    //  評鑑值
                    DataBindedSheet.DataTables.Add(xElement.Attribute("Score").Value.ToDataTable("評鑑值", "評鑑值"));
                }

                //  群組空白列
                if (workSheetNames.Contains(Hierarchy.Title + "-空白列"))
                {
                    DataBindedSheet = new DataBindedSheet();
                    DataBindedSheet.Worksheet = wb.Worksheets[Hierarchy.Title + "-空白列"];
                    DataBindedSheet.DataTables = new List<DataTable>();
                    DataBindedSheets.Add(DataBindedSheet);
                }

                //  平均評鑑值
                foreach (XElement xElement in xDocument.Descendants("StatisticsGroup"))
                {
                    DataBindedSheet = new DataBindedSheet();
                    DataBindedSheet.Worksheet = wb.Worksheets["平均評鑑值"];
                    DataBindedSheet.DataTables = new List<DataTable>();
                    DataBindedSheet.DataTables.Add(HttpUtility.HtmlDecode(xElement.Attribute("Content").Value).ToDataTable("群組名稱", "群組名稱"));
                    DataBindedSheet.DataTables.Add(xElement.Attribute("Score").Value.ToDataTable("評鑑值", "評鑑值"));
                    DataBindedSheets.Add(DataBindedSheet);

                    //  評鑑值背景色
                    if (dicEvaluationBackgroundColor.ContainsKey(SurveyID))
                    {
                        if (dicEvaluationBackgroundColor[SurveyID].ContainsKey(HttpUtility.HtmlDecode(xElement.Attribute("Content").Value)))
                        {
                            //CellObject co = new CellObject(EnrollRecordTable.Rows.Count - 1, 1, EnrollRecordTable.TableName, "DataSection", "平均評鑑值");
                            //cs.SetFontBackGroundColor(dicEvaluationBackgroundColor[SurveyID][HttpUtility.HtmlDecode(xElement.Attribute("Content").Value)]);
                            //dicCellStyles.Add(co, cs);
                        }
                    }
                }

                //  個案題
            }

            #endregion

            return DataBindedSheets;
        }
            /// <summary>
            /// 主要是給匯出時用的
            /// </summary>
            /// <param name="classRecord"></param>
            /// <param name="studentRecord"></param>
            /// <param name="fitnessRecord"></param>
            public void SetDataForExport(ClassRecord classRecord, StudentRecord studentRecord, DAO.StudentFitnessRecord fitnessRecord, bool isExportDegree)
            {
                
                // 測驗日期
                SetColumnValue("測驗日期", Utility.ConvertDateTimeToChineseDateTime(fitnessRecord.TestDate));

                // 學校類別
                SetColumnValue("學校類別", fitnessRecord.SchoolCategory);

                if (classRecord != null)
                {
                    // 年級
                    if (classRecord.GradeYear.HasValue)
                        SetColumnValue("年級", classRecord.GradeYear.Value.ToString());

                    // 班級名稱
                    SetColumnValue("班級名稱", classRecord.Name);

                    // 班級序號 for sort
                    SetOthersValue("班級序號", classRecord.DisplayOrder);
                }

                // 學號/座號
                SetColumnValue("學號/座號", studentRecord.StudentNumber);

                // 性別
                SetColumnValue("性別", Utility.ConvertDBGenderToOutGender(studentRecord.Gender));

                // 身分證字號
                SetColumnValue("身分證字號", studentRecord.IDNumber);

                // 生日
                SetColumnValue("生日", Utility.ConvertDateTimeToChineseDateTime(studentRecord.Birthday));

                // 身高
                SetColumnValue("身高", fitnessRecord.Height);

                // 體重
                SetColumnValue("體重", fitnessRecord.Weight);

                // 坐姿體前彎
                SetColumnValue("坐姿體前彎", fitnessRecord.SitAndReach);

                // 立定跳遠
                SetColumnValue("立定跳遠", fitnessRecord.StandingLongJump);

                // 仰臥起坐
                SetColumnValue("仰臥起坐", fitnessRecord.SitUp);

                // 心肺適能
                SetColumnValue("心肺適能", fitnessRecord.Cardiorespiratory);


                // 姓名 for sort
                SetOthersValue("姓名", studentRecord.Name);

                if(isExportDegree == true)
                {
                    // 身高常模
                    SetColumnValue("身高常模", fitnessRecord.HeightDegree);

                    // 體重常模
                    SetColumnValue("體重常模", fitnessRecord.WeightDegree);

                    // 坐姿體前彎常模
                    SetColumnValue("坐姿體前彎常模", fitnessRecord.SitAndReachDegree);

                    // 立定跳遠常模
                    SetColumnValue("立定跳遠常模", fitnessRecord.StandingLongJumpDegree);

                    // 仰臥起坐常模
                    SetColumnValue("仰臥起坐常模", fitnessRecord.SitUpDegree);

                    // 心肺適能常模
                    SetColumnValue("心肺適能常模", fitnessRecord.CardiorespiratoryDegree);
                }
            }
        void _BGWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            // Get Photo
            _FreshmanPhotoStr = _GraduatePhotoStr = string.Empty;
            _FreshmanPhotoStr = K12.Data.Photo.SelectFreshmanPhoto(PrimaryKey);
            _GraduatePhotoStr = K12.Data.Photo.SelectGraduatePhoto(PrimaryKey);

            // studentRec
            _StudRec = Student.SelectByID(PrimaryKey);
        }
 void AddLog(StudentRecord obj)
 {
     this.logAgent.SetLogValue("�m�W", obj.Name);
     this.logAgent.SetLogValue("�����Ҹ�", obj.IDNumber);
     this.logAgent.SetLogValue("�ͤ�", (obj.Birthday == null ? "" : obj.Birthday.ToString()));
     this.logAgent.SetLogValue("�ʧO", obj.Gender);
     this.logAgent.SetLogValue("���y", obj.Nationality);
     this.logAgent.SetLogValue("�X�ͦa", obj.BirthPlace);
     this.logAgent.SetLogValue("�^��m�W", obj.EnglishName);
     this.logAgent.SetLogValue("�n�J�b��", obj.SALoginName);
 }
        private void DisplayStatus(StudentRecord stu)
        {
            if (stu != null)
            {
                Color s;
                switch (stu.Status)
                {
                    case StudentRecord.StudentStatus.一般:
                        s = Color.FromArgb(255, 255, 255);
                        break;
                    case StudentRecord.StudentStatus.畢業或離校:
                        s = Color.FromArgb(156, 220, 128);
                        break;
                    case StudentRecord.StudentStatus.休學:
                        s = Color.FromArgb(254, 244, 128);
                        break;
                    case StudentRecord.StudentStatus.延修:
                        s = Color.FromArgb(224, 254, 210);
                        break;
                    case StudentRecord.StudentStatus.輟學:
                        s = Color.FromArgb(254, 244, 128);
                        break;
                    case StudentRecord.StudentStatus.轉出:
                        s = Color.FromArgb(156, 220, 55);
                        break;
                    case StudentRecord.StudentStatus.退學:
                        s = Color.FromArgb(156, 55, 128);
                        break;
                    case StudentRecord.StudentStatus.刪除:
                        s = Color.FromArgb(254, 128, 155);
                        break;
                    default:
                        s = Color.Transparent;
                        break;
                }

                StatusItem sitem = GetStatusItem(stu.Status).Value;

                StatusPanel.Text = sitem.Text;
                StatusPanel.Style.BackColor1.Color = s;
                StatusPanel.Style.BackColor2.Color = s;

                foreach (var item in StatusList)
                {
                    if ((StatusItem)item.Tag == sitem)
                        item.Checked = true;
                    else
                        item.Checked = false;
                }
            }
        }
 private string GetStudentString(StudentRecord sr)
 {
     string className = "";
     string seatno = sr.SeatNo.HasValue ? sr.SeatNo.Value.ToString() : "";
     if (ClassDic.ContainsKey(sr.RefClassID))
     {
         className = ClassDic[sr.RefClassID].Name;
     }
     return string.Format("班级「{0}」学号「{1}」学生「{2}」", className, seatno, sr.Name);
 }
        private void AddAddend(StudentRecord student)
        {
            // 檢查是否要加入
            bool CheckAdd = true;
            IEnumerable<DataGridViewRow> students = this.dgvData.Rows.Cast<DataGridViewRow>();

            if (students.Count() > 0)
                if (students.Where(x => (x.Tag as dynamic).StudentID == student.ID).Count() > 0)
                    CheckAdd = false;

            if (CheckAdd)
            {
                Save(new List<string>() { student.ID });

                string strSQL = string.Format(@"select $ischool.emba.scattend_ext.uid as sc_attend_id, student.id as ref_student_id, student.name as name, class_name, student_number, gender, report_group, is_cancel from student left join class on class.id=student.ref_class_id join $ischool.emba.scattend_ext on $ischool.emba.scattend_ext.ref_student_id=student.id join course on $ischool.emba.scattend_ext.ref_course_id=course.id where student.id='{0}' and $ischool.emba.scattend_ext.ref_course_id='{1}';", student.ID, PrimaryKey);

                QueryHelper helper = new QueryHelper();

                DataTable dataTable = helper.Select(strSQL);

                AppendDataToForm(dataTable);
            }
        }
        private Workbook GenerateWorkbook(StudentRecord Student, int SchoolYear, int Semester)
        {
            Workbook workbook = new Workbook();
            workbook.Worksheets.Cast<Worksheet>().ToList().ForEach(x => workbook.Worksheets.RemoveAt(x.Name));

            List<DataBindedSheet> TemplateSheets = this.GetDataBindedSheets(Student, SchoolYear, Semester);

            int instanceSheetIndex = workbook.Worksheets.Add();
            workbook.Worksheets[instanceSheetIndex].Name = Student.StudentNumber + "-" + Student.Name;
                //workbook.Worksheets.AddCopy(TemplateSheets.ElementAt(0).Worksheet.Name);
            workbook.Worksheets[instanceSheetIndex].Copy(TemplateSheets.ElementAt(0).Worksheet);
            Worksheet instanceSheet = workbook.Worksheets[instanceSheetIndex];

            int i = 0;
            DataSet dataSet = new DataSet();
            dataSet.Tables.AddRange(TemplateSheets.ElementAt(0).DataTables.ToArray());
            DocumentHelper.GenerateSheet(dataSet, instanceSheet, i, null);
            if (TemplateSheets.Count > 1)
            {
                TemplateSheets.RemoveAt(0);
                foreach (DataBindedSheet sheet in TemplateSheets)
                {
                    dataSet = new DataSet();
                    dataSet.Tables.AddRange(sheet.DataTables.ToArray());
                    i = instanceSheet.Cells.MaxRow + 1;
                    DocumentHelper.CloneTemplate(instanceSheet, sheet.Worksheet, i);
                    DocumentHelper.GenerateSheet(dataSet, instanceSheet, i, null);
                }
            }

            //  移除樣版檔
            TemplateSheets.ForEach(x => workbook.Worksheets.RemoveAt(x.Worksheet.Name));

            //  移除報表中的變數
            DocumentHelper.RemoveReportVariable(workbook);

            // 置換工作表名稱中的保留字
            workbook.Worksheets.Cast<Worksheet>().ToList().ForEach((x) =>
            {
                x.Name = x.Name.Replace(":", "꞉").Replace(":", "꞉").Replace("/", "⁄").Replace("/", "⁄").Replace(@"\", "∖").Replace("\", "∖").Replace("?", "_").Replace("?", "_").Replace("*", "✻").Replace("*", "✻").Replace("[", "〔").Replace("〔", "〔").Replace("]", "〕").Replace("〕", "〕");
            });
            return workbook;
        }
        protected override void OnPrimaryKeyChangedAsync()
        {
            Record = Student.SelectByID(PrimaryKey);

            List<StudentBrief2> student_Brief2s = Access.Select<StudentBrief2>(string.Format("ref_student_id = {0}", Record.ID));
            if (student_Brief2s.Count > 0)
                _StudentBrief2 = student_Brief2s[0];
            else
                _StudentBrief2 = new StudentBrief2();

            //List<DepartmentGroup> departmentGroups = Access.Select<DepartmentGroup>(string.Format("uid = {0}", _StudentBrief2.DepartmentGroupID.ToString()));
            /*
            if (departmentGroups.Count > 0)
                _DepartmentGroup = departmentGroups[0];
            else
                _DepartmentGroup = new DepartmentGroup();
             * */
        }
        private void SendSingleMail(string email_subject, string email_body, IEnumerable<string> email_list, MandrillApi mandrill, List<UDT.MandrillSendLog> MandrillSendLogs, dynamic o, StudentRecord Student, bool IsCC)
        {
            if (email_list.Count() == 0)
                return;

            string current_email = string.Empty;
            try
            {
                //  gmail 改為 mandrill

                //System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                //System.Net.NetworkCredential cred = new System.Net.NetworkCredential(this.SenderEmail, this.SenderPassword);

                //mail.Subject = email_subject;
                //mail.From = new System.Net.Mail.MailAddress(this.SenderEmail);

                //foreach (string email_address in email_list)
                //    mail.To.Add(email_address);

                //mail.IsBodyHtml = true;
                //mail.Body = email_body;

                //System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
                //smtp.UseDefaultCredentials = false;
                //smtp.EnableSsl = true;
                //smtp.Credentials = cred;
                //smtp.Port = 587;
                //smtp.Send(mail);

                //mandrill = new MandrillApi(this.MandrillAPIKey, false);

                List<EmailAddress> EmailAddresss = new List<EmailAddress>();
                foreach (string mail_to in email_list)
                {
                    current_email = mail_to;

                    EmailMessage message = new EmailMessage();
                    message.auto_text = false;
                    message.from_email = this.from_email;
                    message.from_name = this.from_name;
                    EmailAddress mt = new EmailAddress();

                    mt.email = mail_to;
                    mt.name = string.Empty;
                    message.to = new List<EmailAddress>(){ mt };

                    message.track_clicks = false;
                    message.track_opens = false;
                    message.html = email_body;
                    message.important = false;
                    message.merge = false;
                    message.preserve_recipients = false;
                    message.subject = email_subject;

                    List<EmailResult> results = mandrill.SendMessageSync(message);

                    //  Log Email Result
                    foreach (EmailResult result in results)
                    {
                        UDT.MandrillSendLog MandrillSendLog = new UDT.MandrillSendLog();

                        if (Student != null)
                        {
                            MandrillSendLog.StudentID = int.Parse(Student.ID);
                            MandrillSendLog.StudentNumber = Student.StudentNumber;
                            MandrillSendLog.StudentName = Student.Name;
                        }

                        MandrillSendLog.CourseID = int.Parse(o.CourseID + "");
                        MandrillSendLog.CourseName = o.CourseName + "";
                        MandrillSendLog.SubjectID = int.Parse(o.SubjectID + "");
                        MandrillSendLog.SubjectName = o.SubjectName + "";
                        MandrillSendLog.TeacherID = int.Parse(o.TeacherID + "");
                        MandrillSendLog.TeacherName = o.TeacherName + "";
                        MandrillSendLog.SchoolYear = o.SchoolYear + "";
                        MandrillSendLog.Semester = o.Semester + "";
                        MandrillSendLog.SurveyBeginTime = o.SurveyBeginTime + "";
                        MandrillSendLog.SurveyEndTime = o.SurveyEndTime + "";
                        MandrillSendLog.IsCC = IsCC;

                        MandrillSendLog.CCEmailAddress = string.Empty;
                        MandrillSendLog.CurrentUserAccount = this.user_account;
                        MandrillSendLog.Device = "desktop";
                        MandrillSendLog.EmailCategory = this.email_category;
                        MandrillSendLog.GUID = this.guid;
                        MandrillSendLog.RecipientEmailAddress = mail_to;// string.Join(",", email_list);
                        MandrillSendLog.RejectReason = result.RejectReason;
                        MandrillSendLog.ResultEmail = result.Email;
                        MandrillSendLog.ResultID = result.Id;
                        MandrillSendLog.SenderEmailAddress = this.from_email;
                        MandrillSendLog.SenderName = this.from_name;
                        MandrillSendLog.TimeStamp = this.time_stamp;
                        MandrillSendLog.Source = string.Empty;

                        MandrillSendLogs.Add(MandrillSendLog);
                    }

                    //EmailAddresss.Add(mt);
                }
            }
            //  Log Email Error
            catch (Exception ex)
            {
                MandrillException error = (MandrillException)ex;
                UDT.MandrillSendLog MandrillSendLog = new UDT.MandrillSendLog();

                if (Student != null)
                {
                    MandrillSendLog.StudentID = int.Parse(Student.ID);
                    MandrillSendLog.StudentNumber = Student.StudentNumber;
                    MandrillSendLog.StudentName = Student.Name;
                }

                MandrillSendLog.CourseID = int.Parse(o.CourseID + "");
                MandrillSendLog.CourseName = o.CourseName + "";
                MandrillSendLog.SubjectID = int.Parse(o.SubjectID + "");
                MandrillSendLog.SubjectName = o.SubjectName + "";
                MandrillSendLog.TeacherID = int.Parse(o.TeacherID + "");
                MandrillSendLog.TeacherName = o.TeacherName + "";
                MandrillSendLog.SchoolYear = o.SchoolYear + "";
                MandrillSendLog.Semester = o.Semester + "";
                MandrillSendLog.SurveyBeginTime = o.SurveyBeginTime + "";
                MandrillSendLog.SurveyEndTime = o.SurveyEndTime + "";
                MandrillSendLog.IsCC = IsCC;

                MandrillSendLog.CCEmailAddress = string.Empty;
                MandrillSendLog.CurrentUserAccount = this.user_account;
                MandrillSendLog.Device = "desktop";
                MandrillSendLog.EmailCategory = this.email_category;
                MandrillSendLog.GUID = this.guid;
                MandrillSendLog.RecipientEmailAddress = current_email;// string.Join(",", email_list);
                MandrillSendLog.ErrorCode = error.Error.code;
                MandrillSendLog.ErrorMessage = error.Error.message;
                MandrillSendLog.ErrorName = error.Error.name;
                MandrillSendLog.ErrorStatus = error.Error.status;
                MandrillSendLog.SenderName = this.from_name;
                MandrillSendLog.SenderEmailAddress = this.from_email;
                MandrillSendLog.TimeStamp = this.time_stamp;
                MandrillSendLog.Source = error.ToString();

                MandrillSendLogs.Add(MandrillSendLog);
            }
        }
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            _worker.ReportProgress(0, "取得學生康橋獎懲資料...");

            string stuIDs = string.Join(",", _stuIDList);

            // 將目前選擇學生的 康橋缺曠紀錄取出
            AccessHelper _AccessHelper = new AccessHelper();
            string       query         = "ref_student_id IN (" + stuIDs + ")";

            List <DAO.UDT_KCBSDermit> retVal = new List <DAO.UDT_KCBSDermit>();

            retVal = _AccessHelper.Select <DAO.UDT_KCBSDermit>(query);


            List <K12.Data.StudentRecord> srList = K12.Data.Student.SelectByIDs(_stuIDList);

            // 學生ID 資料 對照 字典
            Dictionary <string, K12.Data.StudentRecord> srDict = new Dictionary <string, StudentRecord>();

            foreach (K12.Data.StudentRecord record in srList)
            {
                srDict.Add(record.ID, record);
            }



            Workbook book = new Workbook();

            book.Worksheets.Clear();
            Worksheet ws = book.Worksheets[book.Worksheets.Add()];

            ws.Name = "康橋獎懲資料匯出";

            List <string> colheaderList = new List <string>();

            colheaderList.Add("姓名");
            colheaderList.Add("班級");
            colheaderList.Add("座號");
            colheaderList.Add("學號");
            colheaderList.Add("在學狀態");
            colheaderList.Add("發生日期");
            colheaderList.Add("懲戒層級");
            colheaderList.Add("懲戒單號");
            colheaderList.Add("是否註銷");
            colheaderList.Add("最後修正日期");

            int columnIndex = 0;

            // 加入表頭
            foreach (string header in colheaderList)
            {
                ws.Cells[0, columnIndex].PutValue(header);
                columnIndex++;
            }

            _worker.ReportProgress(80, "產生Excel報表...");

            //整理資料
            if (retVal.Count > 0)
            {
                int rowIndex = 1; //0為表頭,這裡從1 開始

                foreach (DAO.UDT_KCBSDermit record in retVal)
                {
                    #region 填入內容



                    K12.Data.StudentRecord sr = srDict["" + record.Ref_student_id];

                    //姓名
                    ws.Cells[rowIndex, 0].PutValue(sr.Name);
                    //班級
                    if (sr.Class != null)
                    {
                        ws.Cells[rowIndex, 1].PutValue(sr.Class.Name);
                    }
                    //座號
                    ws.Cells[rowIndex, 2].PutValue(sr.SeatNo);
                    //學號
                    ws.Cells[rowIndex, 3].PutValue(sr.StudentNumber);
                    //狀態
                    ws.Cells[rowIndex, 4].PutValue(sr.StatusStr);
                    //發生日期
                    ws.Cells[rowIndex, 5].PutValue(record.Occur_date.ToShortDateString());
                    //懲戒層級
                    ws.Cells[rowIndex, 6].PutValue(record.LevelNum);
                    //懲戒單號
                    ws.Cells[rowIndex, 7].PutValue(record.ref_Assota_NO);
                    //是否註銷
                    string deleted = record.IsDelete ? "是" : "否";
                    ws.Cells[rowIndex, 8].PutValue(deleted);
                    //最後修正日期
                    ws.Cells[rowIndex, 9].PutValue(record.LastUpdate.ToShortDateString());

                    rowIndex++;

                    #endregion
                }
            }

            ws.AutoFitColumns(); // 使 匯出excel 自動調整 欄寬

            e.Result = book;

            _worker.ReportProgress(100, "康橋獎懲資料匯出,產生完成。");
        }
Example #29
0
        /// <summary>
        /// 轉換Log需要班級座號姓名
        /// </summary>
        /// <param name="rec"></param>
        /// <returns></returns>
        public static string ConvertString1(StudentRecord rec)
        {
            List<string> retList = new List<string>();

            retList.Add("學號:" + rec.StudentNumber);
            if(rec.Class!=null)
                retList.Add("班級:" + rec.Class.Name);

            if (rec.SeatNo.HasValue)
                retList.Add("座號:" + rec.SeatNo.Value);

            retList.Add("姓名:" + rec.Name);

            if (retList.Count > 0)
                return string.Join(",", retList.ToArray());
            else
                return "";
        }
        private List<DataBindedSheet> GetDataBindedSheets(StudentRecord Student, int SchoolYear, int Semester)
        {
            //  非停修生修課記錄:學年度	學期	課號	課程識別碼		課程名稱
            string SQL = string.Format(@"Select subject.uid as subject_id, course.school_year, course.semester, subject.new_subject_code, subject.subject_code, subject.name as subject_name From $ischool.emba.scattend_ext as se join course on course.id=se.ref_course_id
            join student on student.id=se.ref_student_id
            join $ischool.emba.course_ext as ce on ce.ref_course_id=course.id
            join $ischool.emba.subject as subject on subject.uid=ce.ref_subject_id where student.id={0} and course.school_year={1} and course.semester={2} order by ce.serial_no", Student.ID, SchoolYear, Semester);
            DataTable dataTable = Query.Select(SQL);
            Dictionary<string, dynamic> dicSCAttends = new Dictionary<string, dynamic>();
            foreach(DataRow row in dataTable.Rows)
            {
                dynamic o = new ExpandoObject();

                o.SchoolYear = SchoolYear;
                o.Semester = Semester;
                o.NewSubjectCode = row["new_subject_code"] + "";
                o.SubjectCode = row["subject_code"] + "";
                o.SubjectName = row["subject_name"] + "";
                o.SubjectID = row["subject_id"] + "";

                dicSCAttends.Add(SchoolYear + "-" + Semester + "-" + row["subject_id"] + "", o);
            }

            UDT.StudentBrief2 StudentBrief2 = new UDT.StudentBrief2();
            if (this.dicStudentBrief2.ContainsKey(Student.ID))
                StudentBrief2 = this.dicStudentBrief2[Student.ID];

            UDT.DepartmentGroup DepartmentGroup = new UDT.DepartmentGroup();
            if (this.dicStudentBrief2.ContainsKey(Student.ID))
            {
                if (this.dicDepartmentGroups.ContainsKey(StudentBrief2.DepartmentGroupID.ToString()))
                    DepartmentGroup = this.dicDepartmentGroups[StudentBrief2.DepartmentGroupID.ToString()];
            }

            Dictionary<int, UDT.GraduationSubjectList> dicGraduationSubjectLists = new Dictionary<int, UDT.GraduationSubjectList>();
            if (this.dicStudentBrief2.ContainsKey(Student.ID))
            {
                if (this.dicGraduationSubjectLists.ContainsKey(StudentBrief2.GraduationRequirementID))
                    dicGraduationSubjectLists = this.dicGraduationSubjectLists[StudentBrief2.GraduationRequirementID];
            }

            Dictionary<string, UDT.GraduationSubjectGroupRequirement> dicGraduationSubjectGroups = new Dictionary<string, UDT.GraduationSubjectGroupRequirement>();
            if (this.dicStudentBrief2.ContainsKey(Student.ID))
            {
                if (this.dicGraduationSubjectGroupRequirements.ContainsKey(StudentBrief2.GraduationRequirementID))
                    dicGraduationSubjectGroups = this.dicGraduationSubjectGroupRequirements[StudentBrief2.GraduationRequirementID];
            }

            //GraduationSubjectList

            Workbook wb = new Workbook();
            MemoryStream ms = new MemoryStream(Properties.Resources.EMBA_歷年成績表_樣版);
            wb.Open(ms);

            List<DataBindedSheet> DataBindedSheets = new List<DataBindedSheet>();

            DataBindedSheet DataBindedSheet = new DataBindedSheet();
            DataBindedSheet.Worksheet = wb.Worksheets["PageHeader"];
            DataBindedSheet.DataTables = new List<DataTable>();
            DataBindedSheet.DataTables.Add(Student.StudentNumber.ToDataTable("學號", "學號"));
            DataBindedSheet.DataTables.Add(Student.Name.ToDataTable("姓名", "姓名"));
            DataBindedSheet.DataTables.Add(Student.Gender.ToDataTable("性別", "性別"));

            if (!Student.Birthday.HasValue)
            {
                DataBindedSheet.DataTables.Add("".ToDataTable("出生日期", "出生日期"));
            }
            else
            {
                DateTime birthday;
                if (DateTime.TryParse(Student.Birthday.Value + "", out birthday))
                    DataBindedSheet.DataTables.Add(birthday.ToString("yyyy/MM/dd").ToDataTable("出生日期", "出生日期"));
                else
                    DataBindedSheet.DataTables.Add("".ToDataTable("出生日期", "出生日期"));
            }

            DataBindedSheet.DataTables.Add(StudentBrief2.EnrollYear.ToDataTable("入學年度", "入學年度"));
            DataBindedSheet.DataTables.Add(DepartmentGroup.Name.ToDataTable("系所組別", "系所組別"));
            DataBindedSheets.Add(DataBindedSheet);

            Dictionary<string, KeyValuePair> dicSubjectGroupGredits = new Dictionary<string, KeyValuePair>();
            if (this.dicSubjectSemesterScores.ContainsKey(Student.ID))
            {
                List<UDT.SubjectSemesterScore> SubjectSemesterScores = this.dicSubjectSemesterScores[Student.ID];
                SubjectSemesterScores.ForEach((x) =>
                {
                    if (string.IsNullOrEmpty(x.NewSubjectCode))
                    {
                        if (this.dicSubjects.ContainsKey(x.SubjectID.ToString()))
                            x.NewSubjectCode = this.dicSubjects[x.SubjectID.ToString()].NewSubjectCode;
                    }
                });
                SubjectSemesterScores = SubjectSemesterScores.OrderBy(x => x.SchoolYear.HasValue ? x.SchoolYear.Value : 0).ThenBy(x => x.Semester.HasValue ? x.Semester.Value : 0).ThenBy(x => x.NewSubjectCode).ToList();

                int credit_total = 0;
                Dictionary<int, List<UDT.SubjectSemesterScore>> dicDuplicateSubjectSemesterScores = new Dictionary<int, List<UDT.SubjectSemesterScore>>();
                List<string> present_subject_ids = new List<string>();
                foreach (UDT.SubjectSemesterScore SubjectSemesterScore in SubjectSemesterScores)
                {
                    //  是否重覆修課
                    if (!dicDuplicateSubjectSemesterScores.ContainsKey(SubjectSemesterScore.SubjectID))
                        dicDuplicateSubjectSemesterScores.Add(SubjectSemesterScore.SubjectID, new List<UDT.SubjectSemesterScore>());
                    dicDuplicateSubjectSemesterScores[SubjectSemesterScore.SubjectID].Add(SubjectSemesterScore);

                    DataBindedSheet = new DataBindedSheet();
                    DataBindedSheet.Worksheet = wb.Worksheets["DataSection"];
                    DataBindedSheet.DataTables = new List<DataTable>();
                    DataBindedSheet.DataTables.Add((SubjectSemesterScore.SchoolYear.HasValue ? SubjectSemesterScore.SchoolYear.Value + "" : "").ToDataTable("學年度", "學年度"));
                    DataBindedSheet.DataTables.Add((SubjectSemesterScore.Semester.HasValue ? SubjectSemesterScore.Semester.Value + "" : "").ToDataTable("學期", "學期"));
                    DataBindedSheet.DataTables.Add(SubjectSemesterScore.NewSubjectCode.ToDataTable("課號", "課號"));

                    DataBindedSheet.DataTables.Add(SubjectSemesterScore.SubjectCode.ToDataTable("課程識別碼", "課程識別碼"));
                    DataBindedSheet.DataTables.Add(SubjectSemesterScore.SubjectName.ToDataTable("課程名稱", "課程名稱"));
                    DataBindedSheet.DataTables.Add(SubjectSemesterScore.Score.ToDataTable("成績", "成績"));

                    if (dicGraduationSubjectLists.ContainsKey(SubjectSemesterScore.SubjectID))
                    {
                        string SubjectGroup = dicGraduationSubjectLists[SubjectSemesterScore.SubjectID].SubjectGroup;
                        DataBindedSheet.DataTables.Add(SubjectGroup.ToDataTable("群組別", "群組別"));
                        if (!dicSubjectGroupGredits.ContainsKey(SubjectGroup))
                            dicSubjectGroupGredits.Add(SubjectGroup, new KeyValuePair());

                        if (dicGraduationSubjectGroups.ContainsKey(SubjectGroup))
                            dicSubjectGroupGredits[SubjectGroup].Key = dicGraduationSubjectGroups[SubjectGroup].LowestCredit;
                        if (SubjectSemesterScore.IsPass)
                        {
                            if (dicSubjectGroupGredits[SubjectGroup].Value == null)
                                dicSubjectGroupGredits[SubjectGroup].Value = SubjectSemesterScore.Credit;
                            else
                                dicSubjectGroupGredits[SubjectGroup].Value += SubjectSemesterScore.Credit;
                        }
                        if (this.dicSubjects.ContainsKey(SubjectSemesterScore.SubjectID.ToString()))
                            DataBindedSheet.DataTables.Add(this.dicSubjects[SubjectSemesterScore.SubjectID.ToString()].Credit.ToDataTable("學分數", "學分數"));
                        else
                            DataBindedSheet.DataTables.Add(SubjectSemesterScore.Credit.ToDataTable("學分數", "學分數"));
                    }
                    else
                    {
                        DataBindedSheet.DataTables.Add("".ToDataTable("群組別", "群組別"));
                        DataBindedSheet.DataTables.Add(SubjectSemesterScore.Credit.ToDataTable("學分數", "學分數"));
                    }

                    if (!string.IsNullOrEmpty(SubjectSemesterScore.OffsetCourse) || SubjectSemesterScore.IsPass)
                    {
                        DataBindedSheet.DataTables.Add("已取得學分".ToDataTable("備註", "備註"));
                    }
                    else
                        DataBindedSheet.DataTables.Add("未取得學分".ToDataTable("備註", "備註"));

                    if (SubjectSemesterScore.IsPass && string.IsNullOrEmpty(SubjectSemesterScore.OffsetCourse))
                        credit_total += SubjectSemesterScore.Credit;

                    DataBindedSheets.Add(DataBindedSheet);
                    present_subject_ids.Add(string.Format("{0}-{1}-{2}", (SubjectSemesterScore.SchoolYear.HasValue ? SubjectSemesterScore.SchoolYear.Value + "" : ""), (SubjectSemesterScore.Semester.HasValue ? SubjectSemesterScore.Semester.Value + "" : ""), SubjectSemesterScore.SubjectID));
                }
                foreach(string key in dicSCAttends.Keys)
                {
                    if (present_subject_ids.Contains(key))
                        continue;

                    dynamic o = dicSCAttends[key];

                    DataBindedSheet = new DataBindedSheet();
                    DataBindedSheet.Worksheet = wb.Worksheets["DataSection"];
                    DataBindedSheet.DataTables = new List<DataTable>();

                    int intSchoolYear = 0;
                    int intSemester = 0;
                    int.TryParse(o.SchoolYear + "", out intSchoolYear);
                    int.TryParse(o.Semester + "", out intSemester);
                    string NewSubjectCode = o.NewSubjectCode + "";
                    string SubjectCode = o.SubjectCode + "";
                    string SubjectName = o.SubjectName + "";
                    DataBindedSheet.DataTables.Add(intSchoolYear.ToDataTable("學年度", "學年度"));
                    DataBindedSheet.DataTables.Add(intSemester.ToDataTable("學期", "學期"));
                    DataBindedSheet.DataTables.Add(NewSubjectCode.ToDataTable("課號", "課號"));
                    DataBindedSheet.DataTables.Add(SubjectCode.ToDataTable("課程識別碼", "課程識別碼"));
                    DataBindedSheet.DataTables.Add(SubjectName.ToDataTable("課程名稱", "課程名稱"));
                    DataBindedSheet.DataTables.Add("".ToDataTable("成績", "成績"));
                    DataBindedSheet.DataTables.Add("".ToDataTable("學分數", "學分數"));

                    int SubjectID = 0;
                    int.TryParse(o.SubjectID + "", out SubjectID);
                    if (dicGraduationSubjectLists.ContainsKey(SubjectID))
                    {
                        string SubjectGroup = dicGraduationSubjectLists[SubjectID].SubjectGroup;
                        DataBindedSheet.DataTables.Add(SubjectGroup.ToDataTable("群組別", "群組別"));
                        if (!dicSubjectGroupGredits.ContainsKey(SubjectGroup))
                            dicSubjectGroupGredits.Add(SubjectGroup, new KeyValuePair());

                        if (dicGraduationSubjectGroups.ContainsKey(SubjectGroup))
                            dicSubjectGroupGredits[SubjectGroup].Key = dicGraduationSubjectGroups[SubjectGroup].LowestCredit;
                    }
                    else
                    {
                        DataBindedSheet.DataTables.Add("".ToDataTable("群組別", "群組別"));
                    }
                    DataBindedSheet.DataTables.Add("本學期修課".ToDataTable("備註", "備註"));

                    DataBindedSheets.Add(DataBindedSheet);
                }

                int offset_credit = SubjectSemesterScores.Where(x => !string.IsNullOrWhiteSpace(x.OffsetCourse)).Sum(x => x.Credit);
                DataBindedSheet = new DataBindedSheet();
                DataBindedSheet.Worksheet = wb.Worksheets["PageFooter-Header"];
                DataBindedSheet.DataTables = new List<DataTable>();
                DataBindedSheet.DataTables.Add(credit_total.ToDataTable("修習及格學分", "修習及格學分"));
                DataBindedSheet.DataTables.Add(offset_credit.ToDataTable("抵免學分", "抵免學分"));
                DataBindedSheet.DataTables.Add((credit_total + offset_credit).ToDataTable("實得總學分", "實得總學分"));
                DataBindedSheets.Add(DataBindedSheet);

                List<UDT.GraduationSubjectGroupRequirement> GraduationSubjectGroupRequirements = dicGraduationSubjectGroups.Values.ToList();
                GraduationSubjectGroupRequirements.Sort(
                delegate(UDT.GraduationSubjectGroupRequirement x, UDT.GraduationSubjectGroupRequirement y)
                {
                    int index_x = SubjectGroups_Sort.IndexOf(x.SubjectGroup);
                    int index_y = SubjectGroups_Sort.IndexOf(y.SubjectGroup);
                    if (index_x < 0)
                        index_x = int.MaxValue;
                    if (index_y < 0)
                        index_y = int.MaxValue;

                    return index_x.CompareTo(index_y);
                });

                foreach (UDT.GraduationSubjectGroupRequirement GraduationSubjectGroupRequirement in GraduationSubjectGroupRequirements)
                {
                    string SubjectGroup = GraduationSubjectGroupRequirement.SubjectGroup;
                    DataBindedSheet = new DataBindedSheet();
                    DataBindedSheet.Worksheet = wb.Worksheets["PageFooter-DataSection"];
                    DataBindedSheet.DataTables = new List<DataTable>();
                    DataBindedSheet.DataTables.Add(SubjectGroup.ToDataTable("群組別", "群組別"));

                    int gCredit = 0;

                    if (dicSubjectGroupGredits.ContainsKey(SubjectGroup))
                        if (dicSubjectGroupGredits[SubjectGroup].Value.HasValue)
                            gCredit = dicSubjectGroupGredits[SubjectGroup].Value.Value;

                    DataBindedSheet.DataTables.Add((gCredit + "").ToDataTable("已取得學分數", "已取得學分數"));

                    int sCredit = GraduationSubjectGroupRequirement.LowestCredit;
                    if (dicSubjectGroupGredits.ContainsKey(SubjectGroup))
                    {
                        if (sCredit > gCredit)
                            DataBindedSheet.DataTables.Add((sCredit - gCredit).ToDataTable("不足學分數", "不足學分數"));
                        else
                            DataBindedSheet.DataTables.Add("0".ToDataTable("不足學分數", "不足學分數"));
                    }
                    else
                    {
                        DataBindedSheet.DataTables.Add(sCredit.ToDataTable("不足學分數", "不足學分數"));
                    }
                    DataBindedSheet.DataTables.Add(sCredit.ToDataTable("應修學分數", "應修學分數"));

                    DataBindedSheets.Add(DataBindedSheet);
                }

                DataBindedSheet = new DataBindedSheet();
                DataBindedSheet.Worksheet = wb.Worksheets["PageFooter-Footer"];
                DataBindedSheet.DataTables = new List<DataTable>();
                DataBindedSheets.Add(DataBindedSheet);

                //  重覆修課
                List<UDT.SubjectSemesterScore> DuplicateSubjectSemesterScores = new List<UDT.SubjectSemesterScore>();
                foreach (int SubjectID in dicDuplicateSubjectSemesterScores.Keys)
                {
                    if (dicDuplicateSubjectSemesterScores[SubjectID].Count > 1)
                        DuplicateSubjectSemesterScores.AddRange(dicDuplicateSubjectSemesterScores[SubjectID]);
                }

                if (DuplicateSubjectSemesterScores.Count > 1)
                {
                    DataBindedSheet = new DataBindedSheet();
                    DataBindedSheet.Worksheet = wb.Worksheets["Duplicate-Header"];
                    DataBindedSheet.DataTables = new List<DataTable>();
                    DataBindedSheets.Add(DataBindedSheet);
                    foreach (UDT.SubjectSemesterScore SubjectSemesterScore in DuplicateSubjectSemesterScores)
                    {
                        DataBindedSheet = new DataBindedSheet();
                        DataBindedSheet.Worksheet = wb.Worksheets["Duplicate-DataSection"];
                        DataBindedSheet.DataTables = new List<DataTable>();
                        DataBindedSheet.DataTables.Add((SubjectSemesterScore.SchoolYear.HasValue ? SubjectSemesterScore.SchoolYear.Value + "" : "").ToDataTable("學年度", "學年度"));
                        DataBindedSheet.DataTables.Add((SubjectSemesterScore.Semester.HasValue ? SubjectSemesterScore.Semester.Value + "" : "").ToDataTable("學期", "學期"));
                        DataBindedSheet.DataTables.Add(SubjectSemesterScore.NewSubjectCode.ToDataTable("課號", "課號"));

                        DataBindedSheet.DataTables.Add(SubjectSemesterScore.SubjectCode.ToDataTable("課程識別碼", "課程識別碼"));
                        DataBindedSheet.DataTables.Add(SubjectSemesterScore.SubjectName.ToDataTable("課程名稱", "課程名稱"));
                        DataBindedSheet.DataTables.Add(SubjectSemesterScore.Score.ToDataTable("成績", "成績"));
                        //DataBindedSheet.DataTables.Add(SubjectSemesterScore.Credit.ToDataTable("學分數", "學分數"));

                        if (dicGraduationSubjectLists.ContainsKey(SubjectSemesterScore.SubjectID))
                        {
                            string SubjectGroup = dicGraduationSubjectLists[SubjectSemesterScore.SubjectID].SubjectGroup;
                            DataBindedSheet.DataTables.Add(SubjectGroup.ToDataTable("群組別", "群組別"));
                            if (!dicSubjectGroupGredits.ContainsKey(SubjectGroup))
                                dicSubjectGroupGredits.Add(SubjectGroup, new KeyValuePair());

                            if (dicGraduationSubjectGroups.ContainsKey(SubjectGroup))
                                dicSubjectGroupGredits[SubjectGroup].Key = dicGraduationSubjectGroups[SubjectGroup].LowestCredit;
                            if (SubjectSemesterScore.IsPass)
                            {
                                if (dicSubjectGroupGredits[SubjectGroup].Value == null)
                                    dicSubjectGroupGredits[SubjectGroup].Value = SubjectSemesterScore.Credit;
                                else
                                    dicSubjectGroupGredits[SubjectGroup].Value += SubjectSemesterScore.Credit;
                            }
                            if (this.dicSubjects.ContainsKey(SubjectSemesterScore.SubjectID.ToString()))
                                DataBindedSheet.DataTables.Add(this.dicSubjects[SubjectSemesterScore.SubjectID.ToString()].Credit.ToDataTable("學分數", "學分數"));
                            else
                                DataBindedSheet.DataTables.Add(SubjectSemesterScore.Credit.ToDataTable("學分數", "學分數"));
                        }
                        else
                        {
                            DataBindedSheet.DataTables.Add("".ToDataTable("群組別", "群組別"));
                            DataBindedSheet.DataTables.Add(SubjectSemesterScore.Credit.ToDataTable("學分數", "學分數"));
                        }

                        if (!string.IsNullOrEmpty(SubjectSemesterScore.OffsetCourse) || SubjectSemesterScore.IsPass)
                        {
                            DataBindedSheet.DataTables.Add("已取得學分".ToDataTable("備註", "備註"));
                        }
                        else
                            DataBindedSheet.DataTables.Add("未取得學分".ToDataTable("備註", "備註"));

                        if (SubjectSemesterScore.IsPass && string.IsNullOrEmpty(SubjectSemesterScore.OffsetCourse))
                            credit_total += SubjectSemesterScore.Credit;

                        DataBindedSheets.Add(DataBindedSheet);
                    }
                    DataBindedSheet = new DataBindedSheet();
                    DataBindedSheet.Worksheet = wb.Worksheets["Duplicate-Footer"];
                    DataBindedSheet.DataTables = new List<DataTable>();
                    DataBindedSheets.Add(DataBindedSheet);
                }
            }

            return DataBindedSheets;
        }
Example #31
0
 internal CompareStudentRecordEventArgs(StudentRecord v1, StudentRecord v2)
 {
     Value1 = v1;
     Value2 = v2;
 }