Beispiel #1
0
        public Outputclass Create_Exam(Examtable exam)
        {
            Outputclass outputclass = new Outputclass();

            try
            {
                SqlCommand cmd = new SqlCommand("INSERT_EXAMDATA", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@USERID", exam.USERID);
                cmd.Parameters.AddWithValue("@COURSEID", exam.COURSEID);
                cmd.Parameters.AddWithValue("@EXAMCODE", exam.EXAMCODE);
                cmd.Parameters.AddWithValue("@ATTPT", exam.ATTEMPT);
                cmd.Parameters.AddWithValue("@QNID", exam.QUESTIONID);
                cmd.Parameters.AddWithValue("@QUESTION", exam.QUESTION);
                cmd.Parameters.AddWithValue("@UANS", exam.USERANSWER);
                cmd.Parameters.AddWithValue("@MARKS", exam.MARKS);
                Connection();
                int i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    outputclass.Count = i;
                }
                return(outputclass);
            }
            catch (Exception ex)
            {
                outputclass.Msg = ex.ToString();
                return(outputclass);
            }
            finally
            {
                conn.Close();
            }
        }
Beispiel #2
0
        public List <Examtable> Exam_data()
        {
            List <Examtable> exlist = new List <Examtable>();

            try
            {
                SqlCommand cmd = new SqlCommand("GET_EXAMTABLE", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                Connection();
                SqlDataReader dr = cmd.ExecuteReader();
                Examtable     exlist1;
                while (dr.Read())
                {
                    exlist1        = new Examtable();
                    exlist1.USERID = dr["USERID"] != null?Convert.ToInt32(dr["USERID"]) : 0;

                    exlist1.COURSEID = dr["COURSEID"] != null?Convert.ToInt32(dr["COURSEID"]) : 0;

                    exlist1.QUESTION   = dr["QUESTION"] != null ? dr["QUESTION"].ToString() : "";
                    exlist1.ANSWER     = dr["ANSWER"] != null ? dr["ANSWER"].ToString() : "";
                    exlist1.MARKS      = dr["MARKS"] != null ? dr["MARKS"].ToString() : "";
                    exlist1.TOTALMARKS = dr["TOTALMARKS"] != null ? dr["TOTALMARKS"].ToString() : "";
                    exlist1.STATUS     = dr["STATUS"] != null ? dr["STATUS"].ToString() : "";
                    exlist.Add(exlist1);
                }
                return(exlist);
            }
            catch (Exception ch)
            {
                return(exlist);
            }
            finally
            {
                conn.Close();
            }
        }