Exemplo n.º 1
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            //IList<SubjectInfo> subjects = Subject.GetFormalSubjectsByTitle(txtTitle.Text, DeptID,MajorID);
            //if (subjects != null && subjects.Count > 0)
            //{
            //    lblFeedback.Text = "该课题标题已经存在,请输入其它课题! : "+subjects[0].Title;
            //    return;
            //}

            SubjectInfo s = new SubjectInfo();
            s.Title = txtTitle.Text;
            s.Description = txtBody.Text;
            s.DepartmentID = DeptID;
            s.Reference = txReference.Text;
            s.IsChecked = false;
            s.IsFormal = false;
            s.AuthorID = UserID;
            s.AuthorIsStudent = IsStudent;
            if (IsStudent == false)
            {
                if (Utility.GetConfigValue(DeptID, "SubjectManagedByTeacher").Equals("true", StringComparison.OrdinalIgnoreCase))
                    s.IsFormal = true;

                s.AuthorName = UserRealName + " 老师";
            }
            else s.AuthorName = UserRealName + " 同学";
            s.MajorID =int.Parse(ddlMajors.SelectedValue);


           int subjectID= Subject.InsertSubject(s);

            ///如果导师为学生推荐该课题。
           if (IsStudent == false && chkToStudent.Checked == true)
           { 
               int stuID=int.Parse(ddlStudents.SelectedValue);
               RecommendSubjectToStudent(s, stuID);
           }


           bool isCheckPassed = false;
            //如果作者是学生,则自动将其推荐的课题作为其拟选课题。
           if (IsStudent == true && chkSelected.Checked == true)
           {
               //ChangeSelectedSubject(subjectID, ref isCheckPassed);
           
           }
           if (s.IsFormal == false)
           {
               if (IsStudent == true && chkSelected.Checked == true)
               {
                   if (isCheckPassed == true)
                   { 
                       lblFeedback.Text = "成功添加课题,将等待管理员或导师审核!但你先前所选课题已经过导师审核,无法更改选题,请与管理员联系!"; 
                   }
                   else lblFeedback.Text = "成功添加课题,并已将该课题作为您的拟选题目,将等待管理员或导师审核!";
               }
               else lblFeedback.Text = "成功添加课题,等待管理员审核入库。。。";

           }
           else lblFeedback.Text = "成功添加课题,该课题已入库!";
           BindGrid();
        }
Exemplo n.º 2
0
		private void detach_SubjectInfo(SubjectInfo entity)
		{
			this.SendPropertyChanging();
			entity.MajorInfo = null;
		}
Exemplo n.º 3
0
        /// <summary>
        /// 为学生推荐课题
        /// </summary>
        /// <param name="subjectID"></param>
        /// <param name="studentID"></param>
        private void RecommendSubjectToStudent(SubjectInfo s, int studentID)
        {
                

        }
Exemplo n.º 4
0
		private void attach_SubjectInfo(SubjectInfo entity)
		{
			this.SendPropertyChanging();
			entity.DepartmentInfo = this;
		}
Exemplo n.º 5
0
        /// <summary>
        /// 将excel文件中的数据转换成课题实体集合
        /// </summary>
        /// <param name="filePath">excel文件的物理路径</param>
        /// <returns></returns>
        private static IList<SubjectInfo> ChangeExcelToSubjects(string filePath)
        {
            ExamDbDataContext dc = DataAccess.CreateDBContext();

            IList<SubjectInfo> subjects = new List<SubjectInfo>();
            string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";
            if (filePath.EndsWith("xlsx")) strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1\"";

            string deptName = "";
            string majorName = "";
            OleDbConnection myConn = new OleDbConnection(strConn);
            string strCom = " SELECT * FROM [Sheet1$]";
            OleDbCommand cmd = new OleDbCommand(strCom, myConn);
                myConn.Open();
                OleDbDataReader dr = cmd.ExecuteReader();
            try
            {
                
                while (dr.Read())
                {
                    SubjectInfo s = new SubjectInfo();
                    s.Title = dr["课题名称"].ToString();
                    
                    
                    s.Description = dr["课题简介"].ToString();
                    s.Reference = dr["参考文献"].ToString();

                    deptName = dr["系别"].ToString();

                    s.DepartmentID = ReturnID(deptDic, deptName);

                    majorName = dr["所属专业"].ToString();

                    s.MajorID = ReturnID(majorDic, majorName);

                    s.AuthorName = "管理员";
                    s.IsChecked = true;
                    s.IsFormal = true;
                    s.AuthorID = 0;

                    if (s.MajorID == 0 || s.DepartmentID == 0)
                        throw new Exception("系别或专业名称中有错,请按照提示填写!");

                    //if (GetFormalSubjectsByTitle(s.Title, s.DepartmentID) != null)
                    //{
                    //    throw new Exception("与课题库中存在重复的课题名称,请修改再次导入!");                       
                    //}
                    subjects.Add(s);

                    //    HttpContext.Current.Response.Write("一条记录<br>");

                }
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write("错误信息:" + e.Message);
                subjects = null;
            }
            finally
            {
              if(dr!=null)dr.Close();
                myConn.Close();
               
            } return subjects;
        }
Exemplo n.º 6
0
        /// <summary>
        /// 更新正式课题信息
        /// </summary>
        /// <param name="s">课题实体</param>
        public static void UpdateSubject(SubjectInfo s, ExamDbDataContext dc)
        {
            AttachInfo<SubjectInfo>(dc.SubjectInfo, s);
            dc.SubmitChanges();

            PurgeCacheItems("AllSubjects_" + s.DepartmentID.ToString());
        }
Exemplo n.º 7
0
 /// <summary>
 /// 删除课题信息
 /// </summary>
 /// <param name="s">课题实体</param>
 public static void DeleteSubject(SubjectInfo s, ExamDbDataContext dc)
 { 
     AttachInfo<SubjectInfo>(dc.SubjectInfo,s);
       
         
     dc.SubjectInfo.DeleteOnSubmit(s);
     dc.SubmitChanges();
 }
Exemplo n.º 8
0
 /// <summary>          
 /// 插入课题信息
 /// </summary>
 /// <param name="s">课题实体</param>
 public static int InsertSubject(SubjectInfo s)
 {
     ExamDbDataContext dc = DataAccess.CreateDBContext();
     if(dc.SubjectInfo!=null&&dc.SubjectInfo.Any(p => p.Title == s.Title)) return 0;
     dc.SubjectInfo.InsertOnSubmit(s);
     dc.SubmitChanges();
     PurgeCacheItems("AllSubjects_" + s.DepartmentID.ToString());
     return s.SubjectID;
 }