private void cboConfigure_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cboConfigure.SelectedIndex == cboConfigure.Items.Count - 1)
     {
         //新增
         btnSaveConfig.Enabled = btnPrint.Enabled = false;
         NewConfigure dialog = new NewConfigure();
         if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             Configure = new Configure();
             Configure.Name = dialog.ConfigName;
             Configure.Template = dialog.Template;
             Configure.SubjectLimit = dialog.SubjectLimit;
             Configure.SchoolYear = _DefalutSchoolYear;
             Configure.Semester = _DefaultSemester;
             if (cboExam.Items.Count > 0)
                 Configure.ExamRecord = (ExamRecord)cboExam.Items[0];
             _Configures.Add(Configure);
             cboConfigure.Items.Insert(cboConfigure.SelectedIndex, Configure);
             cboConfigure.SelectedIndex = cboConfigure.SelectedIndex - 1;
             Configure.WithSchoolYearScore = dialog.WithSchoolYearScore;
             Configure.WithPrevSemesterScore = dialog.WithPrevSemesterScore;
             Configure.Encode();
             Configure.Save();
         }
         else
         {
             cboConfigure.SelectedIndex = -1;
         }
     }
     else
     {
         if (cboConfigure.SelectedIndex >= 0)
         {
             btnSaveConfig.Enabled = btnPrint.Enabled = true;
             Configure = _Configures[cboConfigure.SelectedIndex];
             if (Configure.Template == null)
                 Configure.Decode();
             if (!cboSchoolYear.Items.Contains(Configure.SchoolYear))
                 cboSchoolYear.Items.Add(Configure.SchoolYear);
             cboSchoolYear.Text = Configure.SchoolYear;
             cboSemester.Text = Configure.Semester;
             if (Configure.ExamRecord != null)
             {
                 foreach (var item in cboExam.Items)
                 {
                     if (((ExamRecord)item).ID == Configure.ExamRecord.ID)
                     {
                         cboExam.SelectedIndex = cboExam.Items.IndexOf(item);
                         break;
                     }
                 }
             }
             cboRefExam.SelectedIndex = -1;
             if (Configure.RefenceExamRecord != null)
             {
                 foreach (var item in cboRefExam.Items)
                 {
                     if (((ExamRecord)item).ID == Configure.RefenceExamRecord.ID)
                     {
                         cboRefExam.SelectedIndex = cboRefExam.Items.IndexOf(item);
                         break;
                     }
                 }
             }
             cboRankRilter.Text = Configure.RankFilterTagName;
             foreach (ListViewItem item in listViewEx1.Items)
             {
                 item.Checked = Configure.PrintSubjectList.Contains(item.Text);
             }
             cboTagRank1.Text = Configure.TagRank1TagName;
             foreach (ListViewItem item in listViewEx2.Items)
             {
                 item.Checked = Configure.TagRank1SubjectList.Contains(item.Text);
             }
             cboTagRank2.Text = Configure.TagRank2TagName;
             foreach (ListViewItem item in listViewEx3.Items)
             {
                 item.Checked = Configure.TagRank2SubjectList.Contains(item.Text);
             }
         }
         else
         {
             Configure = null;
             cboSchoolYear.SelectedIndex = -1;
             cboSemester.SelectedIndex = -1;
             cboExam.SelectedIndex = -1;
             cboRefExam.SelectedIndex = -1;
             cboRankRilter.SelectedIndex = -1;
             cboTagRank1.SelectedIndex = -1;
             cboTagRank2.SelectedIndex = -1;
             foreach (ListViewItem item in listViewEx1.Items)
             {
                 item.Checked = false;
             }
             foreach (ListViewItem item in listViewEx2.Items)
             {
                 item.Checked = false;
             }
             foreach (ListViewItem item in listViewEx3.Items)
             {
                 item.Checked = false;
             }
         }
     }
 }
