public IActionResult SubmitFee(FeeSubViewModel fsvm)
        {
            var           v  = _context.FeeSubmission.Where(q => q.StudentId == fsvm.studentidVM).LastOrDefault();
            FeeSubmission fs = new FeeSubmission();

            fs.ClassId   = fsvm.classidVM;
            fs.StudentId = fsvm.studentidVM;
            if (fsvm.totalfeeVM == 0)
            {
                ViewBag.msg4 = "You haven't entered any amount!";
                return(View());
            }
            if (v != null)
            {
                var f = Math.Abs(fsvm.ShouldtotalfeeVM - fsvm.totalfeeVM);
                if (f == 0)
                {
                    fs.DueAmount = 0;
                }
                else
                {
                    fs.DueAmount = f;
                }
            }
            else
            {
                var f = Math.Abs(fsvm.ShouldtotalfeeVM - fsvm.totalfeeVM);
                if (f == 0)
                {
                    fs.DueAmount = 0;
                }
                else
                {
                    fs.DueAmount = f;
                }
            }

            fs.TotalFee       = fsvm.totalfeeVM;
            fs.FeeAmount      = fsvm.feeamountVM;
            fs.Date           = fsvm.dateVM;
            fs.ExtraFeeAmount = fsvm.extrafeeamountVM;
            _context.FeeSubmission.Add(fs);
            _context.SaveChanges();

            ModelState.Clear();
            var d  = _context.Class.Where(q => q.ClassId == fs.ClassId).FirstOrDefault();
            var dq = _context.Student.Where(q => q.StudentId == fs.StudentId).FirstOrDefault();
            var de = _context.AccountsManagement.Where(q => q.ClassId == fs.ClassId).FirstOrDefault();
            //var ex = _context.ExtraFee.Where(q => q.ClassId == fs.ClassId).FirstOrDefault();
            var fsn = _context.FeeSubmission.Where(q => q.StudentId == fs.StudentId && q.ClassId == fs.ClassId).LastOrDefault();


            FeeSubViewModel fsvm1 = new FeeSubViewModel();

            fsvm1.studentidVM      = fsn.StudentId;
            fsvm1.classidVM        = fsn.ClassId;
            fsvm1.dt               = fsn.Date.ToLongDateString();
            fsvm1.studentnameVM    = dq.StudentName;
            fsvm1.classnameVM      = d.ClassName;
            fsvm1.feeamountVM      = de.FeeAmount;
            fsvm1.extrafeeamountVM = fsn.ExtraFeeAmount;
            fsvm1.dueamountVM      = fsn.DueAmount;
            fsvm1.totalfeeVM       = fsn.TotalFee;
            fsvm1.amountofmonth    = fsvm.amountofmonth;
            fsvm1.lastmonth        = fsvm.lastmonth;
            fsvm1.currentmonth     = fsvm.currentmonth;

            fsvm1.inwords = NumToText.ToText(Convert.ToInt32(fsvm1.totalfeeVM));

            return(RedirectToAction("InvoiceOption", new RouteValueDictionary(fsvm1)));
        }
Exemplo n.º 2
0
        private void feeSubmissionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FeeSubmission submission = new FeeSubmission();

            submission.Show();
        }