Exemplo n.º 1
0
        public string addQuestionvalues(DbExam value)
        {
            DbExam data = new DbExam();
            int    Seq;

            try
            {
                Seq = Context.DbExam.Where(i => i.ExamType == value.ExamType).Max(i => i.Seq) + 1;
            }
            catch {
                Seq = 1;
            }

            data.Seq           = Seq;
            data.ExamType      = value.ExamType;
            data.QuestionType  = value.QuestionType;
            data.Question      = value.Question;
            data.QuestionImage = value.QuestionImage;
            data.CorrectAnswer = value.CorrectAnswer;
            data.ChoiceType    = value.ChoiceType;
            data.Choice1       = value.Choice1;
            data.Choice2       = value.Choice2;
            data.Choice3       = value.Choice3;
            data.Choice4       = value.Choice4;
            data.Choice5       = value.Choice5;
            data.Choice6       = value.Choice6;
            data.Active        = value.Active;

            Context.DbExam.Add(data);

            Context.SaveChanges();

            return("success");
        }
Exemplo n.º 2
0
        public ArrayList StageExam_GetAll()
        {
            ArrayList lst = new ArrayList();

            using (SqlConnection conn = getConnect())
            {
                //SqlCommand cmd = new SqlCommand("select * " +
                //    "from dethi, kyThi, monHoc " +
                //    "where dethi.makythi = kyThi.makythi " +
                //    "and dethi.mamon = monHoc.mamon", conn);
                SqlCommand    cmd = new SqlCommand("select * from kyThi", conn);
                SqlDataReader dr  = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        DbExam obj = new DbExam();
                        obj.stageExamAll_IDataReader(dr);
                        lst.Add(obj);
                    }
                }
            }

            return(lst);
        }
Exemplo n.º 3
0
 public IActionResult editQuestionvalues(DbExam value)
 {
     try
     {
         string result = IExam.editQuestionvalues(value);
         return(Ok(result));
     }
     catch (Exception e) { return(Ok()); }
 }
Exemplo n.º 4
0
 public IActionResult addQuestionvalues(DbExam value)
 {
     try
     {
         string result = IExam.addQuestionvalues(value);
         return(Ok(result));
     }
     catch (Exception e) { return(Ok(e.InnerException.Message)); }
 }
Exemplo n.º 5
0
        public string deleteQuetionvalues(string examType, string questionType, string question)
        {
            DbExam data = new DbExam();

            data = Context.DbExam.Where(x => x.ExamType == examType && x.QuestionType == questionType && x.Question == question).FirstOrDefault();



            Context.DbExam.Remove(data);
            Context.SaveChanges();

            return("success");
        }
Exemplo n.º 6
0
        public ArrayList getExamDetailById(string id)
        {
            ArrayList lst = new ArrayList();

            using (SqlConnection conn = getConnect())
            {
                SqlCommand    cmd = new SqlCommand("select * from ctdethi where madethi= '" + id + "'", conn);
                SqlDataReader dr  = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        DbExam obj = new DbExam();
                        obj.detailExam_IDataReader(dr);
                        lst.Add(obj);
                    }
                }
            }
            return(lst);
        }
Exemplo n.º 7
0
        public string editQuestionvalues(DbExam value)
        {
            DbExam editQuestion = Context.DbExam.Where(x => x.ExamType == value.ExamType && x.Seq == value.Seq).FirstOrDefault();

            editQuestion.ExamType      = value.ExamType;
            editQuestion.QuestionType  = value.QuestionType;
            editQuestion.Question      = value.Question;
            editQuestion.QuestionImage = value.QuestionImage;
            editQuestion.CorrectAnswer = value.CorrectAnswer;
            editQuestion.ChoiceType    = value.ChoiceType;
            editQuestion.Choice1       = value.Choice1;
            editQuestion.Choice2       = value.Choice2;
            editQuestion.Choice3       = value.Choice3;
            editQuestion.Choice4       = value.Choice4;
            editQuestion.Choice5       = value.Choice5;
            editQuestion.Choice6       = value.Choice6;
            editQuestion.Active        = value.Active;

            Context.DbExam.Update(editQuestion);
            Context.SaveChanges();

            return("success");
        }