Пример #1
0
        public ActionResult Create(payfee payfee, string printReciept)
        {
            payFeeRequiredResponse pffr = payFeeRequired(payfee);

            if (pffr.amount <= 0)
            {
                ModelState.AddModelError(string.Empty, pffr.message);
            }
            if (ModelState.IsValid)
            {
                payfee.time = DateTime.Now;

                int    lastid        = 1;
                int    year          = DateTime.Now.Year;
                string lastReceiptNo = "U312100";

                if (db.payfees.Count() > 0)
                {
                    lastid = db.payfees.Max(item => item.id);
                    payfee payfee1 = db.payfees.Find(lastid);
                    year          = payfee1.time.Year;
                    lastReceiptNo = payfee1.recieptNo;
                }

                int currentYear = payfee.time.Year;

                int lastDigits = 100;
                if (currentYear <= year)
                {
                    try
                    {
                        lastDigits = int.Parse(lastReceiptNo.Substring(4)) + 1;
                    }
                    catch (Exception e)
                    { }
                }

                payfee.recieptNo = db.students.Find(payfee.studentid).htno.Substring(2, 2) + currentYear.ToString().Substring(2) + (lastDigits.ToString());

                // var college = db.students.Where(s => s.id.Equals(payfee.studentid)).Select(s => s.dept.name).FirstOrDefault().Substring(0, 3);
                // payfee.recieptNo = db.students.Find(payfee.studentid).htno.Substring(2,2) + lastid.ToString();//dt.Year.ToString().Substring(2, 2) + dt.Month.ToString() + dt.Day.ToString() + 1;
                db.payfees.Add(payfee);
                db.SaveChanges();
                TempData.Add("lastid", payfee.id);
                if (printReciept != null && printReciept.IndexOf("on") >= 0)
                {
                    TempData.Add("print", "true");
                }
                else
                {
                    TempData.Add("print", "false");
                }
                return(RedirectToAction("Index"));
            }
            ViewBag.feeTypeid     = new SelectList(db.feetypes, "id", "type", payfee.feeTypeid);
            ViewBag.paymentTypeid = new SelectList(db.paymenttypes, "id", "type", payfee.paymentTypeid);
            ViewBag.studentid     = new SelectList(db.students, "id", "htno", payfee.studentid);
            ViewBag.acaYearid     = new SelectList(db.acayears, "id", "year", payfee.acaYearid);
            return(View(payfee));
        }
Пример #2
0
        public ActionResult gridAddOrUpdate(payfee payfee)
        {
            payFeeRequiredResponse pffr = payFeeRequired(payfee);

            if (pffr.amount <= 0)
            {
                return(Json(new { success = false, message = pffr.message }, JsonRequestBehavior.AllowGet));
            }

            int lastid = 1;

            if (db.payfees.Count() > 0)
            {
                lastid = db.payfees.Max(item => item.id) + 1;
            }
            payfee.time = DateTime.Now;

            var college = db.students.Where(s => s.id.Equals(payfee.studentid)).Select(s => s.dept.name).FirstOrDefault().Substring(0, 3);

            payfee.recieptNo = college + lastid.ToString();//dt.Year.ToString().Substring(2, 2) + dt.Month.ToString() + dt.Day.ToString() + 1;

            // payfee.recieptNo = payfee.student.htno.Substring(0, 4) + lastid;
            payfee.paymentTypeid = 1;

            db.payfees.Add(payfee);
            db.SaveChanges();
            return(Json(new { success = true, message = "Payment made successfully" }, JsonRequestBehavior.AllowGet));
            //return Json(new { success = false, message = payfee.id + " " + payfee.amount + " " + payfee.studentid + " " + payfee.acaYearid + " " + payfee.feeTypeid }, JsonRequestBehavior.AllowGet);
        }
