Untitled

mail@pastecode.io avatar
unknown
csharp
a month ago
8.6 kB
1
Indexable
Never
HTML
--------------------

@{
    ViewBag.Title = "StudentAccouting";
}

<div class="container">
    <div class="row">
        <div class="col">
            <h2>StudentAccouting</h2>
            Student ID: <input type="number" id="stud_id" /><br />
            Lastname: <input type="text" id="lname" /><br />
            Firstname: <input type="text" id="fname" /><br />
            Gender: <br /><input type="radio" name="gender" id="male" value="Male" />Male<br />
            <input type="radio" name="gender" id="female" value="Female" />Female<br />
            Course Code:
            <select id="course_code">
                <option>1</option>
                <option>2</option>
                <option>3</option>
                <option>4</option>
                <option>5</option>
                <option>6</option>
                <option>7</option>
                <option>8</option>
            </select>
            <br />
            Year: <input type="text" id="year" /><br />
            Subjects: <input type="number" id="subject" /><br /><br />
            <button id="btn">Submit</button>
        </div>
        <div class="col">
            <p id="d_studid">Student ID: </p>
            <p id="d_name">Name: </p>
            <p id="d_gender">Gender: </p>
            <p id="d_coursecode">Course Code: </p>
            <p id="d_course">Course: </p>
            <p id="d_year">Year: </p>
            <p id="d_subject">Subjects: </p>
            <p id="d_totalunit">Total Unit: </p>
            <p id="d_totaltuition"><b>Total Tuition: </b></p>
            <p id="d_reg">Registration: </p>
            <p id="d_misc">Miscellaneous: </p>
            <p id="d_labfee">Lab Fee: </p>
            <p id="d_totalfee">Total Fee: </p>
            <p id="d_prelimfee">Prelim Fee: </p>
            <p id="d_midfee">Midterm Fee: </p>
            <p id="d_semifee">Semi Final Fee: </p>
            <p id="d_finalfee"><b>Final Fee: </b></p>
            <p id="d_mop"><b>Mode of Payment: </b></p>
        </div>
    </div>
</div>


<script src="~/Scripts/jQuery/jquery-3.7.1.min.js"></script>
<script src="~/Scripts/js/studentaccounting.js"></script>

JQUEARY
-------------------------------------------

$().ready(function () {
    $("#btn").click(function () {
        $.post('../Home/postStudentAccounting', {
            stud_id: $('#stud_id').val(),
            lname: $('#lname').val(),
            fname: $('#fname').val(),
            gender: $('input[name="gender"]:checked').val(),
            course_code: $('#course_code').val(),
            year: $('#year').val(),
            subject: $('#subject').val()



        }, function (data) {
            $('#d_studid').text('Student ID: ' + data[0].stud_id)
            $('#d_name').text('Name: ' + data[0].lname + ", " + data[0].fname)
            $('#d_gender').text('Gender: ' + data[0].gender)
            $('#d_coursecode').text('Course Code: ' + data[0].course_code)
            $('#d_course').text('Course: ' + data[0].course)
            $('#d_year').text('Year: ' + data[0].year)
            $('#d_subject').text('Subjects: ' + data[0].subject)
            $('#d_totalunit').text('Total Unit: ' + data[0].total_unit)
            $('#d_totaltuition').text('Total Tuition: ' + data[0].total_tuition)
            $('#d_reg').text('Registration: ' + data[0].reg)
            $('#d_misc').text('Miscellaneous: ' + data[0].misc)
            $('#d_labfee').text('Lab Fee: ' + data[0].lab_fee)
            $('#d_totalfee').text('Total Fee: ' + data[0].total_fee)
            $('#d_prelimfee').text('Prelim Fee: ' + data[0].prelim_fee)
            $('#d_midfee').text('Midterm Fee: ' + data[0].midterm_fee)
            $('#d_semifee').text('Semi Final Fee: ' + data[0].semi_fee)
            $('#d_finalfee').text('Final Fee: ' + data[0].final_fee)
            $('#d_mop').text('Mode of Payment: ' + data[0].mop)

        })
    })
})

C#
-------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace StudentAccounting.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        public ActionResult StudentAccouting()
        {
            return View();
        }

        public ActionResult postStudentAccounting()
        {
            var data = new List<object>();
            var stud_id = Request["stud_id"];
            var lname = Request["lname"];
            var fname = Request["fname"];
            var gender = Request["gender"];
            var course_code = Convert.ToInt32(Request["course_code"]);
            var course = "";
            var year = Request["year"];
            var subject = Convert.ToInt32(Request["subject"]);
            var total_unit = subject * 3.00;
            var tuition_unit = 0.0;
            var reg = 0.0;
            var misc = 0.0;
            var lab_fee = 0.0;
            var mop = "";
            

            if (course_code == 1)
            {
                course = "C1";
                tuition_unit = 356.75;
                reg = 545.00;
                misc = 1000.45;
                lab_fee = 1900.75;
                
            }else if (course_code == 2)
            {
                course = "C2";
                tuition_unit = 387.75;
                reg = 550.00;
                misc = 1050.35;
                lab_fee = 1920.20;

            }
            else if (course_code == 3)
            {
                course = "C3";
                tuition_unit = 345.94;
                reg = 555.00;
                misc = 1100.25;
                lab_fee = 1939.65;

            }
            else if (course_code == 4)
            {
                course = "C4";
                tuition_unit = 351.26;
                reg = 560.00;
                misc = 1150.15;
                lab_fee = 1950.65;

            }
            else if (course_code == 5)
            {
                course = "C5";
                tuition_unit = 378.44;
                reg = 565.00;
                misc = 1200.05;
                lab_fee = 1978.55;

            }
            else if (course_code == 6)
            {
                course = "C6";
                tuition_unit = 326.11;
                reg = 570.00;
                misc = 1249.05;
                lab_fee = 1998.00;

            }else if (course_code == 7)
            {
                course = "C7";
                tuition_unit = 310.45;
                reg = 610.00;
                misc = 1299.85;
                lab_fee = 2017.45;

            }
            else if (course_code == 8)
            {
                course = "C8";
                tuition_unit = 399.79;
                reg = 624.00;
                misc = 1349.75;
                lab_fee = 2036.90;

            }

            var total_tuition = total_unit * tuition_unit;
            var total_fee = total_tuition + reg + misc + lab_fee;
            var prelim_fee = Math.Round(total_fee * .53, 2);
            var midterm_fee = Math.Round(total_fee * .64, 2);
            var semi_fee = Math.Round(total_fee * .75, 2);
            var final_fee = Math.Round(total_fee, 2);

            if(total_fee >= 8000)
            {
                mop = "CASH";
            }else if(total_fee >= 5000)
            {
                mop = "CHECK";
            }
            else
            {
                mop = "CREDIT";
            }

            data.Add(new
            {
                stud_id = stud_id,
                lname = lname,
                fname = fname,
                gender = gender,
                course_code = course_code,
                course = course,
                year = year,
                subject = subject,
                total_unit = total_unit,
                total_tuition = total_tuition,
                reg = reg,
                misc = misc,
                lab_fee = lab_fee,
                total_fee = total_fee,
                prelim_fee = prelim_fee,
                midterm_fee = midterm_fee,
                semi_fee = semi_fee,
                final_fee = final_fee,
                mop = mop


            });

            return Json(data, JsonRequestBehavior.AllowGet);
        }

    }
}
Leave a Comment