Ejemplo n.º 1
0
        private void WriteLog(object sender)
        {
            StringBuilder sb = new StringBuilder();

            string title = "";

            if (sender == btnEntrance)
            {
                title = "入學日期";
            }
            else if (sender == btnGraduate)
            {
                title = "畢業日期";
            }

            foreach (string id in _logDic.Keys)
            {
                StudentRecord sr  = _studentRecords[id];
                LogObj        obj = _logDic[id];

                if (sender == btnEntrance && obj.BeforeEn != obj.AfterEn)
                {
                    string before_date = obj.BeforeEn.HasValue ? obj.BeforeEn.Value.ToShortDateString() : string.Empty;
                    string after_date  = obj.AfterEn.HasValue ? obj.AfterEn.Value.ToShortDateString() : string.Empty;
                    sb.AppendLine(string.Format("學生:{0} 學號:{1} 入學日期由「{2}」改為「{3}」", sr.Name, sr.StudentNumber, before_date, after_date));
                }

                if (sender == btnGraduate && obj.BeforeLv != obj.AfterLv)
                {
                    string before_date = obj.BeforeLv.HasValue ? obj.BeforeLv.Value.ToShortDateString() : string.Empty;
                    string after_date  = obj.AfterLv.HasValue ? obj.AfterLv.Value.ToShortDateString() : string.Empty;
                    sb.AppendLine(string.Format("學生:{0} 學號:{1} 畢業日期由「{2}」改為「{3}」", sr.Name, sr.StudentNumber, before_date, after_date));
                }
            }

            if (!string.IsNullOrEmpty(sb.ToString()))
            {
                FISCA.LogAgent.ApplicationLog.Log("批次修改入學及畢業日期", "修改" + title, sb.ToString());
            }

            MessageBox.Show(title + " 修改完成");
        }
Ejemplo n.º 2
0
        private void DataInit()
        {
            _studentRecords.Clear();
            List <StudentRecord> students = K12.Data.Student.SelectByIDs(_ids);

            foreach (StudentRecord s in students)
            {
                _studentRecords.Add(s.ID, s);
            }

            string str_id = string.Join("','", _ids);

            str_id       = "'" + str_id + "'";
            _studExtList = tool._A.Select <StudentRecord_Ext>("ref_student_id in (" + str_id + ")");

            _studExtDic.Clear();
            foreach (string id in _ids)
            {
                //先全部建立一個StudentRecord_Ext
                StudentRecord_Ext record = new StudentRecord_Ext();
                record.RefStudentID = id;
                _studExtDic.Add(id, record);
            }

            foreach (StudentRecord_Ext record in _studExtList)
            {
                //有已存在的資料就覆蓋回去
                _studExtDic[record.RefStudentID] = record;
            }

            _logDic.Clear();
            foreach (string id in _studExtDic.Keys)
            {
                //紀錄更新前的資料
                LogObj obj = new LogObj(id);
                obj.BeforeEn = _studExtDic[id].EntranceDate;
                obj.BeforeLv = _studExtDic[id].LeavingDate;
                _logDic.Add(id, obj);
            }
        }