示例#1
0
        // Precondition:  Attempting to change focus from patron_ComboBox_Validating
        // Postcondition: If patronBoxCbo.selectedIndex >= 0, focus will change,
        //                 else error message will be set
        private void patron_ComboBox_Validating(object sender, CancelEventArgs e)
        {
            if (patron_ComboBox.SelectedIndex < 0)
            {
                e.Cancel = true;                                               // Stops focus changing
            }
            CheckOutError.SetError(patron_ComboBox, "Must select an patron!"); // Set error message

            patron_ComboBox.SelectAll();
        }
        // Precondition:  Attempting to change focus from returnItemCbo_Validating
        // Postcondition: If patronBoxCbo.selectedIndex >= 0, focus will change,
        //                 else error message will be set
        private void patronBoxCbo_Validating(object sender, CancelEventArgs e)
        {
            if (patronBoxCbo.SelectedIndex < 0)
            {
                e.Cancel = true; // Stops focus changing process
            }
            // Will NOT proceed to Validated event

            CheckOutError.SetError(patronBoxCbo, "Must select an patron!"); // Set error message

            patronBoxCbo.SelectAll();
        }
        public async Task <IActionResult> CheckOutConfirmed(int id, [Bind("BidderId,TotalPaid,AmountOwed,PaymentInfo")] CheckOut result)
        {
            //var bidder = await _context.Bidder.SingleOrDefaultAsync(m => m.BidderId == id);
            //_context.Bidder.Remove(bidder);
            //await _context.SaveChangesAsync();
            //return View(result);


            if (ModelState.IsValid)
            {
                var bidder = await _context.Bidder.SingleOrDefaultAsync(m => m.BidderId == id);

                try
                {
                    bidder.AmountPaid  = result.TotalPaid;
                    bidder.PaymentInfo = result.PaymentInfo;
                    _context.Update(bidder);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BidderExists(bidder.BidderId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                var bidder = await _context.Bidder.SingleOrDefaultAsync(m => m.BidderId == id);

                var chkErr = new CheckOutError
                {
                    BidderId       = bidder.BidderId,
                    BidderFullName = bidder.FullName,
                    ErrorMessage   = "Unknown Error, could not check out Bidder.  You shouldn't be seeing this."
                };

                return(View("CheckOutError", chkErr));
            }
        }
 // Precondition:  itemsAvaCbo_Validating Succeeded
 // Postcondition: ErrorMessage has been cleared, and the user can shift focus and continue on their way
 private void patronBoxCbo_Validated(object sender, EventArgs e)
 {
     CheckOutError.SetError(patronBoxCbo, ""); // Clears error message
 }
 // Precondition:  itemsAvaCbo_Validating Succeeded
 // Postcondition: ErrorMessage has been cleared, and the user can shift focus and continue on their way
 private void itemsAvaCbo_Validated(object sender, EventArgs e)
 {
     CheckOutError.SetError(itemsAvaCbo, ""); // Clears error message
 }
示例#6
0
 // Precondition:  item_ComboBox_Validated Succeeded
 // Postcondition: ErrorMessage has been cleared, and the user can shift focus and continue on their way
 private void item_ComboBox_Validated(object sender, EventArgs e)
 {
     CheckOutError.SetError(item_ComboBox, ""); // Clears error message
 }
        // GET: Bidders/CheckOut/5
        public async Task <IActionResult> CheckOut(int?id)
        {
            //TODO -- Checkout Logic
            if (id == null)
            {
                return(NotFound());
            }


            var bidder = await _context.Bidder
                         .SingleOrDefaultAsync(m => m.BidderId == id);

            if (bidder == null)
            {
                return(NotFound());
            }

            var paddles = await _context.Paddle.Where(o => o.BidderId == bidder.BidderId).ToListAsync();

            if (paddles.Count > 0)
            {
                var paddleIds = paddles.Select(a => a.PaddleId).ToList();
                var bids      = await _context.Bid.Where(o => paddleIds.Contains(o.PaddleId)).ToListAsync();

                var chkout = new CheckOut
                {
                    BidderId    = bidder.BidderId,
                    AmountOwed  = bids.Select(o => o.TotalCost).Sum(),
                    TotalPaid   = bidder.AmountPaid,
                    PaymentInfo = bidder.PaymentInfo
                };

                if (chkout.AmountOwed <= 0)
                {
                    var chkErr = new CheckOutError
                    {
                        BidderId       = bidder.BidderId,
                        BidderFullName = bidder.FullName,
                        ErrorMessage   = "Bidder does owe anything."
                    };

                    return(View("CheckOutError", chkErr));
                }


                ViewBag.Bids        = bids;
                ViewBag.TotalAmount = String.Format("{0:C}", chkout.AmountOwed);
                ViewBag.Donations   = await _context.Donation.Where(o => bids.Select(a => a.DonationId).Contains(o.DonationID)).ToDictionaryAsync(e => e.DonationID);

                return(View(chkout));
            }
            else
            {
                var chkErr = new CheckOutError
                {
                    BidderId       = bidder.BidderId,
                    BidderFullName = bidder.FullName,
                    ErrorMessage   = "Bidder does not have any paddles, cannot bid or check-out."
                };

                return(View("CheckOutError", chkErr));
            }
        }