Esempio n. 1
0
        public JsonResult ResultMarkMid(int id, int major, int class_id)
        {
            List <Mark> list = new List <Mark>();

            SystemContext context     = HttpContext.RequestServices.GetService(typeof(Exam_Management_System.Models.SystemContext)) as SystemContext;
            int           academic_id = context.GetAcademic().Id;

            using (MySqlConnection conn1 = context.GetConnection())
            {
                conn1.Open();
                MySqlCommand cmd1 = new MySqlCommand("select * from mark_mid,subject,studentrollno,student_detail,student,year,major,class where student_detail.class_id=class.id and mark_mid.subject_id=subject.id and mark_mid.studentrollno_id=studentrollno.id and student_detail.studentrollno_id=studentrollno.id and studentrollno.student_id=student.id and student_detail.year_id=year.id and student_detail.major_id=major.id and student_detail.major_id=" + major + " and student_detail.year_id=" + id + " and mark_mid.academic_id=" + academic_id + " and student_detail.class_id=" + class_id + " order by mark_mid.studentrollno_id,mark_mid.subject_id asc", conn1);

                using (var reader = cmd1.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        list.Add(new Mark()
                        {
                            Id        = Convert.ToInt32(reader["id"]),
                            Rollno    = reader["rollno"].ToString(),
                            Name      = reader["student_name"].ToString(),
                            S_mark    = Convert.ToInt32(reader["mark"]),
                            Year      = reader["year_name"].ToString(),
                            Major     = reader["major_name"].ToString(),
                            Grade     = context.Grade(Convert.ToInt32(reader["mark"])),
                            Rollno_id = Convert.ToInt32(reader["studentrollno_id"]),
                            Subject   = reader["subject_name"].ToString(),
                            Class     = reader["class_name"].ToString(),


                            Pass = context.GetPass(Convert.ToInt32(reader["studentrollno_id"]), academic_id, Convert.ToInt32(reader["subject_id"]), Convert.ToInt32(reader["mark"])),
                        });
                    }
                }
                conn1.Close();
            }
            return(Json(list));
        }
Esempio n. 2
0
        public string PostAddMark(Mark mark)
        {
            SystemContext context     = HttpContext.RequestServices.GetService(typeof(Exam_Management_System.Models.SystemContext)) as SystemContext;
            int           academic_id = context.GetAcademic().Id;
            int           student_id  = context.GetStudentId(mark.Rollno, academic_id);

            using (MySqlConnection conn = context.GetConnection())
            {
                conn.Open();
                string sql = null;
                if (mark.Exam_id == 1)
                {
                    if (context.CheckMidMark(student_id, mark.Subject_id, academic_id) == 0)
                    {
                        sql = $"Insert Into mark_mid (studentrollno_id,mark,subject_id,academic_id) Values ('{student_id}','{mark.S_mark}','{mark.Subject_id}','{academic_id}')";
                        using (MySqlCommand command = new MySqlCommand(sql, conn))
                        {
                            command.ExecuteNonQuery();
                            conn.Close();
                        }
                    }
                    else
                    {
                        return("NO");
                    }
                }
                else
                {
                    if (context.CheckFinalMark(student_id, mark.Subject_id, academic_id) == 0)
                    {
                        sql = $"Insert Into mark_final (studentrollno_id,mark,subject_id,academic_id) Values ('{student_id}','{mark.S_mark}','{mark.Subject_id}','{academic_id}')";
                        using (MySqlCommand command = new MySqlCommand(sql, conn))
                        {
                            command.ExecuteNonQuery();
                            //conn.Close();
                        }
                        int mid_mark   = context.GetMid_Mark(student_id, academic_id);
                        int assignment = context.GetAss_Mark(student_id, academic_id);
                        int pass       = context.GetPass(student_id, academic_id, mark.Subject_id, mark.S_mark);
                        // int credit = context.GetCredit(student_id, academic_id, mark.S_mark, mark.Subject_id);
                        int final_mark = context.GetFinal_Mark(student_id, academic_id);
                        int totalMark  = context.GetTotalMark(student_id, academic_id);
                        if (context.CheckResult(student_id, academic_id) == 0)
                        {
                            sql = $"Insert Into result (studentrollno_id,mid_mark,final_mark,assigment_mark,pass,academic_id,total_mark) Values ('{student_id}','{mid_mark}','{final_mark}','{assignment}','{pass}','{academic_id}','{totalMark}')";
                        }
                        else
                        {
                            sql = $"UPDATE result SET final_mark={final_mark},pass={pass},attendence_mark={context.tt},total_mark={totalMark} where studentrollno_id={student_id} and academic_id={academic_id}";
                        }
                        using (MySqlCommand command = new MySqlCommand(sql, conn))
                        {
                            command.ExecuteNonQuery();
                            conn.Close();
                        }
                    }
                    else
                    {
                        return("NO");
                    }
                }
            }
            return("OK");
        }