Ejemplo n.º 1
0
        public static new List<Question> MyPaper(int MID, int Year, int Type)
        {
            var l = new List<Question>();
            try
            {
                SqlParameter[] param =
                {
                    new SqlParameter("@MID",MID),
                    new SqlParameter("@Year",Year),
                    new SqlParameter("@Type",Type)

                };
                var dr = SqlHelper.ExecuteReader(SqlHelper.Local, CommandType.StoredProcedure, "Get_MyPaper", param);
                while (dr.Read())
                {
                    var m = new Question();
                    m.QID = Convert.ToInt32(dr["QID"]);
                    //m.CID = Convert.ToInt32(dr["CID"]);
                    m.Subject = Convert.ToString(dr["Subject"]);
                    m.Answer = Convert.ToString(dr["Answer"]);
                    m.Score = Convert.ToInt32(dr["Score"]);
                    m.Cate = Convert.ToInt32(dr["Cate"]);
                    if (DBNull.Value != dr["A"])
                        m.A = Convert.ToString(dr["A"]);
                    if (DBNull.Value != dr["B"])
                        m.B = Convert.ToString(dr["B"]);
                    if (DBNull.Value != dr["C"])
                        m.C = Convert.ToString(dr["C"]);
                    if (DBNull.Value != dr["D"])
                        m.D = Convert.ToString(dr["D"]);
                    l.Add(m);
                }
                dr.Close();
            }
            catch (Exception ex)
            {

                log.Fatal(ex.Message);
                log.FatalException(ex.Message, ex);
            }
            return l;
        }
Ejemplo n.º 2
0
        public static R Question(Question info)
        {
            var m = new R();
            try
            {
                SqlParameter[] param =
                {
                    new SqlParameter("@CName",info.CName),
                    new SqlParameter("@Subject",info.Subject),
                    new SqlParameter("@A",info.A),
                    new SqlParameter("@B",info.B),
                    new SqlParameter("@C",info.C),
                    new SqlParameter("@D",info.D),
                    new SqlParameter("@Answer",info.Answer),
                    new SqlParameter("@Score",info.Score),
                    new SqlParameter("@Cate",info.Cate)
                   
                };
                //param[0].Direction = ParameterDirection.InputOutput;
                string SQL = @"INSERT INTO [Question]
                                           ([CName]
                                           ,[Subject]
                                           ,[A]
                                           ,[B]
                                           ,[C]
                                           ,[D]
                                           ,[Answer]
                                           ,[Score]
                                           ,[Cate])
                                     VALUES
                                           (@CName
                                           ,@Subject
                                           ,@A
                                           ,@B
                                           ,@C
                                           ,@D
                                           ,@Answer
                                           ,@Score
                                           ,@Cate)";
                var r = SqlHelper.ExecuteNonQuery(SqlHelper.Local, CommandType.Text, SQL, param);
                m.Code = 0;
                // m.Value = Convert.ToInt32(param[0].Value);
            }
            catch (Exception ex)
            {
                m.Code = 300;
                m.Message = ex.Message;
                log.Fatal(ex.Message);
                log.FatalException(ex.Message, ex);
            }

            return m;
        }
Ejemplo n.º 3
0
        public static R Question(string excelPath)
        {
            var r = new R();

            var ds = PreviewQuestion(excelPath);

            var dt = ds.Tables[0];

            foreach (DataRow dr in dt.Rows)
            {
                var info = new Question();
                info.CName = Convert.ToString(dr["CName"]);
                info.Subject = Convert.ToString(dr["Subject"]);
                info.A = Convert.ToString(dr["A"]);
                info.B = Convert.ToString(dr["B"]);
                info.C = Convert.ToString(dr["C"]);
                info.D = Convert.ToString(dr["D"]);
                info.Answer = Convert.ToString(dr["Answer"]);
                info.Score = Convert.ToInt32(dr["Score"]);
                info.Cate = Convert.ToInt32(dr["Cate"]);
                DAL.M.Update.Question(info);
            }

            return r;
        }
Ejemplo n.º 4
0
        public static List<Question> MyPaperResult(int MID)
        {
            var l = new List<Question>();
            try
            {
                SqlParameter[] param =
                {
                    new SqlParameter("@MID",MID)
                    //new SqlParameter("@Year",Year),
                    //new SqlParameter("@Type",Type)
                    
                };
                string SQL = @"
                    SELECT  q.*,my_Answer=myq.Answer,my_status=myq.Status
                    FROM    dbo.My_Question myq
                            INNER JOIN dbo.Question q ON myq.QID = q.QID
                    WHERE   myq.MID = @MID
                    ORDER BY myq.ID ASC
              ";
                var dr = SqlHelper.ExecuteReader(C.conn, CommandType.Text, SQL, param);
                while (dr.Read())
                {
                    var m = new Question();
                    m.QID = Convert.ToInt32(dr["QID"]);
                    //m.CID = Convert.ToInt32(dr["CID"]);
                    m.Subject = Convert.ToString(dr["Subject"]);
                    m.Answer = Convert.ToString(dr["Answer"]);
                    m.Score = Convert.ToInt32(dr["Score"]);
                    m.Cate = Convert.ToInt32(dr["Cate"]);
                    if (DBNull.Value != dr["A"])
                        m.A = Convert.ToString(dr["A"]);
                    if (DBNull.Value != dr["B"])
                        m.B = Convert.ToString(dr["B"]);
                    if (DBNull.Value != dr["C"])
                        m.C = Convert.ToString(dr["C"]);
                    if (DBNull.Value != dr["D"])
                        m.D = Convert.ToString(dr["D"]);
                    l.Add(m);
                }
                dr.Close();
            }
            catch (Exception ex)
            {

                log.Fatal(ex.Message);
                log.FatalException(ex.Message, ex);
            }
            return l;
        }