예제 #1
0
 public ActionResult Index(SaveStubentResult _saveStubentResult)
 {
     ViewBag.Message     = _saveStudentResultManager.SaveResult(_saveStubentResult);
     ViewBag.Grades      = _gradeManager.GetAllGrades();
     ViewBag.Departments = _departmentManager.GetAllDepartment();
     return(View());
 }
예제 #2
0
 public string SaveResult(SaveStubentResult saveStubentResult)
 {
     if (_saveStudentResultGateway.Check(saveStubentResult))
     {
         return("Result already saved");
     }
     return(_saveStudentResultGateway.SaveResult(saveStubentResult));
 }
        public bool Check(SaveStubentResult aSaveStubentResult)
        {
            var connection = new SqlConnection(connectionString);
            var command    = new SqlCommand();

            command.CommandText = "SELECT * FROM EnrolledCourse WHERE StudentRegistrationId='" + aSaveStubentResult.StudentRegId + "' AND CourseId='" + aSaveStubentResult.CourseId + "' and Result!='" + 0 + "'";
            command.Connection  = connection;
            connection.Open();
            SqlDataReader reader = command.ExecuteReader();

            return(reader.HasRows);
        }
        public string SaveResult(SaveStubentResult saveStubentResult)
        {
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand    cmd = new SqlCommand();

            cmd.CommandText = "UPDATE EnrolledCourse SET Result= '" + saveStubentResult.GradeId + "' WHERE StudentRegistrationId='" + saveStubentResult.StudentRegId + "' AND CourseId='" + saveStubentResult.CourseId + "'";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            int rowAffected = cmd.ExecuteNonQuery();

            if (rowAffected > 0)
            {
                return("Result Saved");
            }
            con.Close();
            return("Result not Saved");
        }