예제 #1
0
        public void Insert(SubjectTypeCategory obj)
        {
            string sql = "insert into T_SubjectTypeCategory(cateName,subjectType) values(@cateName,@subjectType)";

            SqlParameter[] parms =
            {
                new SqlParameter("@cateName",    obj.CateName),
                new SqlParameter("@subjectType", (int)obj.SubjectType)
            };
            DBHelper2.Insert(sql, parms);
        }
예제 #2
0
        public void Insert(SubjectOfSimpleAnswer obj)
        {
            string sql = "insert into T_SubjectOfSimpleAnswer(question,answer,cateID) values(@question,@answer,@cateID)";

            SqlParameter[] parms =
            {
                new SqlParameter("@question", obj.Question),
                new SqlParameter("@answer",   obj.Answer),
                new SqlParameter("@cateID",   obj.Category.CateID)
            };
            DBHelper2.Insert(sql, parms);
        }
예제 #3
0
        public void Insert(SubjectOfMultiSelection obj)
        {
            string sql = "insert into T_SubjectOfMultiSelection(question,selectA,selectB,selectC,selectD,answer,cateID) values(@question,@selectA,@selectB,@selectC,@selectD,@answer,@cateID)";

            SqlParameter[] parms =
            {
                new SqlParameter("@question", obj.Question),
                new SqlParameter("@selectA",  obj.SelectA),
                new SqlParameter("@selectB",  obj.SelectB),
                new SqlParameter("@selectC",  obj.SelectC),
                new SqlParameter("@selectD",  obj.SelectD),
                new SqlParameter("@answer",   obj.Answer),
                new SqlParameter("@cateID",   obj.Category.CateID)
            };
            DBHelper2.Insert(sql, parms);
        }
예제 #4
0
        public void Insert(PaperByRandomSelection obj)
        {
            string sql = "insert into T_PaperByRandomSelection(paperName,deptID,paperType,creator,createdTime,judgeSum,singleSelectionSum,multiSelectionSum,judgeCateID,singleSelectionCateID,multiSelectionCateID) values(@paperName,@deptID,@paperType,@creator,@createdTime,@judgeSum,@singleSelectionSum,@multiSelectionSum,@judgeCateID,@singleSelectionCateID,@multiSelectionCateID)";

            SqlParameter[] parms =
            {
                new SqlParameter("@paperName",             obj.PaperName),
                new SqlParameter("@deptID",                obj.PaperType.DeptID),
                new SqlParameter("@paperType",             obj.PaperType.DeptName),
                new SqlParameter("@creator",               obj.Creator.Name),
                new SqlParameter("@createdTime",           obj.CreatedTime),
                new SqlParameter("@judgeSum",              obj.JudgeSum),
                new SqlParameter("@singleSelectionSum",    obj.SingleSelectionSum),
                new SqlParameter("@multiSelectionSum",     obj.MultiSelectionSum),
                new SqlParameter("@judgeCateID",           obj.JudgeCateID),
                new SqlParameter("@singleSelectionCateID", obj.SingleSelectionCateID),
                new SqlParameter("@multiSelectionCateID",  obj.MultiSelectionCateID)
            };
            DBHelper2.Insert(sql, parms);
        }
예제 #5
0
        public void Insert(PaperByManualSelection obj)
        {
            string sql = "insert into T_PaperByManualSelection(paperName,deptID,paperType,creator,createdTime) values(@paperName,@deptID,@paperType,@creator,@createdTime); select @@identity";

            SqlParameter[] parms =
            {
                new SqlParameter("@paperName",   obj.PaperName),
                new SqlParameter("@deptID",      obj.PaperType.DeptID),
                new SqlParameter("@paperType",   obj.PaperType.DeptName),
                new SqlParameter("@creator",     obj.Creator.Name),
                new SqlParameter("@createdTime", obj.CreatedTime)
            };

            SqlConnection  conn  = new SqlConnection(DBHelper2.connStr);
            SqlTransaction trans = null;

            try
            {
                conn.Open();
                trans = conn.BeginTransaction("TInsertPaperByManualSelection");
                using (SqlDataReader dr = DBHelper2.Select(trans, sql, parms))
                {
                    if (dr.Read())
                    {
                        int id = Convert.ToInt32(dr[0]);
                        dr.Close();
                        sql = "insert into T_PaperByManualSelection_Subject(paperID,subjectType,subjectID) values(@paperID,@subjectType,@subjectID)";

                        //1:填空题,2:判断题,3:单选题,4:多选题,5:简答题
                        if (obj.FillBlankList != null)
                        {
                            foreach (SubjectOfFillBlank subject in obj.FillBlankList)
                            {
                                SqlParameter[] parms2 =
                                {
                                    new SqlParameter("@paperID",     id),
                                    new SqlParameter("@subjectType",  1),
                                    new SqlParameter("@subjectID",   subject.Id)
                                };
                                DBHelper2.Insert(trans, sql, parms2);
                            }
                        }

                        if (obj.JudgeList != null)
                        {
                            foreach (SubjectOfJudge subject in obj.JudgeList)
                            {
                                SqlParameter[] parms2 =
                                {
                                    new SqlParameter("@paperID",     id),
                                    new SqlParameter("@subjectType",  2),
                                    new SqlParameter("@subjectID",   subject.Id)
                                };
                                DBHelper2.Insert(trans, sql, parms2);
                            }
                        }

                        if (obj.SingleSelectionList != null)
                        {
                            foreach (SubjectOfSingleSelection subject in obj.SingleSelectionList)
                            {
                                SqlParameter[] parms2 =
                                {
                                    new SqlParameter("@paperID",     id),
                                    new SqlParameter("@subjectType",  3),
                                    new SqlParameter("@subjectID",   subject.Id)
                                };
                                DBHelper2.Insert(trans, sql, parms2);
                            }
                        }

                        if (obj.MultiSelectionList != null)
                        {
                            foreach (SubjectOfMultiSelection subject in obj.MultiSelectionList)
                            {
                                SqlParameter[] parms2 =
                                {
                                    new SqlParameter("@paperID",     id),
                                    new SqlParameter("@subjectType",  4),
                                    new SqlParameter("@subjectID",   subject.Id)
                                };
                                DBHelper2.Insert(trans, sql, parms2);
                            }
                        }

                        if (obj.SimpleAnswerList != null)
                        {
                            foreach (SubjectOfSimpleAnswer subject in obj.SimpleAnswerList)
                            {
                                SqlParameter[] parms2 =
                                {
                                    new SqlParameter("@paperID",     id),
                                    new SqlParameter("@subjectType",  5),
                                    new SqlParameter("@subjectID",   subject.Id)
                                };
                                DBHelper2.Insert(trans, sql, parms2);
                            }
                        }
                    }
                }

                trans.Commit();
            }
            catch
            {
                trans.Rollback();
            }
            finally
            {
                trans.Dispose();
                conn.Close();
            }
        }