Пример #2
0
 private void cboConfigure_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cboConfigure.SelectedIndex == cboConfigure.Items.Count - 1)
     {
         //新增
         btnSaveConfig.Enabled = btnPrint.Enabled = false;
         NewConfigure dialog = new NewConfigure();
         if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             Configure              = new Configure();
             Configure.Name         = dialog.ConfigName;
             Configure.Template     = dialog.Template;
             Configure.SubjectLimit = dialog.SubjectLimit;
             Configure.SchoolYear   = _DefalutSchoolYear;
             Configure.Semester     = _DefaultSemester;
             if (cboExam.Items.Count > 0)
             {
                 Configure.ExamRecord = (ExamRecord)cboExam.Items[0];
             }
             _Configures.Add(Configure);
             cboConfigure.Items.Insert(cboConfigure.SelectedIndex, Configure);
             cboConfigure.SelectedIndex      = cboConfigure.SelectedIndex - 1;
             Configure.WithSchoolYearScore   = dialog.WithSchoolYearScore;
             Configure.WithPrevSemesterScore = dialog.WithPrevSemesterScore;
             Configure.Encode();
             Configure.Save();
         }
         else
         {
             cboConfigure.SelectedIndex = -1;
         }
     }
     else
     {
         if (cboConfigure.SelectedIndex >= 0)
         {
             btnSaveConfig.Enabled = btnPrint.Enabled = true;
             Configure             = _Configures[cboConfigure.SelectedIndex];
             if (Configure.Template == null)
             {
                 Configure.Decode();
             }
             if (!cboSchoolYear.Items.Contains(Configure.SchoolYear))
             {
                 cboSchoolYear.Items.Add(Configure.SchoolYear);
             }
             cboSchoolYear.Text = Configure.SchoolYear;
             cboSemester.Text   = Configure.Semester;
             if (Configure.ExamRecord != null)
             {
                 foreach (var item in cboExam.Items)
                 {
                     if (((ExamRecord)item).ID == Configure.ExamRecord.ID)
                     {
                         cboExam.SelectedIndex = cboExam.Items.IndexOf(item);
                         break;
                     }
                 }
             }
             cboRefExam.SelectedIndex = -1;
             if (Configure.RefenceExamRecord != null)
             {
                 foreach (var item in cboRefExam.Items)
                 {
                     if (((ExamRecord)item).ID == Configure.RefenceExamRecord.ID)
                     {
                         cboRefExam.SelectedIndex = cboRefExam.Items.IndexOf(item);
                         break;
                     }
                 }
             }
             cboRankRilter.Text = Configure.RankFilterTagName;
             foreach (ListViewItem item in listViewEx1.Items)
             {
                 item.Checked = Configure.PrintSubjectList.Contains(item.Text);
             }
             cboTagRank1.Text = Configure.TagRank1TagName;
             foreach (ListViewItem item in listViewEx2.Items)
             {
                 item.Checked = Configure.TagRank1SubjectList.Contains(item.Text);
             }
             cboTagRank2.Text = Configure.TagRank2TagName;
             foreach (ListViewItem item in listViewEx3.Items)
             {
                 item.Checked = Configure.TagRank2SubjectList.Contains(item.Text);
             }
         }
         else
         {
             Configure = null;
             cboSchoolYear.SelectedIndex = -1;
             cboSemester.SelectedIndex   = -1;
             cboExam.SelectedIndex       = -1;
             cboRefExam.SelectedIndex    = -1;
             cboRankRilter.SelectedIndex = -1;
             cboTagRank1.SelectedIndex   = -1;
             cboTagRank2.SelectedIndex   = -1;
             foreach (ListViewItem item in listViewEx1.Items)
             {
                 item.Checked = false;
             }
             foreach (ListViewItem item in listViewEx2.Items)
             {
                 item.Checked = false;
             }
             foreach (ListViewItem item in listViewEx3.Items)
             {
                 item.Checked = false;
             }
         }
     }
 }