Пример #3
0
        public payFeeRequiredResponse payFeeRequired(payfee payfee)
        {
            if (payfee.amount < 100)
            {
                return(new payFeeRequiredResponse(0, "Minimum payment is Rs. 100/-"));
            }
            var setfees = db.setfees.Where(d => d.studentid.Equals(payfee.studentid)).Where(d => d.feeTypeid.Equals(payfee.feeTypeid)).Where(d => d.acaYearid.Equals(payfee.acaYearid));

            if (setfees.Count() > 0)
            {
                long outstandingdue = getOutStandingDue(payfee.studentid, payfee.acaYearid, payfee.feeTypeid);

                if (outstandingdue <= 0)
                {
                    return(new payFeeRequiredResponse(0, "No due exists, payment is not added"));
                }

                if (payfee.amount > outstandingdue)
                {
                    return(new payFeeRequiredResponse(0, "Amount being paid is greater than Required Amount, payment is not added"));
                }
                else
                {
                    if (installmentsLeft(payfee.studentid, payfee.acaYearid, payfee.feeTypeid) == (short)1 && payfee.amount < outstandingdue)
                    {
                        return(new payFeeRequiredResponse(0, "Since this is the final installment clear the due, amount less than outstanding due is not allowed"));
                    }
                    return(new payFeeRequiredResponse(outstandingdue, "Payment is required"));
                }
            }
            return(new payFeeRequiredResponse(0, "There is no fee set with this parameters, payment is not added"));
        }
Пример #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            payfee payfee = db.payfees.Find(id);

            db.payfees.Remove(payfee);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #5
0
        public ActionResult Edit(int id)
        {
            payfee payfee = db.payfees.Find(id);

            ViewBag.feeTypeid     = new SelectList(db.feetypes, "id", "type", payfee.feeTypeid);
            ViewBag.paymentTypeid = new SelectList(db.paymenttypes, "id", "type", payfee.paymentTypeid);
            ViewBag.studentid     = new SelectList(db.students, "id", "htno", payfee.studentid);
            ViewBag.acaYearid     = new SelectList(db.acayears, "id", "year", payfee.acaYearid);
            return(View(payfee));
        }
Пример #6
0
        public ActionResult Edit(payfee payfee)
        {
            payFeeRequiredResponse pffr = payFeeRequired(payfee);

            if (pffr.amount <= 0)
            {
                ModelState.AddModelError(string.Empty, pffr.message);
            }
            if (ModelState.IsValid)
            {
                db.Entry(payfee).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.feeTypeid     = new SelectList(db.feetypes, "id", "type", payfee.feeTypeid);
            ViewBag.paymentTypeid = new SelectList(db.paymenttypes, "id", "type", payfee.paymentTypeid);
            ViewBag.studentid     = new SelectList(db.students, "id", "htno", payfee.studentid);
            ViewBag.acaYearid     = new SelectList(db.acayears, "id", "year", payfee.acaYearid);
            return(View(payfee));
        }
Пример #7
0
        public ActionResult PrintToPdf(int id)
        {
            payfee payfee = db.payfees.Find(id);

            Document doc = new Document(PageSize.A5);

            // Set the document to write to memory.
            MemoryStream memStream = new MemoryStream();
            PdfWriter    writer    = PdfWriter.GetInstance(doc, memStream);

            writer.CloseStream = false;
            doc.Open();

            // string html = ControllerExtensions.RenderPartialViewToString(this, "Print", payfee);
            string html = ControllerExtensions.RenderPartialToString2("Print", payfee, this.ControllerContext);

            var dir  = Server.MapPath("/Content");
            var path = Path.Combine(dir, "banner_" + payfee.student.dept.college.collegeCode + ".gif");

            Image pic = Image.GetInstance(path);

            //  iTextSharp.text.Image pic = iTextSharp.text.Image.GetInstance(path);

            pic.ScalePercent(76f);
            doc.Add(pic);

            StringReader str = new StringReader(html);

            XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, str);

            if (doc.IsOpen())
            {
                doc.Close();
            }

            return(new FileContentResult(memStream.ToArray(), "application/pdf"));
        }
Пример #8
0
        public ActionResult Delete(int id)
        {
            payfee payfee = db.payfees.Find(id);

            return(View(payfee));
        }
Пример #9
0
        public ViewResult Details(int id)
        {
            payfee payfee = db.payfees.Find(id);

            return(View(payfee));
        }