Example #1
0
        /// <summary>          
        /// 插入判断题信息
        /// </summary>
        /// <param name="s">判断题实体</param>
        public static int InsertJudge(JudgeInfo s)
        {
            ExamDbDataContext dc = DataAccess.CreateDBContext();

            dc.JudgeInfo.InsertOnSubmit(s);

            dc.SubmitChanges();
            // PurgeCacheItems("AllSubjects_" + s.DepartmentID.ToString());
            return s.JudgeID;
        }
        protected void imgBtnSave_Click(object sender, ImageClickEventArgs e)
        {
            JudgeInfo j = new JudgeInfo();

            j.Title = txtTitle.Text;
            j.RightAnswer =bool.Parse(rblAnswer.SelectedValue);

            Judge.InsertJudge(j);

            txtTitle.Text = "";

            this.ClientScript.RegisterStartupScript(this.GetType(), "Hint", "<script>alert('成功保存数据')</script>");
        }
Example #3
0
 /// <summary>
 /// 更新判断题信息
 /// </summary>
 /// <param name="s">判断题实体</param>
 public static void UpdateJudge(JudgeInfo s)
 {
     ExamDbDataContext dc = DataAccess.CreateDBContext();
     AttachInfo<JudgeInfo>(dc.JudgeInfo, s);
     // PurgeCacheItems("AllJudges_" + s.DepartmentID.ToString());
     dc.SubmitChanges();
 }
Example #4
0
 /// <summary>
 /// 删除判断题信息
 /// </summary>
 /// <param name="s">判断题实体</param>
 public static void DeleteJudge(JudgeInfo s, ExamDbDataContext dc)
 {
     AttachInfo<JudgeInfo>(dc.JudgeInfo, s);
     dc.JudgeInfo.DeleteOnSubmit(s);
     dc.SubmitChanges();
 }
Example #5
0
        private static IList<JudgeInfo> ChangeExcelToJudges(string filePath)
        {

            IList<JudgeInfo> judges = new List<JudgeInfo>();
            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\"";

            OleDbConnection myConn = new OleDbConnection(strConn);
            string strCom = " SELECT * FROM [Sheet1$]";
            OleDbCommand cmd = new OleDbCommand(strCom, myConn);
            OleDbDataReader dr = null;
            try
            {
                myConn.Open();
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    //if(dr["姓名"]==null||dr["学号"]==null||dr["班级"]==null||dr["专业"]==null|| dr["家庭地址"]==null)
                    //   continue;
                    string sAnswers = "";
                    JudgeInfo s = new JudgeInfo();
                    s.Title = dr["题目"].ToString();
                    sAnswers = dr["答案"].ToString();

                    s.CourseID = BLLBase.ReturnID(BLLBase.GetCourseDic(), dr["课程"].ToString());
                    s.ChapterID = BLLBase.ReturnID(BLLBase.GetChapterDic(), dr["章节"].ToString());

                    if (sAnswers == "对") s.RightAnswer = true;
                    else s.RightAnswer = false;
                    judges.Add(s);
                    //   HttpContext.Current.Response.Write("一条记录<br>");

                }
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write("错误信息:" + e.Message);
                judges = null;

            }
            finally
            {
                if (dr != null) dr.Close();
                myConn.Close();

            }
            
            return judges;
        }
Example #6
0
		private void detach_JudgeInfo(JudgeInfo entity)
		{
			this.SendPropertyChanging();
			entity.CourseInfo = null;
		}
Example #7
0
		private void attach_JudgeInfo(JudgeInfo entity)
		{
			this.SendPropertyChanging();
			entity.CourseInfo = this;
		}