Ejemplo n.º 1
0
        private void LoadSubject()
        {
            try
            {
                listSubject.Clear();

                DirectoryInfo directoryInfo = new DirectoryInfo(Application.StartupPath + @"\data");
                FileInfo[]    fileInfo      = directoryInfo.GetFiles("*.sdbt");
                foreach (FileInfo item in fileInfo)
                {
                    if (item.Extension.ToLower() == ".sdbt")
                    {
                        string subjectId   = Path.GetFileNameWithoutExtension(item.Name);
                        int    index       = subjectId.IndexOf('_') + 1;
                        string subjectName = subjectId.Substring(index, subjectId.Length - index);

                        M_ExerciseSubject subject = new M_ExerciseSubject();
                        subject.SubjectId   = subjectId;
                        subject.SubjectName = subjectName;
                        listSubject.Add(subject);
                    }
                }
                listSubject.Insert(0, new M_ExerciseSubject()
                {
                    SubjectId = "0", SubjectName = "---请选择一门考试科目---"
                });
                publicClass.BindDropDownList(cboSubject, "SubjectId", "SubjectName", listSubject);
                cboSubject.SelectedIndex = CommonUtil.subjectIndex;
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(typeof(frmExamSubject), ex);
                CommonUtil.WriteLog(ex);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 加载科目
 /// </summary>
 private void LoadSubject()
 {
     try
     {
         listSubject.Clear();
         DirectoryInfo directoryInfo = new DirectoryInfo(Application.StartupPath + @"\data");
         FileInfo[]    fileInfo      = directoryInfo.GetFiles("*.sdbt");//只取文本文档
         foreach (FileInfo item in fileInfo)
         {
             if (item.Extension.ToLower() == ".sdbt")
             {
                 string   subjectId = Path.GetFileNameWithoutExtension(item.Name);
                 string[] temp      = subjectId.Split('_');
                 if (temp.Length == 0)
                 {
                     continue;
                 }
                 if (temp[0] != PublicClass.StudentCode)
                 {
                     continue;
                 }
                 M_ExerciseSubject subject = new M_ExerciseSubject();
                 subject.SubjectId   = subjectId;
                 subject.SubjectName = temp[temp.Length - 1];
                 listSubject.Add(subject);
             }
         }
         listSubject.Insert(0, new M_ExerciseSubject()
         {
             SubjectId = "0", SubjectName = "---请选择一门考试科目---"
         });
         publicClass.BindDropDownList(cboSubject, "SubjectId", "SubjectName", listSubject);
     }
     catch (Exception ex)
     {
         LogHelper.WriteLog(typeof(frmExercise), ex);
         CommonUtil.WriteLog(ex);
     }
 }