Ejemplo n.º 1
0
        public ActionResult Create(PaymentEntry paymententry)
        {
            if (paymententry.RegID != 0)
            {

                RegistrationEntry RegLookup = new RegistrationEntry();

                RegLookup.RegistrationUID = RegLookup.RegIDtoUID(paymententry.RegID);

                if (RegLookup.RegistrationUID != null)
                {

                    if (paymententry.PmtStatusID == 0)
                    {
                        ViewBag.isEmpty = false;
                        ViewBag.RegID = paymententry.RegID;
                        ViewBag.RegAmtOwes = RegLookup.RegTotalPrice(paymententry.RegID);

                        paymententry.PaymentDate = DateTime.Now;
                        paymententry.PmtStatusID = (int)1;

                        //ViewBag.PmtStatusID = new SelectList(db.PmtStatuses, "PmtStatusID", "Name");
                        ViewBag.PmtTypeID = new SelectList(db.PmtTypes, "PmtTypeID", "Name");
                        return View(paymententry);
                    }

                    if (paymententry.PmtStatusID == 1 && paymententry.PmtTypeID == 0)
                    {
                        ViewBag.isEmpty = false;
                        ViewBag.RegID = paymententry.RegID;
                        ViewBag.RegAmtOwes = RegLookup.RegTotalPrice(paymententry.RegID);
                        ViewBag.Message = "Please select a payment type";

                        paymententry.PaymentDate = DateTime.Now;
                        paymententry.PmtStatusID = (int)1;

                        ViewBag.PmtTypeID = new SelectList(db.PmtTypes, "PmtTypeID", "Name");
                        return View(paymententry);
                    }

                    if (paymententry.PmtStatusID == 1 && paymententry.PaymentAmt <= (decimal)0)
                    {
                        ViewBag.isEmpty = false;
                        ViewBag.RegID = paymententry.RegID;
                        ViewBag.RegAmtOwes = RegLookup.RegTotalPrice(paymententry.RegID);
                        ViewBag.Message = "Payment Amount has to be greater then 0";

                        paymententry.PaymentDate = DateTime.Now;
                        paymententry.PmtStatusID = (int)1;

                        ViewBag.PmtTypeID = new SelectList(db.PmtTypes, "PmtTypeID", "Name", paymententry.PmtTypeID);
                        return View(paymententry);
                    }

                    if (paymententry.PmtStatusID == 1 && ModelState.IsValid)
                    {
                        db.PaymentEntries.Add(paymententry);
                        db.SaveChanges();

                        EventHistory NewEvent = new EventHistory();
                        NewEvent.AddHistory(paymententry.RegID, "Payment Entered", paymententry.PaymentID);

                        return RedirectToAction("Index");
                    }
                }
                else
                {
                    ViewBag.Message = "Registration ID not found";
                    ViewBag.isEmpty = true;
                    return View();
                }
            }

            ViewBag.Message = "Error";
            ViewBag.isEmpty = true;
            return View();
        }
Ejemplo n.º 2
0
        public ActionResult Complete(string RegUID, PaymentEntry values)
        {
            if (RegUID == null)
            {
                ViewBag.Found = false;
                return View();
            }

            RegistrationEntry FoundEntry = new RegistrationEntry();
            int FoundRegID = FoundEntry.RegUIDtoID(RegUID);

            if (values.RegID == 0 && values.PaymentAmt == (decimal)0)
            {
                ViewBag.Found = true;
                ViewBag.Scholarship = true;
                ViewBag.TotalPrice = FoundEntry.RegTotalPrice(FoundRegID);
                ViewBag.RegID = FoundRegID;
                ViewBag.RegUID = RegUID;
                values.RegID = (int)FoundRegID;
                values.PaymentDate = DateTime.Now;
                values.PmtTypeID = (int)1;
                values.PmtStatusID = (int)1;

                return View(values);
            }

            if (values.RegID == FoundRegID && values.PaymentAmt <= (decimal)0)
            {
                ViewBag.Found = true;
                ViewBag.Scholarship = true;
                ViewBag.TotalPrice = FoundEntry.RegTotalPrice(FoundRegID);
                ViewBag.RegID = FoundRegID;
                ViewBag.RegUID = RegUID;
                ViewBag.MessageEn = "Please enter an Amount greater then 0";
                ViewBag.MessageCh = "请输入一个数目大于0";
                values.RegID = (int)FoundRegID;
                values.PaymentDate = DateTime.Now;
                values.PmtTypeID = (int)1;
                values.PmtStatusID = (int)1;

                return View(values);
            }

            if (values.RegID == FoundRegID && values.PaymentAmt > (decimal)0)
            {
                values.RegID = (int)FoundRegID;
                values.PaymentDate = DateTime.Now;
                values.PmtTypeID = (int)1;
                values.PmtStatusID = (int)1;

                _db.PaymentEntries.Add(values);
                _db.SaveChanges();

                EventHistory NewEvent = new EventHistory();
                NewEvent.AddHistory(values.RegID, "Scholarship Request Entered", values.PaymentID);

                return RedirectToAction("Modify", "Register", new { RegUID = RegUID });
            }

            ViewBag.Found = true;
            ViewBag.Scholarship = false;
            ViewBag.TotalPrice = FoundEntry.RegTotalPrice(FoundRegID);
            ViewBag.RegID = FoundRegID;

            return View();
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int id, PaymentEntry paymententry)
        {
            if (ModelState.IsValid)
            {
                paymententry.PaymentID = id;

                db.Entry(paymententry).State = EntityState.Modified;
                db.SaveChanges();

                EventHistory NewEvent = new EventHistory();
                NewEvent.AddHistory(paymententry.RegID, "Payment Entry Modified", id);

                return RedirectToAction("Index");
            }
            ViewBag.PmtStatusID = new SelectList(db.PmtStatuses, "PmtStatusID", "Name", paymententry.PmtStatusID);
            ViewBag.PmtTypeID = new SelectList(db.PmtTypes, "PmtTypeID", "Name", paymententry.PmtTypeID);
            return View(paymententry);
        }