Untitled

mail@pastecode.io avatar
unknown
csharp
a month ago
13 kB
3
Indexable
Never
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 = Math.Round(total_tuition + reg + misc + lab_fee, 2);
            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 radio_val = Convert.ToInt32(Request["radio_val"]);
            var pre_val = Convert.ToDouble(Request["pre_val"]);
            var mid_val = Convert.ToDouble(Request["mid_val"]);
            var semi_val = Convert.ToDouble(Request["semi_val"]);
            var final_val = Convert.ToDouble(Request["final_val"]);
            double amount = 0.0;
            

            var tendered_amt = Convert.ToDouble(Request["tendered_amt"]);
            double final_tendered = tendered_amt / 100;

            if(radio_val == 1)
                amount = pre_val;
            else if(radio_val == 2)
                amount = mid_val;
            else if (radio_val == 3)
                amount = semi_val;
            else if(radio_val == 4)
                amount = final_val;

            var word_amount = Convert.ToInt32(amount);

            int ones = word_amount % 10;
            word_amount /= 10;
            int tens = word_amount % 10;
            word_amount /= 10;
            int hundreds = word_amount % 10;
            word_amount /= 10;
            int thousands = word_amount % 10;
            word_amount /= 10;
            int tenThousands = word_amount % 10;

            string word = "";

            // Handling ten thousands place
            if (tenThousands == 1)
            {
                if (thousands == 0)
                    word = "Ten Thousand";
                else if (thousands == 1)
                    word = "Eleven Thousand";
                else if (thousands == 2)
                    word = "Twelve Thousand";
                else if (thousands == 3)
                    word = "Thirteen Thousand";
                else if (thousands == 4)
                    word = "Fourteen Thousand";
                else if (thousands == 5)
                    word = "Fifteen Thousand";
                else if (thousands == 6)
                    word = "Sixteen Thousand";
                else if (thousands == 7)
                    word = "Seventeen Thousand";
                else if (thousands == 8)
                    word = "Eighteen Thousand";
                else if (thousands == 9)
                    word = "Nineteen Thousand";
            }
            else if (tenThousands == 2)
                word = "Twenty Thousand";
            else if (tenThousands == 3)
                word = "Thirty Thousand";
            else if (tenThousands == 4)
                word = "Forty Thousand";
            else if (tenThousands == 5)
                word = "Fifty Thousand";
            else if (tenThousands == 6)
                word = "Sixty Thousand";
            else if (tenThousands == 7)
                word = "Seventy Thousand";
            else if (tenThousands == 8)
                word = "Eighty Thousand";
            else if (tenThousands == 9)
                word = "Ninety Thousand";

            // Handling thousands place
            if (thousands != 0 && tenThousands != 1)
            {
                word += " ";
                if (thousands == 1)
                    word += "One Thousand";
                else if (thousands == 2)
                    word += "Two Thousand";
                else if (thousands == 3)
                    word += "Three Thousand";
                else if (thousands == 4)
                    word += "Four Thousand";
                else if (thousands == 5)
                    word += "Five Thousand";
                else if (thousands == 6)
                    word += "Six Thousand";
                else if (thousands == 7)
                    word += "Seven Thousand";
                else if (thousands == 8)
                    word += "Eight Thousand";
                else if (thousands == 9)
                    word += "Nine Thousand";
            }

            // Handling hundreds place
            if (hundreds != 0)
            {
                word += " ";
                if (hundreds == 1)
                    word += "One Hundred";
                else if (hundreds == 2)
                    word += "Two Hundred";
                else if (hundreds == 3)
                    word += "Three Hundred";
                else if (hundreds == 4)
                    word += "Four Hundred";
                else if (hundreds == 5)
                    word += "Five Hundred";
                else if (hundreds == 6)
                    word += "Six Hundred";
                else if (hundreds == 7)
                    word += "Seven Hundred";
                else if (hundreds == 8)
                    word += "Eight Hundred";
                else if (hundreds == 9)
                    word += "Nine Hundred";
            }

            // Handling tens and ones place
            if (tens != 0)
            {
                word += " ";
                if (tens == 1)
                {
                    if (ones == 0)
                        word += "Ten";
                    else if (ones == 1)
                        word += "Eleven";
                    else if (ones == 2)
                        word += "Twelve";
                    else if (ones == 3)
                        word += "Thirteen";
                    else if (ones == 4)
                        word += "Fourteen";
                    else if (ones == 5)
                        word += "Fifteen";
                    else if (ones == 6)
                        word += "Sixteen";
                    else if (ones == 7)
                        word += "Seventeen";
                    else if (ones == 8)
                        word += "Eighteen";
                    else if (ones == 9)
                        word += "Nineteen";
                }
                else
                {
                    if (tens == 2)
                        word += "Twenty";
                    else if (tens == 3)
                        word += "Thirty";
                    else if (tens == 4)
                        word += "Forty";
                    else if (tens == 5)
                        word += "Fifty";
                    else if (tens == 6)
                        word += "Sixty";
                    else if (tens == 7)
                        word += "Seventy";
                    else if (tens == 8)
                        word += "Eighty";
                    else if (tens == 9)
                        word += "Ninety";
                }

                if (tens != 1 && ones != 0)
                    word += " ";
            }

            if (ones != 0 && tens != 1)
            {
                if (tens == 0)
                    word += " ";
                if (ones == 1)
                    word += "One";
                else if (ones == 2)
                    word += "Two";
                else if (ones == 3)
                    word += "Three";
                else if (ones == 4)
                    word += "Four";
                else if (ones == 5)
                    word += "Five";
                else if (ones == 6)
                    word += "Six";
                else if (ones == 7)
                    word += "Seven";
                else if (ones == 8)
                    word += "Eight";
                else if (ones == 9)
                    word += "Nine";
            }


            var change = Math.Round(final_tendered - amount, 2);

            data.Add(new
            {
                word = word,
                change = change,
            });

            return Json(data, JsonRequestBehavior.AllowGet);
        }

    }
}
Leave a Comment