Untitled
shinta0x01
plain_text
7 months ago
11 kB
12
Indexable
Never
HTML -------------- <div class="container"> <div class="row"> <h2 class=" text-center">Student Accounting</h2> <div class="col-md-4"> <input class="form-control" type="number" id="stud_id" placeholder="Student ID"/><br /> <input class="form-control" type="text" id="lname" placeholder="Lastname"/><br /> <input class="form-control" type="text" id="fname" placeholder="Firstname"/><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 /><br /> <select class="form-control" id="course_code"> <option value="" selected disabled hidden>Course Code</option> <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 /> <select class="form-control" id="subject"> <option value="" selected disabled hidden>Subjects</option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>8</option> <option>9</option> <option>10</option> </select> <br /> <select class="form-control" id="year"> <option value="" selected disabled hidden>Year</option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> </select><br /> <br /><br /> <button class="btn btn-primary">Submit</button> </div> <div class="col-md-4"> <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_tuitionperunit">Tuition Per 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_mop"><b>Mode of Payment: </b></p> </div> <div class="col-md-4"> <input type="radio" id="pre" name="fee" value="1"/><span id="d_prelimfee"> Prelim Fee </span><span id="p"></span><br /> <input type="radio" id="mid" name="fee" value="2"/><span id="d_midfee"> Midterm Fee </span><span id="m"></span><br /> <input type="radio" id="semi" name="fee" value="3"/><span id="d_semifee"> Semi Final Fee </span><span id="s"></span><br /> <input type="radio" id="final" name="fee" value="4"/><span id="d_finalfee"> Final Fee </span><span id="f"></span><br /> <input type="number" id="amount" /> <button class="btn btn-primary" id="btnfee">Save</button> <p id="change">Change: </p> </div> </div> </div> <script src="~/Scripts/jQuery/jquery-3.7.1.min.js"></script> <script src="~/Scripts/myScript/studentaccounting.js"></script> jQuery ------------------------------ $().ready(function () { $(".btn").click(function () { console.log($('input[name="gender"]:checked').val()) $.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(), assessment: $('input[name="fee"]:checked').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_tuitionperunit').text('Tuition Per Unit: ' + data[0].tuition_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) $('#p').text(data[0].prelim_fee) $('#m').text(data[0].midterm_fee) $('#s').text(data[0].semi_fee) $('#f').text(data[0].final_fee) $('#d_mop').text('Mode of Payment: ' + data[0].mop) }) }) $('#btnfee').click(function () { var fee = parseInt($('input[name="fee"]:checked').val()) var fee1 = 0; if (fee == 1) { fee1 = $('#p').text() } else if (fee == 2) { fee1 = $('#m').text() } else if (fee == 3) { fee1 = $('#s').text() } else if (fee == 4) { fee1 = $('#f').text() } $.post('../Home/postStudentFee', { amount: $('#amount').val(), fee: fee1 }, function (data) { $('#change').text("Change: " + data[0].amt) }) }) }) C Sharp ---------------------- using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace WebApplication1.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 = 1959.10; } 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, tuition_unit = tuition_unit, 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); } public ActionResult postStudentFee() { var data = new List<object>(); var amount = Convert.ToDouble(Request["amount"]); double amt = amount / 100; var fee = Convert.ToDouble(Request["fee1"]); double change = amt - fee; data.Add(new { change = change, amt = amt, }); return Json(data, JsonRequestBehavior.AllowGet); } } }
Leave a Comment