public ActionResult SaveStudentResult(SaveStudentResult saveStudentResult)
 {
     ViewBag.students = aStudentManager.GetAllStudent();
     ViewBag.grades   = aStudentManager.GetGrages();
     ViewBag.message  = aStudentManager.SaveResult(saveStudentResult);
     return(View());
 }
Пример #2
0
        public ActionResult SaveStudentResult(SaveStudentResult saveStudentResult)
        {
            var SSFmessage = "";

            if (ModelState.IsValid)
            {
                //var course = Mapper.Map<Course>(model);

                bool isSavedSSR = studentManager.Add(saveStudentResult);
                if (isSavedSSR)
                {
                    ViewBag.SSRmessage = "Student Result Information Saved Successfully!";
                    ModelState.Clear();
                }
                else
                {
                    ViewBag.SSFmessage = "This Course Result Already Saved Under This Student";
                }
            }
            else
            {
                ViewBag.SSFmessage = "Failed";
            }
            var model  = new SaveStudentResultViewModel();
            var result = studentDAL.StudentEnrollListGetAll().Select(c => new { StudentId = c.StudentId, RegistrationNumber = c.Student.RegistrationNumber }).Distinct().ToList();

            model.RegistrationNumberList = result.Select(c => new SelectListItem()
            {
                Value = c.StudentId.ToString(), Text = c.RegistrationNumber
            });
            model.CoursetSelectListItems = GetDefaultSelectListItem();
            ViewBag.FMessage             = SSFmessage;
            return(View(model));
        }
Пример #3
0
        public string SaveStudentResultData(SaveStudentResult saveStudentResult)
        {
            List <SaveStudentResult> studentResults = studentResultGateway.GetAllStudentResult();
            int count = 0;

            foreach (var result in studentResults)
            {
                if (result.StudentId == saveStudentResult.StudentId)
                {
                    if (result.CourseId == saveStudentResult.CourseId)
                    {
                        count = 1;
                        break;
                    }
                }
            }
            if (count > 0)
            {
                if (studentResultGateway.UpdateStudentResultData(saveStudentResult) > 0)
                {
                    return("Student Result Updated Successfully.");
                }
                return("Student Result Update Failed.");
            }
            else
            {
                if (studentResultGateway.SaveStudentResultData(saveStudentResult) > 0)
                {
                    return("Student Result Saved Successfully.");
                }
                return("Student Result Saving Failed.");
            }
        }
        public ActionResult Create(SaveStudentResult model)
        {
            if (ModelState.IsValid)
            {
                db.SaveStudentResults.Add(model);
                db.SaveChanges();
            }

            return(RedirectToAction("Create"));
        }
        public ActionResult SaveStudentResult(SaveStudentResult saveStudentResult)
        {
            saveStudentResult.RegNo = studentManager.GetStudentRegNoById(saveStudentResult.StudentId);
            ViewBag.students        = studentManager.GetAllStudents();
            ViewBag.grades          = studentResultManager.GetAllResultGrades();
            if (ModelState.IsValid)
            {
                ViewBag.Message = studentResultManager.SaveStudentResultData(saveStudentResult);
            }

            return(View());
        }
Пример #6
0
        public int UpdateStudentResultData(SaveStudentResult saveStudentResult)
        {
            Qurey   = "UPDATE studentResult SET gradeId = @gradeId WHERE studentId = @studentId";
            Command = new SqlCommand(Qurey, Connection);
            Command.Parameters.AddWithValue("@gradeId", saveStudentResult.GradeId);
            Command.Parameters.AddWithValue("@studentId", saveStudentResult.StudentId);

            Connection.Open();
            RowAffected = Command.ExecuteNonQuery();
            Connection.Close();

            return(RowAffected);
        }
        public int SaveResult(SaveStudentResult saveStudentResult)
        {
            Query   = " INSERT INTO StudentResult_tb(StudentId,CourseId,Grade) VALUES(@StudentId,@CourseId,@Grade)";
            Command = new SqlCommand(Query, Connection);
            Command.Parameters.Clear();
            Command.Parameters.AddWithValue("StudentId", saveStudentResult.StudentId);
            Command.Parameters.AddWithValue("CourseId", saveStudentResult.CourseId);
            Command.Parameters.AddWithValue("Grade", saveStudentResult.Grade);
            Connection.Open();
            int rowAffected = Command.ExecuteNonQuery();

            Connection.Close();
            return(rowAffected);
        }
Пример #8
0
        public int SaveStudentResultData(SaveStudentResult saveStudentResult)
        {
            Qurey   = "INSERT INTO studentResult VALUES(@studentId, @regNo, @courseId, @gradeId)";
            Command = new SqlCommand(Qurey, Connection);
            Command.Parameters.AddWithValue("@studentId", saveStudentResult.StudentId);
            Command.Parameters.AddWithValue("@regNo", saveStudentResult.RegNo);
            Command.Parameters.AddWithValue("@courseId", saveStudentResult.CourseId);
            Command.Parameters.AddWithValue("@gradeId", saveStudentResult.GradeId);

            Connection.Open();
            RowAffected = Command.ExecuteNonQuery();
            Connection.Close();

            return(RowAffected);
        }
