/// <summary>
        /// Arik Chadima
        /// Created: 2015/4/16 Binds the hosted report viewer to the PrintableInvoice with the given
        ///          guest with the guestID.
        /// </summary>
        /// <param name="guestId">guest id of the guest to use for the invoice</param>
        /// <returns>bool successful</returns>
        /// <remarks>Updated by Arik Chadima 2015/4/17</remarks>
        /// <exception cref="WanderingTurtleException" />
        public void BuildInvoice(int guestId)
        {
            //builds the managers required
            InvoiceManager invoiceManager = new InvoiceManager();
            HotelGuestManager guestManager = new HotelGuestManager();

            try
            {
                RvHostArea.LocalReport.DataSources.Clear();
                ReportDataSource reportDataSource1 = new ReportDataSource
                {
                    Name = "HotelGuestDataset"
                };
                //Name of the report dataset in our .RDLC file
                List<HotelGuest> guestSet = new List<HotelGuest>();
                var foundGuest = guestManager.GetHotelGuest(guestId);
                guestSet.Add(foundGuest);
                reportDataSource1.Value = guestSet;
                RvHostArea.LocalReport.DataSources.Add(reportDataSource1);

                ReportDataSource reportDataSource2 = new ReportDataSource
                {
                    Name = "InvoiceDetailsDataset"
                };
                //Name of the report dataset in our .RDLC file
                List<InvoiceDetails> invoiceSet = new List<InvoiceDetails>
                {
                    invoiceManager.RetrieveInvoiceByGuest(guestId)
                };
                reportDataSource2.Value = invoiceSet;
                RvHostArea.LocalReport.DataSources.Add(reportDataSource2);

                ReportDataSource reportDataSource3 = new ReportDataSource
                {
                    Name = "BookingDetailsSet",
                    Value = invoiceManager.RetrieveGuestBookingDetailsList(guestId)
                };
                //Name of the report dataset in our .RDLC file
                RvHostArea.LocalReport.DataSources.Add(reportDataSource3);

                ReportDataSource reportDataSource4 = new ReportDataSource
                {
                    Name = "ZipCodeDataset"
                };
                //Name of the report dataset in our .RDLC file
                List<CityState> zipSet = new List<CityState>
                {
                    foundGuest.CityState
                };
                reportDataSource4.Value = zipSet;
                RvHostArea.LocalReport.DataSources.Add(reportDataSource4);

                RvHostArea.LocalReport.ReportEmbeddedResource = "com.WanderingTurtle.FormPresentation.Views.PrintableInvoice.rdlc";
                RvHostArea.RefreshReport();
            }
            catch (Exception ex)
            {
                throw new WanderingTurtleException(this, ex);
            }
        }
