/// <summary>
 /// 依年級進行排序
 /// </summary>
 private int SortDTClub(DTClub dt1, DTClub dt2)
 {
     return dt1.GradeYear.CompareTo(dt2.GradeYear);
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (IsDataValidity())
            {
                #region 資料正確,進行儲存
                List<DTClub> DTClubList = new List<DTClub>();
                foreach (DataGridViewRow each in dgvTimes.Rows)
                {
                    string Grade = "" + each.Cells[chGradeYear.Index].Value;
                    string Start = "" + each.Cells[chStartTime.Index].Value;
                    string End = "" + each.Cells[chEndTime.Index].Value;

                    DTClub dt = new DTClub();

                    dt.GradeYear = int.Parse(Grade);

                    if (!string.IsNullOrEmpty(Start))
                    {
                        dt.Start = DateTime.Parse(Start);
                    }
                    if (!string.IsNullOrEmpty(End))
                    {
                        dt.End = DateTime.Parse(End);
                    }
                    DTClubList.Add(dt);
                }

                try
                {
                    _AccessHelper.InsertValues(DTClubList);
                    _AccessHelper.DeletedValues(Low_DTClubList);

                    DTClubList.Sort(SortDTClub);
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("已修改开放选课时间");
                    foreach (DTClub each in DTClubList)
                    {
                        string start = each.Start.HasValue ? each.Start.Value.ToString("yyyy/MM/dd HH:mm") : "";
                        string end = each.End.HasValue ? each.End.Value.ToString("yyyy/MM/dd HH:mm") : "";
                        sb.AppendLine(string.Format("「{0}」年级:开始时间「{1}」结束时间「{2}」", each.GradeYear, start, end));
                    }

                    FISCA.LogAgent.ApplicationLog.Log("拓展性课程", "修改选课时间", sb.ToString());
                }
                catch (Exception ex)
                {
                    MsgBox.Show("储存失败!!\n" + ex.Message);
                    SmartSchool.ErrorReporting.ReportingService.ReportException(ex);
                    return;
                }
                MsgBox.Show("储存成功!!");
                this.Close();

                #endregion
            }
            else
            {
                MsgBox.Show("画面中含有不正确资料。");
            }
        }