Пример #9
0
        ///---Student Enroll End---///
        ///-----Save Student result---////

        public bool Add(SaveStudentResult saveStudentResult)
        {
            if (db.SaveStudentResults.Any(c => c.StudentId == saveStudentResult.StudentId && c.CourseId == saveStudentResult.CourseId))
            {
                return(false);
                //db.StudentEnrolls.Add(studentEnroll);
                //return db.SaveChanges() > 0;
            }
            else if (db.SaveStudentResults.Any(c => c.StudentId == saveStudentResult.StudentId && c.CourseId != saveStudentResult.CourseId))
            {
                db.SaveStudentResults.Add(saveStudentResult);
                return(db.SaveChanges() > 0);
            }
            else
            {
                db.SaveStudentResults.Add(saveStudentResult);
                return(db.SaveChanges() > 0);
            }
        }
Пример #10
0
        public int Save(SaveStudentResult saveStudentResult)
        {
            string     query   = "INSERT INTO Result(CourseId,GradeId,StudentId) VALUES(@CourseId,@GradeId,@StudentId)";
            SqlCommand command = new SqlCommand(query, Connection);

            command.Parameters.Clear();
            command.Parameters.Add("@CourseId", SqlDbType.Int);
            command.Parameters["@CourseId"].Value = saveStudentResult.CourseId;

            command.Parameters.Add("@GradeId", SqlDbType.Int);
            command.Parameters["@GradeId"].Value = saveStudentResult.GradeId;

            command.Parameters.Add("@StudentId", SqlDbType.Int);
            command.Parameters["@StudentId"].Value = saveStudentResult.StudentId;

            Connection.Open();
            int rowsAffected = command.ExecuteNonQuery();

            Connection.Close();
            return(rowsAffected);
        }
 public int Save(SaveStudentResult saveStudentResult)
 {
     if (saveStudentResult.StudentId != 0 && saveStudentResult.CourseId != 0)
     {
         if (IsCourseExist(saveStudentResult.StudentId, saveStudentResult.CourseId))
         {
             throw new Exception("Grade already given");
         }
         if (IsCourseEnrolled(saveStudentResult.StudentId, saveStudentResult.CourseId))
         {
             return(saveStudentResultGateway.Save(saveStudentResult));
         }
         else
         {
             throw new Exception("This Course has not been enrolled by this student!");
         }
     }
     else
     {
         throw new Exception("Please Select Student and Course");
     }
 }
Пример #12
0
 public string SaveResult(SaveStudentResult saveStudentResult)
 {
     if (IsCourseResultExist(saveStudentResult.StudentId, saveStudentResult.CourseId))
     {
         if (aStudentGateway.UpdateResult(saveStudentResult.StudentId, saveStudentResult.Grade) > 0)
         {
             return("Course result Updated.");
         }
         else
         {
             return("Not updated");
         }
     }
     else
     {
         if (aStudentGateway.SaveResult(saveStudentResult) > 0)
         {
             return("Result saved.");
         }
         return("Result save failed!");
     }
 }
Пример #13
0
        public ActionResult Save(SaveStudentResult saveStudentResult)
        {
            try
            {
                int rowsAffected = saveStudentResultManager.Save(saveStudentResult);
                if (rowsAffected > 0)
                {
                    ViewBag.Message = "Saved";
                }
                else
                {
                    ViewBag.Message = "Fail";
                }
            }
            catch (Exception exception)
            {
                ViewBag.Message = exception.Message;
            }
            ViewBag.Student = GetAllstudents();

            ViewBag.Grade = GetAllGrades();
            return(View());
        }
Пример #14
0
        public List <SaveStudentResult> GetAllStudentResult()
        {
            Qurey   = "SELECT * FROM studentResult";
            Command = new SqlCommand(Qurey, Connection);
            List <SaveStudentResult> studentResults = new List <SaveStudentResult>();

            Connection.Open();
            Reader = Command.ExecuteReader();
            while (Reader.Read())
            {
                SaveStudentResult studentResult = new SaveStudentResult();
                studentResult.Id        = Convert.ToInt32(Reader["id"]);
                studentResult.StudentId = Convert.ToInt32(Reader["studentId"]);
                studentResult.RegNo     = Reader["regNo"].ToString();
                studentResult.CourseId  = Convert.ToInt32(Reader["courseId"]);
                studentResult.GradeId   = Convert.ToInt32(Reader["gradeId"]);

                studentResults.Add(studentResult);
            }
            Reader.Close();
            Connection.Close();

            return(studentResults);
        }
Пример #15
0
        ///---- Student Enroll End----///
        ///----- Save student result---///

        public bool Add(SaveStudentResult saveStudentResult)
        {
            bool isSavedSSR = studentDAL.Add(saveStudentResult);

            return(isSavedSSR);
        }