Example #2
0
        /// <summary>
        /// Arik Chadima
        /// Created: 2015/5/1
        /// Assembles and returns an AccountingDetails Object with booking details for invoices and supplier listings for closed out invoices within the start and end params
        /// </summary>
        /// <param name="start">start date of invoices</param>
        /// <param name="end">end date of invoices</param>
        /// <returns>AccountingDetails with object data as requested by the params</returns>
        /// <remarks>
        /// Arik Chadima
        /// Updated: 2015/05/01
        /// Implemented method from just a stub to complete.
        /// Arik Chadima
        /// Updated 2015/05/05
        /// Added try-catch blocks for "dangerous" code.
        /// </remarks>
        /// <exception cref="ArgumentNullException"><paramref name="match" /> is null.</exception>
        public AccountingDetails GetAccountingDetails(DateTime start, DateTime end)
        {
            AccountingDetails details = new AccountingDetails
            {
                StartDate = start,
                EndDate   = end
            };
            InvoiceManager        im               = new InvoiceManager();
            BookingManager        bm               = new BookingManager();
            List <ItemListing>    listings         = ItemListingAccessor.GetAllItemListingList();
            List <InvoiceDetails> inactiveInvoices = InvoiceAccessor.GetAllInvoicesList().FindAll(i => i.Active == false && i.DateOpened >= start && i.DateClosed <= end);
            List <BookingDetails> bookings         = new List <BookingDetails>();
            List <int>            listingIDs       = new List <int>();

            foreach (InvoiceDetails i in inactiveInvoices)
            {
                var guestBookings = im.RetrieveGuestBookingDetailsList(i.HotelGuestID);
                details.Invoices.Add(new AccountingInvoiceDetails {
                    InvoiceInformation = i, Bookings = guestBookings
                });                                                                                                      //translations into a "lower" subset.

                foreach (BookingDetails bd in guestBookings)
                {
                    bookings.Add(bd);
                    if (!listingIDs.Contains(bd.ItemListID))
                    {
                        listingIDs.Add(bd.ItemListID);
                    }
                }
            }

            var suppliers = SupplierAccessor.GetSupplierList();

            foreach (Supplier s in suppliers)
            {
                IEnumerable <int> itemIDs = listings.FindAll(l => listingIDs.Contains(l.ItemListID)).Select(l => l.ItemListID);
                var iDs = itemIDs as IList <int> ?? itemIDs.ToList();
                List <ItemListingDetails> items = iDs.Select(i => bm.RetrieveItemListingDetailsList(i)).ToList();

                //probably too condensed, but it compiles everyting necessary for stuffs.
                details.SupplierListings.Add(new AccountingSupplierListingDetails {
                    Vendor = s, Items = items, Bookings = bookings.FindAll(b => iDs.Contains(b.ItemListID))
                });
            }

            return(details);
        }
        /// <summary>
        /// Arik Chadima 
        /// Created: 2015/4/24
        /// 
        /// Checks the user's pin and if it is valid, shows what bookings they've selected.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            lblError.Visible = false;
            BookingManager hgm = new BookingManager();
            if (txtLogin.Text.ValidateAlphaNumeric(6, 6))
            {
                try
                {
                    var foundGuest = hgm.CheckValidPIN(txtLogin.Text);

                    InvoiceManager im = new InvoiceManager();
                    var bookings = im.RetrieveGuestBookingDetailsList((int)foundGuest.HotelGuestID);
                    repBookings.DataSource = bookings;
                    repBookings.DataBind();
                    var totalPrice = bookings.Sum(x => x.TotalCharge);
                    GuestFullName.Text = foundGuest.GetFullName;
                    Address1.Text = foundGuest.Address1;
                    Address2.Text = foundGuest.Address2;
                    var cityState = foundGuest.CityState;
                    CityStateZip.Text = cityState.City + ", " + cityState.State + "  " + cityState.Zip;
                    EmailAddress.Text = foundGuest.EmailAddress;
                    PhoneNumber.Text = foundGuest.PhoneNumber;
                    TotalPrice.Text = String.Format("{0:c}", totalPrice);
                    loginDiv.Visible = false;
                    guestDetailsDiv.Visible = true;

                }
                catch (ApplicationException)
                {
                    showError("The pin entered is not active or does not exist.");
                    lblError.Visible = true;
                    txtLogin.Text = "";
                }
                catch (Exception)
                {
                    showError("There was an error fetching data.");
                    lblError.Visible = true;
                    txtLogin.Text = "";
                }
            }
            else
            {
                showError("The pin you enterred was not formatted correctly.<br>It must be 6 alphanumeric characters.");
                lblError.Visible = true;
            }
        }
        /// <summary>
        /// Arik Chadima
        /// Created: 2015/5/1
        /// Assembles and returns an AccountingDetails Object with booking details for invoices and supplier listings for closed out invoices within the start and end params
        /// </summary>
        /// <param name="start">start date of invoices</param>
        /// <param name="end">end date of invoices</param>
        /// <returns>AccountingDetails with object data as requested by the params</returns>
        /// <remarks>
        /// Arik Chadima
        /// Updated: 2015/05/01
        /// Implemented method from just a stub to complete.
        /// Arik Chadima
        /// Updated 2015/05/05
        /// Added try-catch blocks for "dangerous" code.
        /// </remarks>
        /// <exception cref="ArgumentNullException"><paramref name="match" /> is null.</exception>
        public AccountingDetails GetAccountingDetails(DateTime start, DateTime end)
        {
            AccountingDetails details = new AccountingDetails
            {
                StartDate = start,
                EndDate = end
            };
            InvoiceManager im = new InvoiceManager();
            BookingManager bm = new BookingManager();
            List<ItemListing> listings = ItemListingAccessor.GetAllItemListingList();
            List<InvoiceDetails> inactiveInvoices = InvoiceAccessor.GetAllInvoicesList().FindAll(i => i.Active == false && i.DateOpened >= start && i.DateClosed <= end);
            List<BookingDetails> bookings = new List<BookingDetails>();
            List<int> listingIDs = new List<int>();

            foreach (InvoiceDetails i in inactiveInvoices)
            {
                var guestBookings = im.RetrieveGuestBookingDetailsList(i.HotelGuestID);
                details.Invoices.Add(new AccountingInvoiceDetails { InvoiceInformation = i, Bookings = guestBookings }); //translations into a "lower" subset.

                foreach (BookingDetails bd in guestBookings)
                {
                    bookings.Add(bd);
                    if (!listingIDs.Contains(bd.ItemListID))
                    {
                        listingIDs.Add(bd.ItemListID);
                    }
                }
            }

            var suppliers = SupplierAccessor.GetSupplierList();

            foreach (Supplier s in suppliers)
            {
                IEnumerable<int> itemIDs = listings.FindAll(l => listingIDs.Contains(l.ItemListID)).Select(l => l.ItemListID);
                var iDs = itemIDs as IList<int> ?? itemIDs.ToList();
                List<ItemListingDetails> items = iDs.Select(i => bm.RetrieveItemListingDetailsList(i)).ToList();

                //probably too condensed, but it compiles everyting necessary for stuffs.
                details.SupplierListings.Add(new AccountingSupplierListingDetails { Vendor = s, Items = items, Bookings = bookings.FindAll(b => iDs.Contains(b.ItemListID)) });
            }

            return details;
        }