Emmmanuel FIADUFE

Emmmanuel FIADUFE

  • 816
  • 900
  • 40.5k

Fetch data query fails

May 5 2024 6:41 PM

Hello Term,
I have 4 tables, and table one is tblCLass which contain ClassId and ClassName, and table two is tblRegistrationFeesTable
which contain RegistrationId, Fees, and ClassId and the Table 3 is tblTerm which contain TermId and TermName,
 and in table 4 is tblFeesPayment which contain FeesId,Payment date Student name,TermId, RegistrationId,ClassId, FeesPaid, Wallet and and I want to select ClassName and then it will fetch Fee by RegistrationId and whenever I select ClassName I want the existig fees to show in the approved textbox.
But when I select ClassName the fees doesn't show in the approved textbox.

 

 public ActionResult GetStudentFees(int registrationId, int classId)
        {
            decimal SchoolFees = objBasicShoolDBEntities.tblRegistrationFees.Single(model => model.RegistrationId == registrationId && model.ClassId == classId).Fees;
            return Json(SchoolFees, JsonRequestBehavior.AllowGet);
        }

 

 function GetTermlyFees(registrationId) {
        $.ajax({
            async: true,
            type: 'GET',
            dataType: 'JSON',
            contentType: 'application/json; charset=utf-8',
            data: { registrationId: registrationId},
            url: '/Home/GetStudentFees',
            success: function (data) {
                $("#txtRegistrationFees").val(parseFloat(data).toFixed(2));
            },
            error: function () {
                alert("There is some problem to get school fees.");
            }
        });
        }


Answers (15)