当前位置: 首页>>代码示例>>C#>>正文


C# List.SaveAll方法代码示例

本文整理汇总了C#中List.SaveAll方法的典型用法代码示例。如果您正苦于以下问题:C# List.SaveAll方法的具体用法?C# List.SaveAll怎么用?C# List.SaveAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在List的用法示例。


在下文中一共展示了List.SaveAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnDelete_Click

        private void btnDelete_Click(object sender, EventArgs e)
        {
            List<UDT.StatisticsGroup> StatisticsGroups = new List<UDT.StatisticsGroup>();

            if (MessageBox.Show("確定刪除?", "警告", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
                return;
            foreach (DataGridViewRow DataGridViewRow in this.dgvData.SelectedRows)
            {
                UDT.StatisticsGroup StatisticsGroup = DataGridViewRow.Tag as UDT.StatisticsGroup;
                StatisticsGroup.Deleted = true;
                StatisticsGroups.Add(StatisticsGroup);
            }
            StatisticsGroups.SaveAll();
            this.InitStatisticsGroup();
        }
开发者ID:jungfengpaulwang,项目名称:EMBATeachingEvaluation,代码行数:15,代码来源:frmCalculateEvaluation.cs

示例2: Save

        public void Save(List<string> students)
        {
            List<SCAttendExt> scattendRecords = new List<SCAttendExt>();
            foreach (string student in students)
            {
                SCAttendExt scattendRecord = new SCAttendExt();
                scattendRecord.StudentID = int.Parse(student);
                scattendRecord.CourseID = int.Parse(PrimaryKey);
                scattendRecord.IsCancel = false;
                scattendRecords.Add(scattendRecord);
            }
            try
            {
                List<string> insertedRecordUIDs = scattendRecords.SaveAll();
                List<K12.Data.StudentRecord> studentRecords = new List<StudentRecord>();
                if (insertedRecordUIDs != null && insertedRecordUIDs.Count > 0)
                {
                    //  寫入「新增」的 Log
                    List<UDT.SCAttendExt> insertedRecords = Access.Select<UDT.SCAttendExt>(insertedRecordUIDs);
                    Dictionary<string, UDT.SCAttendExt> dicInsertedRecords = new Dictionary<string, SCAttendExt>();
                    if (insertedRecords.Count > 0)
                        dicInsertedRecords = insertedRecords.ToDictionary(x => x.UID);
                    CourseRecord courseRecord = Course.SelectByID(PrimaryKey);
                    studentRecords = K12.Data.Student.SelectByIDs(insertedRecords.Select(x => x.StudentID.ToString()));
                    Dictionary<string, StudentRecord> dicStudentRecords = new Dictionary<string, StudentRecord>();
                    if (studentRecords.Count > 0)
                        dicStudentRecords = studentRecords.ToDictionary(x => x.ID);
                    LogSaver logBatch = ApplicationLog.CreateLogSaverInstance();
                    foreach (string iRecords in dicInsertedRecords.Keys)
                    {
                        UDT.SCAttendExt insertedRecord = dicInsertedRecords[iRecords];
                        StudentRecord student = dicStudentRecords[insertedRecord.StudentID.ToString()];

                        StringBuilder sb = new StringBuilder();
                        sb.Append("學生「" + student.Name + "」,學號「" + student.StudentNumber + "」");
                        sb.AppendLine("被新增一筆「修課記錄」。");
                        sb.AppendLine("詳細資料:");
                        sb.Append("開課「" + courseRecord.Name + "」\n");
                        logBatch.AddBatch("管理學生修課.新增", "新增", "course", PrimaryKey, sb.ToString());
                    }
                    logBatch.LogBatch(true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
开发者ID:jungfengpaulwang,项目名称:EMBACore,代码行数:48,代码来源:Course_SCAttend.cs

示例3: btnSet_Click

        private void btnSet_Click(object sender, EventArgs e)
        {
            //1. 重設密碼登入,待實作。

            //2. 更新資料
            try
            {
                // update status
                if (this.targetScoreLock == null)
                {
                    this.targetScoreLock = new UDT.SubjectScoreLock();
                    this.targetScoreLock.SchoolYear = (int)this.nudSchoolYear.Value;
                    this.targetScoreLock.Semester = int.Parse(((SemesterItem)this.cboSemester.SelectedItem).Value);
                }

                this.targetScoreLock.IsLocked = this.chkIsLocked.Checked;
                List<ActiveRecord> recs = new List<ActiveRecord>();
                recs.Add(this.targetScoreLock);
                recs.SaveAll();
                string msg = string.Format("已 {0} {1} {2} 成績輸入設定。",
                    (this.chkIsLocked.Checked ? "鎖定" : "開放"),
                    this.nudSchoolYear.Value,
                    ((SemesterItem)this.cboSemester.SelectedItem).Name);

                //log
                FISCA.LogAgent.ApplicationLog.Log("成績輸入設定", "修改", "", "", msg);

                Util.ShowMsg(msg, "開放/鎖定成績輸入!");

            }
            catch (Exception ex)
            {
                string msg = string.Format("{0} {1} {2} 成績輸入設定時發生錯誤!",
                    (this.chkIsLocked.Checked ? "鎖定" : "開放"),
                    this.nudSchoolYear.Value,
                    ((SemesterItem)this.cboSemester.SelectedItem).Name);
                Util.ShowMsg("", "開放/鎖定成績輸入!");
            }

            //reload data ...
            this.GetLockedStatus();
        }
开发者ID:jungfengpaulwang,项目名称:EMBACore,代码行数:42,代码来源:SubjectScoreLockForm.cs

示例4: btnDelete_Click

        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.dgvData.SelectedRows.Count == 0)
            {
                MessageBox.Show("請選取項目(可複選)。");
                return;
            }
            if (MessageBox.Show("確定刪除?", "警告", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
                return;
            List<UDT.CSFaq> CSFaqs = new List<UDT.CSFaq>();
            foreach (DataGridViewRow row in this.dgvData.SelectedRows)
            {
                UDT.CSFaq CSFaq = row.Tag as UDT.CSFaq;

                CSFaq.Deleted = true;
                CSFaqs.Add(CSFaq);
            }
            CSFaqs.SaveAll();
            this.DGV_DataBinding();
        }
开发者ID:jungfengpaulwang,项目名称:EMBACourseSelection,代码行数:20,代码来源:frmFAQ.cs

示例5: ProcessRequest

            public override string ProcessRequest(int Year, Dictionary<string, Dictionary<string, string>> Data)
            {
                if (Year != 102 && this.successor != null)
                {
                    return this.successor.ProcessRequest(Year, Data);
                }
                else
                {
                    StringBuilder strLog = new StringBuilder();
                    List<UDT.Approach> ExistingRecords = new List<UDT.Approach>();
                    AccessHelper Access = new AccessHelper();

                    strLog.AppendLine("詳細資料:");

                    ExistingRecords = Access.Select<UDT.Approach>();
                    //  要新增的 Record
                    List<UDT.Approach> insertRecords = new List<UDT.Approach>();
                    //  要更新的 Record
                    List<UDT.Approach> updateRecords = new List<UDT.Approach>();
                    foreach (string key in Data.Keys)
                    {
                        //string id_number = Data[key]["身分證號"].Trim();
                        string q1_string = Data[key]["升學與就業情形"].Trim();
                        string q2_string = Data[key]["升學:就讀學校情形"].Trim();
                        string q3_string = Data[key]["升學:學制別"].Trim();
                        string q4_string = Data[key]["升學:入學方式"].Trim();
                        string q5_string = Data[key]["未升學未就業:動向"].Trim();
                        string q6_string = Data[key]["是否需要教育部協助"].Trim().Replace("1", "是").Replace("2", "否");
                        string memo = Data[key]["備註"].Trim();

                        strLog.AppendLine("填報學年度「" + Year + "」升學與就業情形「" + q1_string + "」升學:就讀學校情形「" + q2_string + "」升學:學制別「" + q3_string + "」升學:入學方式「" + q4_string + "」未升學未就業:動向「" + q5_string + "」是否需要教育部協助「" + q6_string + "」備註「" + memo + "」");

                        int q2_int;
                        int q3_int;
                        int q4_int;
                        int q5_int;

                        int student_id = int.Parse(key);

                        UDT.Approach record = new UDT.Approach();
                        IEnumerable<UDT.Approach> filterRecords = new List<UDT.Approach>();
                        filterRecords = ExistingRecords.Where(x => x.StudentID == student_id);

                        if (filterRecords.Count() > 0)
                        {
                            record = filterRecords.OrderByDescending(x => x.LastUpdateTime).ElementAt(0);
                            updateRecords.Add(record);
                        }
                        else
                        {
                            insertRecords.Add(record);
                        }

                        int q1 = int.Parse(q1_string);

                        record.StudentID = student_id;
                        record.SurveyYear = Year;
                        record.Q1 = q1;

                        if (int.TryParse(q2_string, out q2_int))
                            record.Q2 = q2_int;
                        else
                            record.Q2 = null;

                        if (int.TryParse(q3_string, out q3_int))
                            record.Q3 = q3_int;
                        else
                            record.Q3 = null;

                        if (int.TryParse(q4_string, out q4_int))
                            record.Q4 = q4_int;
                        else
                            record.Q4 = null;

                        if (int.TryParse(q5_string, out q5_int))
                            record.Q5 = q5_int;
                        else
                            record.Q5 = null;

                        record.Q6 = q6_string;
                        record.Memo = memo;

                        record.LastUpdateTime = DateTime.Now;
                    }

                    //  新增
                    List<string> insertedIDs = new List<string>();
                    try
                    {
                        insertedIDs = insertRecords.SaveAll();
                    }
                    catch (System.Exception e)
                    {
                        System.Windows.Forms.MessageBox.Show(e.Message);
                        return e.Message;
                    }
                    //  更新
                    List<string> updatedIDs = new List<string>();
                    try
                    {
//.........这里部分代码省略.........
开发者ID:ischool-desktop,项目名称:KHJH_CentralOffice,代码行数:101,代码来源:ApproachSave.cs

示例6: btnSet_Click


//.........这里部分代码省略.........
                o.TotalNo = row.Cells[6].Value + "";
                o.FillNo = row.Cells[7].Value + "";
                o.SubjectName = oo.SubjectName;
                o.ClassName = oo.ClassName;
                o.Status = row.Cells[8].Value + "";
                o.SubjectID = row.Cells[1].Tag + "";

                DateTime survey_date_begin = DateTime.Today;
                DateTime survey_date_end = DateTime.Today;
                List<string> survey_dates = new List<string>();

                if (DateTime.TryParse(row.Cells[4].Value + "", out survey_date_begin))
                    survey_dates.Add(survey_date_begin.ToShortDateString());
                if (DateTime.TryParse(row.Cells[5].Value + "", out survey_date_end))
                    survey_dates.Add(survey_date_end.ToShortDateString());

                survey_dates = survey_dates.Distinct().ToList();

                o.SurveyDate = string.Join("~", survey_dates);

                backup_lists.Add(o);
            }
            Task task = Task.Factory.StartNew(()=>
            {
                List<UDT.Reply> Replys = Access.Select<UDT.Reply>("status = 1");
                List<UDT.TeacherStatistics> TeacherStatistics = Access.Select<UDT.TeacherStatistics>();
                Dictionary<string, UDT.TeacherStatistics> dicTeacherStatistics = new Dictionary<string, UDT.TeacherStatistics>();
                if (TeacherStatistics.Count > 0)
                    dicTeacherStatistics = TeacherStatistics.ToDictionary(x => x.CourseID + "-" + x.TeacherID + "-" + x.SchoolYear + "-" + x.Semester);

                List<UDT.TeacherStatistics> nTeacherStatistics = new List<UDT.TeacherStatistics>();
                foreach (dynamic o in backup_lists)
                {
                    //if (o.Status == "無效")
                    //    continue;

                    BusinessLogic.TeacherStatistics cTeacherStatistics = new BusinessLogic.TeacherStatistics(o.CourseID, o.TeacherID);
                    bool can_save = false;
                    if (cTeacherStatistics.Survey == null)
                        continue;

                    cTeacherStatistics.SchoolYear = school_year.ToString();
                    cTeacherStatistics.Semester = semester.ToString();
                    cTeacherStatistics.CourseName = o.CourseName;
                    cTeacherStatistics.SubjectName = o.SubjectName;
                    cTeacherStatistics.ClassName = o.ClassName;
                    cTeacherStatistics.TeacherName = o.TeacherName;
                    cTeacherStatistics.SubjectCode = o.SubjectCode;
                    cTeacherStatistics.NewSubjectCode = o.NewSubjectCode;
                    cTeacherStatistics.FeedBackCount = o.FillNo;
                    cTeacherStatistics.CSAttendCount = o.TotalNo;
                    cTeacherStatistics.CourseID = o.CourseID;
                    cTeacherStatistics.SubjectID = o.SubjectID;
                    cTeacherStatistics.TeacherID = o.TeacherID;
                    cTeacherStatistics.SurveyDate = o.SurveyDate;

                    foreach (UDT.Reply Reply in Replys)
                    {
                        if (Reply.SurveyID.ToString() != cTeacherStatistics.Survey.uSurvey.UID || Reply.CourseID.ToString() != o.CourseID || Reply.TeacherID.ToString() != o.TeacherID)
                            continue;

                        cTeacherStatistics.SetAnswer(Reply.Answer);
                        can_save = true;
                    }

                    string Statistics_List = cTeacherStatistics.ToString();
                    string key = o.CourseID + "-" + o.TeacherID;
                    UDT.TeacherStatistics oTeacherStatistic = new UDT.TeacherStatistics();
                    if (dicTeacherStatistics.ContainsKey(key + "-" + school_year + "-" + semester))
                        oTeacherStatistic = dicTeacherStatistics[key + "-" + school_year + "-" + semester];

                    oTeacherStatistic.CourseID = int.Parse(o.CourseID);
                    oTeacherStatistic.TeacherID = int.Parse(o.TeacherID);
                    oTeacherStatistic.SchoolYear = school_year;
                    oTeacherStatistic.Semester = semester;
                    oTeacherStatistic.StatisticsList = Statistics_List;
                    oTeacherStatistic.TimeStamp = DateTime.Now;

                    if (can_save)
                        nTeacherStatistics.Add(oTeacherStatistic);
                }
                nTeacherStatistics.SaveAll();
            });

            task.ContinueWith((y) =>
            {
                if (y.Exception != null)
                {
                    MessageBox.Show(y.Exception.InnerException.Message);
                    goto TheEnd;
                }

                this.DGV_DataBinding();
                MessageBox.Show("計算完畢。");
                TheEnd:
                this.circularProgress.IsRunning = false;
                this.circularProgress.Visible = false;
                this.btnSet.Enabled = true;
            }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
        }
开发者ID:jungfengpaulwang,项目名称:EMBATeachingEvaluation,代码行数:101,代码来源:frmEvaluationCalc.cs

示例7: btnSave_Click

        private void btnSave_Click(object sender, EventArgs e)
        {
            btnSave.Enabled = false;

            // 讀取畫面是否允許設定
            Dictionary<string, bool?> appDict = new Dictionary<string, bool?>();

            try 
            {
                foreach (DataGridViewRow drv in dgData.Rows)
                {
                    string uid = drv.Tag.ToString();

                    if (!string.IsNullOrEmpty(uid))
                    {
                        bool? bb;
                        string strB = "";
                        bb = null;
                        
                        if (drv.Cells[colApprove.Index].Value !=null)
                            strB=drv.Cells[colApprove.Index].Value.ToString();

                        if (strB == "是")
                            bb = true;
                        
                        if (strB == "否")
                            bb = false;                        

                        if (!appDict.ContainsKey(uid))
                            appDict.Add(uid, bb);
                    }
                }

                List<udtNoticeApprove> updateNoticeApproveList = new List<udtNoticeApprove>();
                // 修改是否引許相關資料
                foreach (string key in appDict.Keys)
                {
                    bool? newB = appDict[key];

                    if (_NoticeApproveDict.ContainsKey(key))
                    {
                        foreach (udtNoticeApprove nData in _NoticeApproveDict[key])
                        {
                            // 相同
                            if (nData.Approve != newB)
                            {
                                nData.Approve = newB;
                                updateNoticeApproveList.Add(nData);
                            }
                        }
                    }
                }

                // 更新資料
                if (updateNoticeApproveList.Count > 0)
                    updateNoticeApproveList.SaveAll();

                MsgBox.Show("儲存完成.");
                this.Close();

            }catch( Exception ex)
            {
                MsgBox.Show("儲存失敗," + ex.Message);
            }            
        }
开发者ID:ischool-desktop,项目名称:Notice,代码行数:65,代码来源:NoticeApproveForm.cs

示例8: WriteChongTongCourse

        private void WriteChongTongCourse(decimal school_year, string semester, List<CourseSection> CourseSections)
        {
            if (CourseSections.Count == 0)
                return;

            string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
            List<UDT.ConflictCourse> conflict_courses = new List<UDT.ConflictCourse>();
            Dictionary<int, Dictionary<string, List<CourseSection>>> dicCourseSections = new Dictionary<int, Dictionary<string, List<CourseSection>>>();
            Dictionary<int, CourseSection> dicCourseIDs = new Dictionary<int, CourseSection>();
            CourseSections.ForEach((x) =>
            {
                if (!dicCourseIDs.ContainsKey(x.CourseID))
                    dicCourseIDs.Add(x.CourseID, x);
            });
            CourseSections.ForEach((x) =>
            {
                if (!dicCourseSections.ContainsKey(x.CourseID))
                    dicCourseSections.Add(x.CourseID, new Dictionary<string,List<CourseSection>>());

                if (!dicCourseSections[x.CourseID].ContainsKey(x.BeginTime.ToShortDateString()))
                    dicCourseSections[x.CourseID].Add(x.BeginTime.ToShortDateString(), new List<CourseSection>());

                dicCourseSections[x.CourseID][x.BeginTime.ToShortDateString()].Add(x);
            });
            foreach (int CourseID in dicCourseSections.Keys)
            {
                foreach (string date in dicCourseSections[CourseID].Keys)
                {
                    CourseSection A = dicCourseIDs[CourseID];
                    Dictionary<int, List<CourseSection>> dicBs = new Dictionary<int, List<CourseSection>>();
                    foreach (CourseSection x in dicCourseSections[CourseID][date])
                    {
                        List<CourseSection> ChongTongCourseSections = CourseSections.Where(y => (y.SubjectID != x.SubjectID && y.CourseID != x.CourseID && x.BeginTime.ToShortDateString() == y.BeginTime.ToShortDateString())).Where(y => ((x.BeginTime <= y.BeginTime && x.EndTime >= y.EndTime) || (x.BeginTime >= y.BeginTime && x.BeginTime <= y.EndTime) || (x.EndTime >= y.BeginTime && x.EndTime <= y.EndTime))).ToList();

                        foreach (CourseSection cs in ChongTongCourseSections)
                        {
                            if (!dicBs.ContainsKey(cs.CourseID))
                                dicBs.Add(cs.CourseID, new List<CourseSection>());

                            dicBs[cs.CourseID].Add(cs);
                        }
                    }
                    foreach (int course_id in dicBs.Keys)
                    {
                        UDT.ConflictCourse conflict_course = new UDT.ConflictCourse();

                        CourseSection B = dicBs[course_id].ElementAt(0);

                        DateTime begin_time = DateTime.MaxValue;
                        DateTime end_time = DateTime.MinValue;

                        if (dicBs[course_id].Min(y => y.BeginTime) < begin_time)
                            begin_time = dicBs[course_id].Min(y => y.BeginTime);
                        if (dicBs[course_id].Max(y => y.EndTime) > end_time)
                            end_time = dicBs[course_id].Max(y => y.EndTime);

                        //if (A.CourseID != 649)
                        //    continue;

                        conflict_course.SchoolYear = A.SchoolYear;
                        conflict_course.Semester = A.Semester;
                        conflict_course.CourseID_A = A.CourseID;
                        conflict_course.CourseName_A = A.CourseName;
                        conflict_course.CourseID_B = B.CourseID;
                        conflict_course.CourseName_B = B.CourseName;
                        conflict_course.ConflictDate = date;
                        conflict_course.ConflictWeek = Day[Convert.ToInt16(DateTime.Parse(date).DayOfWeek)];
                        conflict_course.IsSameSubject = false;
                        conflict_course.ConflictTime = begin_time.ToString("HH:mm") + "~" + end_time.ToString("HH:mm");

                        conflict_courses.Add(conflict_course);
                    }
                }
            }
            conflict_courses.SaveAll();
        }
开发者ID:jungfengpaulwang,项目名称:EMBACourseSelection,代码行数:76,代码来源:ConflictCourseManagement.cs

示例9: OnSaveData

        protected override void OnSaveData()
        {
            //SCAttend.SCAttendID = row["sc_attend_id"].ToString();
            //SCAttend.StudentID = row["ref_student_id"].ToString();
            //SCAttend.Group = row["report_group"].ToString();
            //SCAttend.CourseID = PrimaryKey;
            //SCAttend.IsCancel = isCancel;
            //  1、先取得 SCAttendExt 物件
            List<dynamic> SCAttendExts = new List<dynamic>();
            foreach (DataGridViewRow row in this.dgvData.Rows)
            {
                if (row.IsNewRow)
                    continue;

                dynamic SCAttend = (row.Tag as dynamic);
                SCAttendExts.Add(SCAttend);
            }
            if (SCAttendExts.Count == 0)
                return;

            List<string> studentIDs = new List<string>();
            foreach (dynamic SCAttend in SCAttendExts)
                studentIDs.Add(SCAttend.StudentID);

            List<SCAttendExt> scattendExts = Access.Select<SCAttendExt>(string.Format("ref_student_id in ({0}) And ref_course_id='{1}'", string.Join(",", studentIDs), PrimaryKey));
            List<SCAttendExt> originalExts = new List<SCAttendExt>();
            if (scattendExts != null && scattendExts.Count>0)
                scattendExts.ForEach(x => originalExts.Add(x.Clone()));
            //  2、更新 SCAttendExt 物件內容
            List<SCAttendExt> updateRecords = new List<SCAttendExt>();
            foreach (DataGridViewRow row in this.dgvData.Rows)
            {
                if (row.IsNewRow)
                    continue;

                dynamic SCAttend = (row.Tag as dynamic);

                IEnumerable<SCAttendExt> SCAttendExtRecords = scattendExts.Where(x => (x.UID == SCAttend.SCAttendID));

                SCAttendExt scattendExtRecord = SCAttendExtRecords.ElementAt(0);

                scattendExtRecord.Group = (row.Cells["ReportGroup"].Value == null ? "" : row.Cells["ReportGroup"].Value.ToString());
                bool isCancel = false;
                bool.TryParse((row.Cells["IsCancel"].Value == null ? "" : row.Cells["IsCancel"].Value.ToString()), out isCancel);
                scattendExtRecord.IsCancel = isCancel;

                if (scattendExtRecord.RecordStatus == FISCA.UDT.RecordStatus.Update)
                    updateRecords.Add(scattendExtRecord);
            }

            List<string> updatedRecordUIDs = updateRecords.SaveAll();
            BatchLogAgent batchLogAgent = new BatchLogAgent();
            if (updatedRecordUIDs != null && updatedRecordUIDs.Count > 0)
            {
                List<SCAttendExt> updatedRecords = Access.Select<SCAttendExt>(updatedRecordUIDs);
                Dictionary<string, UDT.SCAttendExt> dicUpdatedRecords = new Dictionary<string, SCAttendExt>();
                if (updatedRecords.Count > 0)
                    dicUpdatedRecords = updatedRecords.ToDictionary(x => x.UID);
                CourseRecord courseRecord = Course.SelectByID(PrimaryKey);
                List<StudentRecord> studentRecords = K12.Data.Student.SelectByIDs(updatedRecords.Select(x => x.StudentID.ToString()));
                Dictionary<string, StudentRecord> dicStudentRecords = new Dictionary<string, StudentRecord>();
                if (studentRecords.Count > 0)
                    dicStudentRecords = studentRecords.ToDictionary(x => x.ID);
                foreach (string iRecords in dicUpdatedRecords.Keys)
                {
                    UDT.SCAttendExt updatedRecord = dicUpdatedRecords[iRecords];
                    StudentRecord student = dicStudentRecords[updatedRecord.StudentID.ToString()];
                    IEnumerable<UDT.SCAttendExt> originalRecords = originalExts.Where(x => (x.StudentID.ToString() == student.ID && x.CourseID == updatedRecord.CourseID));

                    LogAgent log = new LogAgent();
                    this.AddLog(log, originalRecords.ElementAt(0));
                    this.AddLog(log, updatedRecord);
                    batchLogAgent.AddLogAgent(log);
                    //StringBuilder sb = new StringBuilder();
                    //sb.Append("學生「" + student.Name + "」,學號「" + student.StudentNumber + "」");
                    //sb.AppendLine("被修改一筆「修課記錄」。");
                    //sb.AppendLine("詳細資料:");
                    //sb.Append("開課「" + courseRecord.Name + "」\n");
                    //if (!updatedRecord.Group.Equals(originalRecords.ElementAt(0).Group))
                    //    sb.Append("報告小組由「" + originalRecords.ElementAt(0).Group + "」改為「" + updatedRecord.Group + "」\n");
                    //if (!updatedRecord.IsCancel.Equals(originalRecords.ElementAt(0).IsCancel))
                    //    sb.Append("停修由「" + originalRecords.ElementAt(0).IsCancel + "」改為「" + updatedRecord.IsCancel + "」\n");
                }
            }
            if (batchLogAgent.Count > 0)
                batchLogAgent.Save();

            LoadData();

            SaveButtonVisible = false;
            CancelButtonVisible = false;
        }
开发者ID:jungfengpaulwang,项目名称:EMBACore,代码行数:92,代码来源:Course_SCAttend.cs

示例10: Save_Click

        private void Save_Click(object sender, EventArgs e)
        {
            string graduationRequirementName = this.txtName.Text.Trim();
            Access = new AccessHelper();

            //  所有的「畢業條件」
            List<GraduationRequirement> graduationRequirements = Access.Select<GraduationRequirement>();

            //  若新增的「畢業條件」名稱已存在,則發出警告並跳出程式
            if (graduationRequirements.Where(x => (x.Name == graduationRequirementName && x.DepartmentGroupID == _DepartmentGroupID)).Count() > 0)
            {
                MessageBox.Show("同名之畢業條件已存在!");
                return;
            }

            //  待新增的「畢業條件」
            GraduationRequirement graduationRequirement = new GraduationRequirement();

            //  檢查是否複製
            ComboItem item = (ComboItem)this.cboGraduationRequirementRule.SelectedItem;
            if (item == null || item.Tag == null)
            {
                //  不複製
                graduationRequirement.Name = graduationRequirementName;
                graduationRequirement.DepartmentGroupID = _DepartmentGroupID;
                graduationRequirement.RequiredCredit = 0;
                graduationRequirement.DepartmentCredit = 0;
                graduationRequirement.ElectiveCredit = 0;

                graduationRequirement.Save();
            }
            else
            {
                //  1、複製「畢業條件」
                GraduationRequirement oGraduationRequirement = (GraduationRequirement)item.Tag;

                graduationRequirement.Name = graduationRequirementName;
                graduationRequirement.DepartmentGroupID = _DepartmentGroupID;
                graduationRequirement.RequiredCredit = oGraduationRequirement.RequiredCredit;
                graduationRequirement.DepartmentCredit = oGraduationRequirement.DepartmentCredit;
                graduationRequirement.ElectiveCredit = oGraduationRequirement.ElectiveCredit;

                graduationRequirements = new List<GraduationRequirement>();
                graduationRequirements.Add(graduationRequirement);
                List<string> graduationRequirementIDs = graduationRequirements.SaveAll();
                //  2、複製「畢業應修科目清單」
                List<GraduationSubjectList> graduationSubjects = Access.Select<GraduationSubjectList>(string.Format("ref_graduation_requirement_id = {0}", oGraduationRequirement.UID));
                List<GraduationSubjectList> newGraduationSubjects = new List<GraduationSubjectList>();
                foreach(GraduationSubjectList graduationSubject in graduationSubjects)
                {
                    GraduationSubjectList newGraduationSubjectList = new GraduationSubjectList();

                    newGraduationSubjectList.GraduationRequirementID = int.Parse(graduationRequirementIDs[0]);
                    newGraduationSubjectList.SubjectID = graduationSubject.SubjectID;
                    newGraduationSubjectList.Prerequisites = graduationSubject.Prerequisites;

                    newGraduationSubjects.Add(newGraduationSubjectList);
                }
                newGraduationSubjects.SaveAll();
                //  3、複製「畢業應修科目群組應修科目數及應修學分數」--待討論,建議不做

                //  4、重繪「指定畢業條件」選單
                //EMBACore.Initialization.StudentInit.RedrawGraduationRequirementMenuButton();
            }

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
开发者ID:jungfengpaulwang,项目名称:EMBACore,代码行数:68,代码来源:GraduationRequirementRuleCreator.cs

示例11: Save_Click

        private void Save_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            try
            {
                string Err_Msg = string.Empty;

                string SurveyName = this.txtName.Text.Trim();

                if (string.IsNullOrEmpty(SurveyName))
                    Err_Msg += "請輸入評鑑樣版名稱。\n";

                if (!string.IsNullOrEmpty(Err_Msg))
                    throw new Exception(Err_Msg);

                //  所有的「評鑑樣版」
                List<UDT.Survey> Surveys = Access.Select<UDT.Survey>(string.Format(@"name='{0}'", SurveyName));
                //  若新增的「評鑑樣版」名稱已存在,則發出警告並跳出程式
                if ((this._Survey == null) && Surveys.Count() > 0)
                {
                    MessageBox.Show("同名之評鑑樣版已存在。");
                    this.DialogResult = System.Windows.Forms.DialogResult.None;
                    return;
                }
                //  若修改的「評鑑樣版」名稱已存在,且該「評鑑樣版」的「uid」非待修改「評鑑樣版」所擁有,則發出警告並跳出程式
                if ((this._Survey != null) && Surveys.Where(x => x.UID != this._Survey.UID).Count() > 0)
                {
                    MessageBox.Show("同名之評鑑樣版已存在。");
                    this.DialogResult = System.Windows.Forms.DialogResult.None;
                    return;
                }

                //  修改「問卷」
                if (this._Survey != null)
                {
                    this._Survey.Name = this.txtName.Text.Trim();
                    this._Survey.Category = this.txtCategory.Text.Trim();
                    this._Survey.Description = this.txtDescription.Text.Trim();
                    this._Survey.Save();
                    this.Close();
                    return;
                }

                //  待新增的「問卷」
                UDT.Survey nSurvey = new UDT.Survey();

                nSurvey.Name = SurveyName;
                nSurvey.Category = this.txtCategory.Text.Trim();
                nSurvey.Description = this.txtDescription.Text.Trim();

                nSurvey.Save();

                //  檢查是否複製「題目」
                ComboItem item = (ComboItem)this.cboSurvey.SelectedItem;
                if (item == null || item.Tag == null)
                {
                    //  不複製
                    this.Close();
                    return;
                }
                else
                {
                    //  複製「題目」、「答案選項」、及「題目標題」
                    string SurveyID = ((UDT.Survey)item.Tag).UID;
                    List<UDT.Question> oQuestions = Access.Select<UDT.Question>(string.Format(@"ref_survey_id = {0}", SurveyID));
                    List<UDT.Question> nQuestions = new List<UDT.Question>();
                    foreach (UDT.Question oQuestion in oQuestions)
                    {
                        UDT.Question nQuestion = new UDT.Question();

                        nQuestion.SurveyID = int.Parse(nSurvey.UID);
                        nQuestion.Title = oQuestion.Title;
                        nQuestion.Type = oQuestion.Type;
                        nQuestion.IsRequired = oQuestion.IsRequired;
                        nQuestion.IsCase = oQuestion.IsCase;
                        nQuestion.IsSelfAssessment = oQuestion.IsSelfAssessment;
                        nQuestion.DisplayOrder = oQuestion.DisplayOrder;

                        nQuestions.Add(nQuestion);
                    }
                    nQuestions.SaveAll();
                    nQuestions = Access.Select<UDT.Question>(string.Format(@"ref_survey_id = {0}", nSurvey.UID));
                    List<UDT.QuestionOption> oQuestionOptions = new List<UDT.QuestionOption>();
                    List<UDT.QuestionOption> nQuestionOptions = new List<UDT.QuestionOption>();
                    if (oQuestions.Count > 0)
                        oQuestionOptions = Access.Select<UDT.QuestionOption>(string.Format(@"ref_question_id in ({0})", string.Join(",", oQuestions.Select(x => x.UID))));
                    foreach (UDT.QuestionOption oQuestionOption in oQuestionOptions)
                    {
                        UDT.Question oQuestion = oQuestions.Where(x => x.UID == oQuestionOption.QuestionID.ToString()).ElementAt(0);
                        UDT.Question nQuestion = nQuestions.Where(x => x.Title == oQuestion.Title).ElementAt(0);

                        UDT.QuestionOption nQuestionOption = new UDT.QuestionOption();
                        nQuestionOption.QuestionID = int.Parse(nQuestion.UID);
                        nQuestionOption.Title = oQuestionOption.Title;
                        nQuestionOption.DisplayOrder = oQuestionOption.DisplayOrder;

                        nQuestionOptions.Add(nQuestionOption);
                    }
                    nQuestionOptions.SaveAll();
                    List<UDT.QHRelation> oQHRelations = new List<UDT.QHRelation>();
//.........这里部分代码省略.........
开发者ID:jungfengpaulwang,项目名称:EMBATeachingEvaluation,代码行数:101,代码来源:SurveyCreator.cs

示例12: SaveUDT

        private void SaveUDT()
        {
            //  待刪除資料
            Dictionary<string, PaymentHistory> deleteRecords = new Dictionary<string, PaymentHistory>();
            //  待更新資料
            Dictionary<string, PaymentHistory> updateRecords = new Dictionary<string, PaymentHistory>();
            //  待新增資料
            List<PaymentHistory> insertRecords = new List<PaymentHistory>();
            //  學生資料
            K12.Data.StudentRecord studentRecord = K12.Data.Student.SelectByID(PrimaryKey);

            foreach (DataGridViewRow dataGridRow in this.dgvData.Rows)
            {
                if (dataGridRow.IsNewRow)
                    continue;

                PaymentHistory paymentHistoryRecord = (PaymentHistory)dataGridRow.Tag;

                if (paymentHistoryRecord == null)
                    paymentHistoryRecord = new PaymentHistory();

                //  學年度
                paymentHistoryRecord.SchoolYear = int.Parse(dataGridRow.Cells["SchoolYear"].Value.ToString());
                //  學期
                paymentHistoryRecord.Semester = int.Parse(SemesterItem.GetSemesterByName(dataGridRow.Cells["Semester"].Value.ToString()).Value);
                //  是否繳費
                bool isPaied = false;
                bool.TryParse(dataGridRow.Cells["IsPaied"].Value == null ? "" : dataGridRow.Cells["IsPaied"].Value.ToString(), out isPaied);
                paymentHistoryRecord.IsPaied = (isPaied ? 1 : 0);
                //  學生系統編號
                paymentHistoryRecord.StudentID = int.Parse(PrimaryKey);

                if (paymentHistoryRecord.RecordStatus == FISCA.UDT.RecordStatus.Insert)
                    insertRecords.Add(paymentHistoryRecord);
                else if (paymentHistoryRecord.RecordStatus == FISCA.UDT.RecordStatus.Update)
                    updateRecords.Add(paymentHistoryRecord.UID, paymentHistoryRecord);
            }

            IEnumerable<DataGridViewRow> dataGridViewRows = this.dgvData.Rows.Cast<DataGridViewRow>();
            foreach (string key in _dicUTDs.Keys)
            {
                if (dataGridViewRows.Where(x => x.Cells["UID"].Value != null).Where(x => (x.Cells["UID"].Value.ToString() == key)).Count() == 0)
                {
                    PaymentHistory paymentHistoryRecord = _dicUTDs[key];
                    paymentHistoryRecord.Deleted = true;
                    deleteRecords.Add(key, paymentHistoryRecord);
                }
            }

            //  更新日期
            if (insertRecords.Count>0)
                insertRecords.ForEach(x=>x.LastModifiedDate = System.DateTime.Now);

            List<string> insertedRecordUIDs = insertRecords.SaveAll();                    //  匯入「新增」資料
            List<PaymentHistory> insertedRecords = new List<PaymentHistory>();
            if (insertedRecordUIDs != null && insertedRecordUIDs.Count>0)
                insertedRecords = this.Access.Select<PaymentHistory>(insertedRecordUIDs);
            if (insertedRecords != null && insertedRecords.Count > 0)
            {
                //  寫入「新增」的 Log
                Dictionary<string, PaymentHistory> dicInsertedRecords = insertedRecords.ToDictionary(x => x.UID);
                foreach (string iRecords in dicInsertedRecords.Keys)
                {
                    PaymentHistory record = dicInsertedRecords[iRecords];

                    StringBuilder sb = new StringBuilder();

                    sb.Append("學生「" + studentRecord.Name + "」,學號「" + studentRecord.StudentNumber + "」");
                    sb.AppendLine("被新增一筆「繳費紀錄」。");
                    sb.AppendLine("詳細資料:");
                    sb.Append("學年度「" + record.SchoolYear + "」\n");
                    sb.Append("學期「" + record.Semester + "」\n");
                    sb.Append("繳費「" + IsPaidToString(record.IsPaied) + "」\n");

                    FISCA.LogAgent.ApplicationLog.Log("繳費記錄.學生", "新增", Log.LogTargetCategory.Student.ToString().ToLower(), record.StudentID.ToString(), sb.ToString());
                }
            }

            //  更新日期
            if (updateRecords.Count > 0)
                updateRecords.Values.ToList().ForEach(x => x.LastModifiedDate = System.DateTime.Now);

            List<string> updatedRecords = updateRecords.Values.SaveAll();   //  匯入「更新」資料
            List<PaymentHistory> updatedRecordss = new List<PaymentHistory>();
            if (updatedRecords != null && updatedRecords.Count>0)
                updatedRecordss = Access.Select<PaymentHistory>(updatedRecords);

            if (updatedRecordss != null && updatedRecordss.Count > 0)
            {
                //  批次寫入「修改」的 Log
                foreach (PaymentHistory uRecords in updatedRecordss)
                {
                    PaymentHistory record = uRecords;
                    PaymentHistory oldRecord = _dicUTDs[uRecords.UID];

                    StringBuilder sb = new StringBuilder();

                    sb.Append("學生「" + studentRecord.Name + "」,學號「" + studentRecord.StudentNumber + "」");
                    sb.AppendLine("被修改一筆「繳費記錄」。");
                    sb.AppendLine("詳細資料:");
//.........这里部分代码省略.........
开发者ID:jungfengpaulwang,项目名称:EMBACore,代码行数:101,代码来源:Student_PaymentHistory.cs

示例13: Import


//.........这里部分代码省略.........
                    filterRecords = allSubjectSemesterScoreRecords.Where(x => (x.SchoolYear.HasValue ? x.SchoolYear.Value.ToString() : "").Trim() == (string.IsNullOrEmpty(school_year) ? "" : int.Parse(school_year).ToString())).Where(x => (x.Semester.HasValue ? x.Semester.ToString() : "").Trim() == (string.IsNullOrEmpty(semester) ? "" : int.Parse(semester).ToString())).Where(x => x.SubjectCode.Trim().ToUpper() == subject_code.ToUpper()).Where(x => x.StudentID.ToString() == dicStudent_Numbers[student_number.ToUpper()]);
                }
                else
                {
                    //  鍵值為:學年度+學期+學號+課號
                    filterRecords = allSubjectSemesterScoreRecords.Where(x => (x.SchoolYear.HasValue ? x.SchoolYear.Value.ToString() : "").Trim() == (string.IsNullOrEmpty(school_year) ? "" : int.Parse(school_year).ToString())).Where(x => (x.Semester.HasValue ? x.Semester.ToString() : "").Trim() == (string.IsNullOrEmpty(semester) ? "" : int.Parse(semester).ToString())).Where(x => x.NewSubjectCode.Trim().ToUpper() == new_subject_code.ToUpper()).Where(x => x.StudentID.ToString() == dicStudent_Numbers[student_number.ToUpper()]);
                }
                if (filterRecords.Count() > 0)
                    record = filterRecords.ElementAt(0);

                if (mOption.SelectedFields.Contains("等第成績") && !string.IsNullOrWhiteSpace(row.GetValue("等第成績")))
                    record.Score = row.GetValue("等第成績").Trim();

                int intSchoolyear = 0;
                int.TryParse(school_year, out intSchoolyear);
                if (!string.IsNullOrEmpty(school_year))
                    record.SchoolYear = intSchoolyear;
                int intSemester = 0;
                int.TryParse(semester, out intSemester);
                if (!string.IsNullOrEmpty(semester))
                    record.Semester = intSemester;

                //  「開課」系統編號暫不寫入
                //record.CourseID = int.Parse(filterDataRows.ElementAt(0)["course_id"] + "");

                if (mOption.SelectedFields.Contains("學分數") && !string.IsNullOrWhiteSpace(row.GetValue("學分數")))
                    record.Credit = int.Parse(row.GetValue("學分數").Trim());

                if (mOption.SelectedFields.Contains("取得學分") && !string.IsNullOrWhiteSpace(row.GetValue("取得學分")))
                    record.IsPass = (row.GetValue("取得學分").Trim() == "是" ? true : false);

                if (mOption.SelectedFields.Contains("必選修") && !string.IsNullOrWhiteSpace(row.GetValue("必選修")))
                    record.IsRequired = (row.GetValue("必選修") == "必修" ? true : false);

                if (keyField == "課號")
                {
                    record.NewSubjectCode = new_subject_code;

                    if (mOption.SelectedFields.Contains("課程識別碼") && !string.IsNullOrEmpty(subject_code))
                        record.SubjectCode = subject_code;
                }
                else
                {
                    record.SubjectCode = subject_code;

                    if (mOption.SelectedFields.Contains("課號") && !string.IsNullOrEmpty(new_subject_code))
                        record.NewSubjectCode = new_subject_code;
                }

                if (mOption.SelectedFields.Contains("備註") && !string.IsNullOrWhiteSpace(row.GetValue("備註")))
                    record.Remark = row.GetValue("備註").Trim();

                if (mOption.SelectedFields.Contains("抵免課程") && !string.IsNullOrWhiteSpace(row.GetValue("抵免課程")))
                    record.OffsetCourse = row.GetValue("抵免課程").Trim();

                if (!string.IsNullOrEmpty(course_id))
                    record.CourseID = int.Parse(course_id);

                record.StudentID = int.Parse(studentID);
                record.SubjectID = int.Parse(dicSubjectIDs[(keyField == "課程識別碼" ? subject_code : new_subject_code)]);

                if (mOption.SelectedFields.Contains("課程名稱") && !string.IsNullOrEmpty(subject_name))
                    record.SubjectName = subject_name;

                if (dicClass_Names.ContainsKey(studentID + "_" + (keyField == "課程識別碼" ? subject_code : new_subject_code)))
                    record.CourseID = int.Parse(dicClass_Names[studentID + "_" + (keyField == "課程識別碼" ? subject_code : new_subject_code)]);

                if (record.RecordStatus == RecordStatus.Insert)
                    insertRecords.Add(record);
                if (record.RecordStatus == RecordStatus.Update)
                    updateRecords.Add(record);
            }
            List<string> insertedRecordIDs = new List<string>();
            try
            {
                insertedRecordIDs = insertRecords.SaveAll();
            }
            catch (System.Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
                return e.Message;
            }
            List<string> updatedRecordIDs = new List<string>();
            try
            {
                updatedRecordIDs = updateRecords.SaveAll();
            }
            catch (System.Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
                return e.Message;
            }
            //  RaiseEvent
            if (insertedRecordIDs.Count > 0 || updateRecords.Count > 0)
            {
                IEnumerable<string> uids = insertedRecordIDs.Union(updatedRecordIDs);
                UDT.SubjectSemesterScore.RaiseAfterUpdateEvent(this, new ParameterEventArgs(uids));
            }
            return string.Empty;
        }
开发者ID:jungfengpaulwang,项目名称:EMBACore,代码行数:101,代码来源:SubjectSemesterScore_Import.cs

示例14: Save_Click

        private void Save_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("確定發佈?若您選擇「確定」,「選課結果」將加入至「學生修課」。若不確定,請按「取消」。", "警告", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
                return;
            this.circularProgress.IsRunning = true;
            this.circularProgress.Visible = true;
            int item = 2;
            try
            {
                Task task = Task.Factory.StartNew(() =>
                {
                    List<UDT.CSAttendSnapshot> CSAttendSnapshots = Access.Select<UDT.CSAttendSnapshot>(string.Format("school_year = {0} and semester = {1} and item = {2}", this.SchoolYear, this.Semester, item));
                    if (CSAttendSnapshots.Count == 0)
                        throw new Exception("無資料可發佈。");

                    List<UDT.SCAttendExt> SCAttendExts = new List<UDT.SCAttendExt>();
                    DataTable dataTable = Query.Select(string.Format("select se.uid, se.ref_student_id, se.ref_course_id, se.report_group, se.is_cancel, se.seat_x, se.seat_y from $ischool.emba.scattend_ext as se join course on course.id=se.ref_course_id where course.school_year={0} and course.semester={1}", this.SchoolYear, this.Semester));
                    List<string> oSCAttendExts = new List<string>();
                    foreach (DataRow row in dataTable.Rows)
                    {
                        string key = row["ref_student_id"] + "-" + row["ref_course_id"];
                        oSCAttendExts.Add(key);
                    }
                    Dictionary<string, UDT.CSAttendSnapshot> dicCSAttendSnapshots = new Dictionary<string, UDT.CSAttendSnapshot>();
                    foreach(UDT.CSAttendSnapshot CSAttendSnapshot in CSAttendSnapshots)
                    {
                        string key = CSAttendSnapshot.StudentID + "-" + CSAttendSnapshot.CourseID;

                        if (!oSCAttendExts.Contains(key))
                        {
                            UDT.SCAttendExt SCAttendExt = new UDT.SCAttendExt();

                            SCAttendExt.CourseID = CSAttendSnapshot.CourseID;
                            SCAttendExt.StudentID = CSAttendSnapshot.StudentID;

                            SCAttendExts.Add(SCAttendExt);
                        }
                    }
                    SCAttendExts.SaveAll();
                });
                task.ContinueWith((x) =>
                {
                    this.circularProgress.IsRunning = false;
                    this.circularProgress.Visible = false;

                    if (x.Exception != null)
                        MessageBox.Show(x.Exception.InnerException.Message);
                    else
                        MessageBox.Show("發佈完成。");
                }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
            }
            catch (Exception ex)
            {
                this.circularProgress.IsRunning = false;
                this.circularProgress.Visible = false;
                MessageBox.Show(ex.Message);
                return;
            }
        }
开发者ID:jungfengpaulwang,项目名称:EMBACourseSelection,代码行数:59,代码来源:frmCSAttendToCourseExt.cs

示例15: pay_btn_Click


//.........这里部分代码省略.........
            //List<string> newStudentNumberList = new List<string>();
            int nowSet = 0;
            foreach (NewStudentRecord var in students)
            {
                MotherForm.SetStatusBarMessage("正在讀取校車資料庫", nowSet++ * 10 / students.Count);
                if (!newStudentIDList.Contains(var.UID))
                {
                    newStudentIDList.Add(var.UID);
                    //newStudentNumberList.Add(var.Number);
                }
            }

            List<PaymentDetail> Studentdetails = PaymentDetail.GetByTarget("NewStudent", newStudentIDList);
            //List<PaymentDetail> Studentdetails = PaymentDetail.GetAll();
            List<StudentByBus> _Source = new List<StudentByBus>();
            List<StudentByBus> StudentByBuses = StudentByBusDAO.SelectByBusYearAndTimeNameAndStudntList(int.Parse(this.cboYear.Text), this.cboRange.Text, newStudentIDList);
            Dictionary<string, StudentByBus> EveryStudentByBuses = new Dictionary<string,StudentByBus>();
            nowSet = 0;
            foreach (StudentByBus var in StudentByBuses)
            {
                MotherForm.SetStatusBarMessage("正在讀取校車資料庫", 10 + nowSet++ * 40 / StudentByBuses.Count);
                if (!EveryStudentByBuses.ContainsKey(var.StudentID))
                    EveryStudentByBuses.Add(var.StudentID, var);
            }

            DateTime day;

            nowSet = 0;

            foreach (PaymentDetail pd in Studentdetails)
            {
                MotherForm.SetStatusBarMessage("正在更新校車資料庫", 50 + nowSet++ * 50 / Studentdetails.Count);
                //List<StudentByBus> StudentByBuses = StudentByBusDAO.SelectByStudntID(pd.Extensions["MergeField::學號"]);

                if (!EveryStudentByBuses.ContainsKey(pd.RefTargetID))
                    continue;

                StudentByBus sbb = EveryStudentByBuses[pd.RefTargetID];
                //if (pd.Extensions["MergeField::學號"] == "39002" || pd.Extensions["MergeField::學號"] == "39001")
                //    nowSet = nowSet;
                if (sbb.PayStatus == true)
                    continue;

                pd.FillHistories();
                IList<PaymentHistory> historyss = pd.Histories;
                foreach (PaymentHistory history in historyss)
                {
                    if (history.Receipt.Cancelled)
                    {
                        if (DateTime.TryParse(history.PayDate.ToString(), out day))
                        {
                            //foreach (StudentByBus sbb in StudentByBuses)
                            //{
                            if (sbb.SchoolYear == int.Parse(pd.Extensions["校車收費年度"]) && sbb.BusRangeName == pd.Extensions["校車收費名稱"])
                                {
                                    if (sbb.comment != "改單:原為" + history.Receipt.Extensions["MergeField::代碼"] + " " + history.Receipt.Extensions["MergeField::站名"] + ",金額為" + history.Receipt.Amount)
                                    {
                                        sbb.PayStatus = true;
                                        sbb.PayDate = DateTime.Parse(history.PayDate.ToString());
                                        sbb.comment += "改單:原為" + history.Receipt.Extensions["MergeField::代碼"] + " " + history.Receipt.Extensions["MergeField::站名"] + ",金額為" + history.Receipt.Amount;
                                        _Source.Add(sbb);
                                    }
                                    break;
                                }
                            //}
                        }
                        else
                            continue;
                    }
                    else
                    {
                        if (DateTime.TryParse(history.PayDate.ToString(), out day))
                        {
                            //foreach (StudentByBus sbb in StudentByBuses)
                            //{
                                if (sbb.SchoolYear == int.Parse(pd.Extensions["校車收費年度"]) && sbb.BusRangeName == pd.Extensions["校車收費名稱"])
                                {
                                    if (sbb.PayStatus == false || sbb.PayDate != DateTime.Parse(history.PayDate.ToString()))
                                    {
                                        sbb.PayStatus = true;
                                        sbb.PayDate = DateTime.Parse(history.PayDate.ToString());
                                        if (history.Receipt.PaidAmount != sbb.BusMoney)
                                            sbb.comment = "繳費金額為" + history.Receipt.PaidAmount.ToString();
                                        _Source.Add(sbb);
                                    }
                                    break;
                                }
                            //}
                        }
                        else
                            continue;
                    }
                }
            }
            if (_Source.Count > 0)
                _Source.SaveAll();

            MotherForm.SetStatusBarMessage("校車對帳資料完成", 100);
            MessageBox.Show("已新增 " + _Source.Count + " 筆記錄,校車對帳資料完成!");
        }
开发者ID:kobeaaron110,项目名称:mdhs,代码行数:101,代码来源:NewStudentBus.cs


注:本文中的List.SaveAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。