Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
11 kB
2
Indexable
Never
#cshtml

@{
    ViewBag.Title = "ajaxStudent";
}

<h2 style="margin-top: 3vw">Student Accounting System</h2>
<div class="row">
    <div class="col-md-3 mt-2">
        Student ID Number
        <br />
        <input type="number" id="studentNum" class="form-control"/>
    </div>
</div>
<div class="row">
    <div class="col-md-3 mt-2">
        Family Name
        <br />
        <input type="text" id="famName" class="form-control" />
    </div>
    <div class="col-md-3 mt-2">
        First Name
        <br />
        <input type="text" id="firstName" class="form-control" />
    </div>
    <div class="row">
        <div class="d-flex flex-column mt-2" style="width: 280px;">
            Gender
            <div class="form-check">
                <input class="form-check-input" type="radio" name="gender" id="gFemale" value="Female" checked>
                <label class="form-check-label" for="exampleRadios1">
                    Female
                </label>
            </div>
            <div class="form-check">
                <input class="form-check-input" type="radio" name="gender" id="gMale" value="Male">
                <label class="form-check-label" for="exampleRadios1">
                    Male
                </label>
            </div>
            <div class="form-check">
                <input class="form-check-input" type="radio" name="gender" id="gOther" value="Other">
                <label class="form-check-label" for="exampleRadios1">
                    Rather not say
                </label>
            </div>
        </div>
        <div class="col-md-3 mt-2">
            Course Code
            <select id="courseCode" class="form-control">
                <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>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-md-3 mt-2">
        Year Level <br />
        <input type="number" id="yearLevel" class="form-control" />
    </div>
    <div class="col-md-3 mt-2">
        Subjects (1-10) <br />
        <input type="number" id="subject" class="form-control"/>  <br />
    </div>
</div>
<div class="row" style="width:360px; padding-left:200px; margin-top: 2vw">
    <button class="btn btn-primary" type="submit" id="bGetCalc">Submit</button>
</div>
<div class="row">
    <div class="col mt-5">
        <p id="pID">Student ID: </p>
        <p id="pCourse">Course: </p>
        <p id="pFullName">Name: </p>
        <p id="pGender">Gender: </p>
        <p id="pYearLevel">Year Level: </p>
    </div>
</div>
<div class="row">
    <div class="col">
        <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>
<div class="d-flex flex-column mt-1" style="width: 280px;">
    <div class="form-check; mt-2">
        <input class="form-check-input" type="radio" name="fee" id="pPrelim" value="prelim" checked>
        <label class="form-check-label" for="exampleRadios1">
            Prelim Fee: 
        </label>
    </div>
    <div class="form-check; mt-2">
        <input class="form-check-input" type="radio" name="fee" id="pMidterm" value="midterm">
        <label class="form-check-label" for="exampleRadios1">
            <span>
                <p id="pPrelim" style="font-weight: 700">Prelim Fee:</p>
            </span>
        </label>
    </div>
    <div class="form-check; mt-2">
        <input class="form-check-input" type="radio" name="fee" id="pSemiFinal" value="semi">
        <label class="form-check-label" for="exampleRadios1">
            Semi-Final Fee:
        </label>
    </div>
    <div class="form-check; mt-2">
        <input class="form-check-input" type="radio" name="fee" id="pFinal" value="final">
        <label class="form-check-label" for="exampleRadios1">
            Final Fee:
        </label>
    </div>
</div>
<br />
<p id="pPrelim" style="font-weight: 700">Prelim Fee:</p>
<p id="pMidterm" style="font-weight: 700">Midterm Fee:</p>
<p id="pSemiFinal" style="font-weight: 700">Semi Final Fee:</p>
<p id="pFinal" style="font-weight: 700">Final Fee:</p>
<p id="pMOP" style="font-weight: 700">Mode of Payment: </p>

<script src="~/Scripts/JqueryFile/jquery-3.7.1.min.js"></script>
<script src="~/Scripts/myJquery/ajaxStudent.js"></script>


------------------------
JS
$().ready(function () {
    $('#bGetCalc').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("Prelim Fee: " + (data[0].prelimFee).toFixed(2));
            $("#pMidterm").text("Midterm Fee: " + (data[0].midtermFee).toFixed(2));
            $("#pSemiFinal").text("Semi Final Fee: " + (data[0].semiFee).toFixed(2));
            $("#pFinal").text("Final Fee: " + (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);


        }) 
    })
})

---------------------
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);
        }
    }
}
Leave a Comment