Untitled

 avatar
user_2031329
plain_text
7 months ago
9.9 kB
0
Indexable
Never
#HTML
<div class="container">
    <div class="row">
        <h2 class="text-center mt-2">Student Accounting System</h2>
        <div class="col mt-4">
            Student ID Number <br />
            <input class="form-control" type="number" id="studentNum" />
            Family Name <br />
            <input class="form-control" type="text" id="famName" />
            First Name <br />
            <input class="form-control" type="text" id="firstName" />
            Gender <br />
            <input style="margin-left:1vw" type="radio" name="gender" id="gFemale" value="Female" /> Female <br />
            <input style="margin-left:1vw" type="radio" name="gender" id="gMale" value="Male" /> Male <br />
            <input style="margin-left:1vw" type="radio" name="gender" id="gNone" value="Others" /> Rather not say <br />
            Course Code
            <select class="form-control" id="courseCode">
                <option selected disabled>Select Course Code</option>
                <option value="1">0001</option>
                <option value="2">0002</option>
                <option value="3">0003</option>
                <option value="4">0004</option>
                <option value="5">0005</option>
                <option value="6">0006</option>
                <option value="7">0007</option>
                <option value="8">0008</option>
            </select>
            Subjects (note: only 1 - 10) <br />
            <input class="form-control" type="number" id="subject" />
            Year Level <br />
            <input class="form-control" type="number" id="yearLevel" /> <br />
            <button class="btn btn-primary" style="margin-left:7vw" id="bSubmit">Submit</button>
        </div>
        <div class="col">
            <p id="pID" class="mt-4">Student ID: </p>
            <p id="pFullName">Name: </p>
            <p id="pCourse">Course: </p>
            <p id="pGender">Gender: </p>
            <p id="pYearLevel">Year Level: </p>
            <p>===================</p>
            <p id="pTotalUnit">Total Units: </p>
            <p id="pTuitionPerUnit">Tuition per Unit: </p>
            <p id="pTotalTuition" style="font-weight: 500">Total Tuition: </p>
            <p id="pRegFee">Registration Fee: </p>
            <p id="pMiscFee">Miscellaneous Fee:</p>
            <p id="pLabFee">Laboratory Fee:</p>
            <p id="pTotalFee" style="font-weight: 700">Total Fee:</p>
        </div>
        <div class="col mt-4">
            <input type="radio" id="rPre" name="fee" value="1"/>
            <span id="sPre"> Prelim Fee : </span>
            <span id="pPrelim" style="font-weight: 500"></span><br />
            <input type="radio" id="rMid" name="fee" value="2" style="margin-top: 1.5vw"/>
            <span id="sMid"> Midterm Fee : </span>
            <span id="pMidterm" style="font-weight: 500"></span><br />
            <input type="radio" id="rSemi" name="fee" value="3" style="margin-top: 1.5vw"/>
            <span id="sSemi"> Semi-Final Fee : </span>
            <span id="pSemiFinal" style="font-weight: 500"></span><br />
            <input type="radio" id="rMid" name="fee" value="4" style="margin-top: 1.5vw"/>
            <span id="sFin"> Final Fee : </span>
            <span id="pFinal" style="font-weight: 500"></span><br />
            <p id="pMOP" style="font-weight: 500;margin-top: 1vw">Mode of Payment: </p>
            Amount Tendered <br />
            <input class="form-control" id="amountTendered" type="number" />
            <p id="pChange">Change : </p>
            <button class="btn btn-primary" id="bSave">Save</button>
        </div>
    </div>
</div>

====================================
#JS
$().ready(function () {
    $('#bSubmit').click(function () { 

        $.post('../Home/ajaxStudentAcc', {
            courseCode: $('#courseCode').val(),
            subject: $('#subject').val(),
            fullName: $('#famName').val() + " , " + $('#firstName').val(),
            sID: $("#studentNum").val(),
            gender: $('input[name="gender"]:checked').val(),
            yearLevel: $('#yearLevel').val(),
            
        }, function (data) {

            $("#pCourse").text("Course: " + data[0].course);
            $("#pTotalUnit").text("Total Units: " + data[0].totalUnit);
            $("#pTuitionPerUnit").text("Tuition per Unit: " + data[0].tuitionPerUnit);
            $("#pTotalTuition").text("Total Tuition: " + (data[0].totalTuition).toFixed(2));
            $("#pRegFee").text("Registration Fee: " + (data[0].regFee).toFixed(2));
            $("#pMiscFee").text("Miscellaneous Fee: " + (data[0].miscFee).toFixed(2));
            $("#pLabFee").text("Laboratory Fee: " + (data[0].labFee).toFixed(2));
            $("#pTotalFee").text("Total Fee: " + (data[0].totalFee).toFixed(2));
            $("#pPrelim").text((data[0].prelimFee).toFixed(2));
            $("#pMidterm").text((data[0].midtermFee).toFixed(2));
            $("#pSemiFinal").text((data[0].semiFee).toFixed(2));
            $("#pFinal").text((data[0].finalFee).toFixed(2));
            $("#pMOP").text("Mode of Payment: " + data[0].modeOP);
            $("#pFullName").text("Name: " + data[0].fullName);
            $("#pID").text("Student ID: " + data[0].studID);
            $("#pGender").text("Gender: " + data[0].gender);
            $("#pYearLevel").text("Year Level: " + data[0].yLevel);
        }) 
    })
    $("#bSave").click(function () {
        alert($('input[name="fee"]:checked').val())
        $.post('../Home/ajaxStudentAcc2', {
            amountTendered: parseInt($('#amountTendered').val()),
            fee: $('input[name="fee"]:checked').val(),
            
        }, function (data) {
            $("#pChange").text("Change: " + data[0].change)
        })
    })
})

======================================
#Controller
    public ActionResult ajaxStudent()
    {
        return View();
    }
    public ActionResult ajaxStudentAcc()
    {
        var data = new List<object>();
        var courseCode = Int32.Parse(Request["courseCode"]);
        var fullName = Request["fullName"];
        var studID = Int32.Parse(Request["sID"]);
        var gender = Request["gender"];
        var subject = Int32.Parse(Request["subject"]);
        var yLevel = Int32.Parse(Request["yearLevel"]);
        var course = "";
        var totalUnit = subject * 3.0;
        double tuition = 0.00;
        double regFee = 0.00;
        double miscFee = 0.00;
        double labFee = 0.00;

        if (courseCode == 1) {
            course = "C1";
            tuition = 356.75;
            regFee = 545.00;
            miscFee = 1000.45;
            labFee = 1900.75;
        } else if (courseCode == 2){
            course = "C2";
            tuition = 387.75;
            regFee = 550.00;
            miscFee = 1050.35;
            labFee = 1920.20;
        }
        else if (courseCode == 3) {
            course = "C3";
            tuition = 345.94;
            regFee = 555.00;
            miscFee = 1100.25;
            labFee = 1939.65;
        }
        else if (courseCode == 4){
            course = "C4";
            tuition = 351.26;
            regFee = 560.00;
            miscFee = 1150.15;
            labFee = 1959.10;
        }
        else if (courseCode == 5) {
            course = "C5";
            tuition = 378.44;
            regFee = 565.00;
            miscFee = 1200.05;
            labFee = 1978.55;
        }
        else if (courseCode == 6){
            course = "C6";
            tuition = 326.11;
            regFee = 570.00;
            miscFee = 1249.05;
            labFee = 1998.00;
        }
        else if (courseCode == 7) {
            course = "C7";
            tuition = 310.45;
            regFee = 610.00;
            miscFee = 1299.85;
            labFee = 2017.45;
        }
        else if (courseCode == 8){
            course = "C8";
            tuition = 399.79;
            regFee = 624.00;
            miscFee = 1349.75;
            labFee = 2036.90;
        }
        else {
            course = "Invalid Course Code";
        }

        double totalTuition = tuition * totalUnit;
        double totalFee = totalTuition + regFee + miscFee + labFee;
        double prelimFee = totalFee * .53;
        double midtermFee = totalFee * .64;
        double semiFee = totalFee * .75;
        double finalFee = totalFee;
        var modeOP = "";

        if (totalFee >= 8000){
            modeOP = "Cash";
        } else if (totalFee >= 5000 && totalFee < 8000) {
            modeOP = "Check";
        } else {
            modeOP = "Credit";
        }

        data.Add(new
        {
            course = course,
            totalUnit = totalUnit,
            tuitionPerUnit = tuition,
            totalTuition = totalTuition,
            regFee = regFee,
            miscFee = miscFee,
            labFee = labFee,
            totalFee = totalFee,
            prelimFee = prelimFee, 
            midtermFee = midtermFee,
            semiFee = semiFee,
            finalFee = finalFee,
            modeOP = modeOP,
            fullName = fullName,
            studID = studID,
            gender = gender,
            yLevel = yLevel,    
 
        });
        return Json(data, JsonRequestBehavior.AllowGet);
    }
    public ActionResult ajaxStudentAcc2()
    {
        var data = new List<object>();
        var amount = Int32.Parse(Request["amountTendered"]);
        var fee = Int32.Parse(Request["fee"]);
        var finalFee = Int32.Parse(Request["finalFee"]);
        var change = 0;
       

        if (fee == 1)
        {
            change = amount - finalFee;
        }

        
       
        data.Add(new
        {
            change = change,
            amount = amount,
            finalFee = finalFee,
            fee = fee,

        });
        return Json(data, JsonRequestBehavior.AllowGet);
    }
    
}

Leave a Comment