예제 #6
0
        public void InsertTestRecorderAnswer(int recorderID, List <SubjectOfFillBlank> list1, List <SubjectOfJudge> list2, List <SubjectOfSingleSelection> list3, List <SubjectOfMultiSelection> list4, List <SubjectOfSimpleAnswer> list5)
        {
            SqlConnection conn = new SqlConnection(DBHelper2.connStr);

            try
            {
                conn.Open();
                string         sql   = "insert into T_TestRecorder_Answer(recorderID,subjectType,subjectID) values(@recorderID,@subjectType,@subjectID)";
                SqlParameter[] parms =
                {
                    new SqlParameter("@recorderID",  recorderID),
                    new SqlParameter("@subjectType",          0),
                    new SqlParameter("@subjectID", 0)
                };
                //填空题
                if (list1 != null)
                {
                    foreach (SubjectOfFillBlank subject in list1)
                    {
                        parms[1].Value = (int)SubjectType.FillBlank;
                        parms[2].Value = subject.Id;
                        DBHelper2.Insert(sql, parms);
                    }
                }

                //判断题
                if (list2 != null)
                {
                    foreach (SubjectOfJudge subject in list2)
                    {
                        parms[1].Value = (int)SubjectType.Judge;
                        parms[2].Value = subject.Id;
                        DBHelper2.Insert(sql, parms);
                    }
                }

                //单选题
                if (list3 != null)
                {
                    foreach (SubjectOfSingleSelection subject in list3)
                    {
                        parms[1].Value = (int)SubjectType.SingleSelection;
                        parms[2].Value = subject.Id;
                        DBHelper2.Insert(sql, parms);
                    }
                }

                //多选题
                if (list4 != null)
                {
                    foreach (SubjectOfMultiSelection subject in list4)
                    {
                        parms[1].Value = (int)SubjectType.MultiSelection;
                        parms[2].Value = subject.Id;
                        DBHelper2.Insert(sql, parms);
                    }
                }

                // 简答题
                if (list5 != null)
                {
                    foreach (SubjectOfSimpleAnswer subject in list5)
                    {
                        parms[1].Value = (int)SubjectType.SimpleAnswer;
                        parms[2].Value = subject.Id;
                        DBHelper2.Insert(sql, parms);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
예제 #7
0
파일: DBTest.cs 프로젝트: lmdyhm/yitihua
        public void Insert(Test test,
                           int fillBlankScoresOfEveryone,
                           int judgeScoresOfEveryone,
                           int singleSelectionScoresOfEveryone,
                           int multiSelectionScoresOfEveryone,
                           List <SubjectOfSimpleAnswer> simpleAnswerScoresList)
        {
            Insert(test);

            string sql = "insert into T_Test_Subject_Scores(testID,subjectType,scores) values(@testID,@subjectType,@scores)";

            SqlParameter[] parms =
            {
                new SqlParameter("@testID",      test.TestID),
                new SqlParameter("@subjectType", null),
                new SqlParameter("@scores",      null)
            };

            SqlConnection conn = new SqlConnection(DBHelper2.connStr);

            try
            {
                conn.Open();
                //填空题
                parms[1].Value = (int)SubjectType.FillBlank;
                parms[2].Value = fillBlankScoresOfEveryone;
                DBHelper2.Insert(conn, sql, parms);

                //判断题
                parms[1].Value = (int)SubjectType.Judge;
                parms[2].Value = judgeScoresOfEveryone;
                DBHelper2.Insert(conn, sql, parms);

                //单选题
                parms[1].Value = (int)SubjectType.SingleSelection;
                parms[2].Value = singleSelectionScoresOfEveryone;
                DBHelper2.Insert(conn, sql, parms);

                //多选题
                parms[1].Value = (int)SubjectType.MultiSelection;
                parms[2].Value = multiSelectionScoresOfEveryone;
                DBHelper2.Insert(conn, sql, parms);

                //简答题
                string         sql2   = "insert into T_Test_SubjectOfSimpleAnswer_Scores(testID,subjectID,scores) values(@testID,@subjectID,@scores)";
                SqlParameter[] parms2 =
                {
                    new SqlParameter("@testID",    test.TestID),
                    new SqlParameter("@subjectID", null),
                    new SqlParameter("@scores",    null)
                };
                if (simpleAnswerScoresList != null)
                {
                    foreach (SubjectOfSimpleAnswer subject in simpleAnswerScoresList)
                    {
                        parms2[1].Value = subject.Id;
                        parms2[2].Value = subject.Scores;
                        DBHelper2.Insert(conn, sql2, parms2);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }