Пример #1
0
        public static PackageInfo GetPackageInfo()
        {
            PackageInfo packageInfoDataset = new PackageInfo();

            PackageInfo.PackageDataTable packageInfoPackageDataTable =
                packageInfoDataset.Package;

            PackageInfo.EventDataTable packageInfoEventDataTable =
                packageInfoDataset.Event;

            PackageInfo.FlightDataTable packageInfoFlightDataTable =
                packageInfoDataset.Flight;

            SAPPackageReadWrite package =
                new SAPPackageReadWrite(Config._dbConnectionName);

            SAPEventReadWrite events =
                new SAPEventReadWrite(Config._dbConnectionName);

            SAPVenueReadWrite venue =
                new SAPVenueReadWrite(Config._dbConnectionName);

            SAPPackageEventMapReadWrite packageEventMap =
                new SAPPackageEventMapReadWrite(Config._dbConnectionName);

            SAPFlight flightHelper = new SAPFlight(
                Config.SAPUserName, Config.SAPPassword);

            SAPDataSetPackage packageDataset = package.SelectAll();

            foreach (SAPDataSetPackage.PackageRow packageRow in packageDataset.Package.Rows)
            {
                PackageInfo.PackageRow packageInfoPackageRow =
                    packageInfoPackageDataTable.AddPackageRow(
                        packageRow.PackageID,
                        packageRow.PackageName,
                        packageRow.PackageDescription);

                SAPDataSetPackageEventMap packageEventMapDataset =
                    packageEventMap.SelectByPackageID(packageRow.PackageID);

                foreach (SAPDataSetPackageEventMap.PackageEventMapRow packageEventMapRow in packageEventMapDataset.PackageEventMap.Rows)
                {
                    SAPDataSetEvent eventDataset = events.SelectByEventID(packageEventMapRow.EventID);

                    foreach (SAPDataSetEvent.EventRow eventRow in eventDataset.Event.Rows)
                    {
                        PackageInfo.EventRow packageInfoEventRow =
                            packageInfoEventDataTable.AddEventRow(
                                eventRow.EventID,
                                packageInfoPackageRow,
                                eventRow.EventName,
                                eventRow.EventDescription,
                                eventRow.EventDate.ToString(),
                                eventRow.VenueName,
                                0,
                                0,
                                0);

                        string venueCity = string.Empty;
                        using (SAPDataReaderVenue venueReader = venue.ReaderSelectByVenueID(eventRow.VenueID))
                        {
                            if (venueReader.DataReader.HasRows)
                            {
                                venueReader.DataReader.Read();
                                venueCity = venueReader.VenueCity.ToUpper();
                            }
                        }

                        if (venueCity != string.Empty)
                        {
                            flightHelper.GetList(string.Empty, venueCity);
                            foreach (SAPServices.SAP_FLIGHTLIST.BAPISFLDAT flight in flightHelper._flightList)
                            {
                                //flight dates should be between today and before the event date
                                if (Convert.ToDateTime(flight.FLIGHTDATE) > DateTime.Today &&
                                    Convert.ToDateTime(flight.FLIGHTDATE) < eventRow.EventDate)
                                {
                                    flightHelper.CheckAvailability(flight.AIRLINEID, flight.CONNECTID, flight.FLIGHTDATE);

                                    PackageInfo.FlightRow packageInfoFlightRow =
                                        packageInfoFlightDataTable.AddFlightRow(
                                            packageInfoEventRow,
                                            flight.AIRLINE,
                                            flight.FLIGHTDATE,
                                            flight.DEPTIME,
                                            flight.AIRPORTFR,
                                            flight.CITYFROM,
                                            flight.AIRPORTTO,
                                            flight.CITYTO,
                                            flight.ARRDATE,
                                            flight.ARRTIME,
                                            flightHelper._availability.FIRSTFREE,
                                            flightHelper._availability.BUSINFREE,
                                            flightHelper._availability.ECONOFREE);

                                    packageInfoEventRow.GoldAvailability   += flightHelper._availability.FIRSTFREE;
                                    packageInfoEventRow.SilverAvailability += flightHelper._availability.BUSINFREE;
                                    packageInfoEventRow.BronzeAvailability += flightHelper._availability.ECONOFREE;
                                }
                            }
                        }
                    }
                }
            }
            return(packageInfoDataset);
        }
Пример #2
0
        public static Sales GetSalesData(int month, int year)
        {
            Sales salesDataset = new Sales();

            Sales.PackageDataTable     salesPackageDataTable     = salesDataset.Package;
            Sales.PackageSaleDataTable salesPackageSaleDataTable = salesDataset.PackageSale;

            Sales.EventDataTable     salesEventDataTable     = salesDataset.Event;
            Sales.EventSaleDataTable salesEventSaleDataTable = salesDataset.EventSale;

            Sales.FlightDataTable salesFlightDataTable = salesDataset.Flight;

            SAPPackageReadWrite package =
                new SAPPackageReadWrite(Config._dbConnectionName);

            SAPEventAttendeeReadWrite attendee =
                new SAPEventAttendeeReadWrite(Config._dbConnectionName);

            SAPEventAttendeeAgencyMapReadWrite eventAttendeeAgencyMap =
                new SAPEventAttendeeAgencyMapReadWrite(Config._dbConnectionName);

            SAPPackageEventMapReadWrite packageEventMap =
                new SAPPackageEventMapReadWrite(Config._dbConnectionName);

            SAPEventReadWrite events =
                new SAPEventReadWrite(Config._dbConnectionName);

            SAPFlightTrip flightTripHelper =
                new SAPFlightTrip(Config.SAPUserName, Config.SAPPassword);

            SAPFlightConnection flightConnectionHelper =
                new SAPFlightConnection(Config.SAPUserName, Config.SAPPassword);

            //fetch all packages
            SAPDataSetPackage packageDataset = package.SelectAll();

            //iterate through the packages
            foreach (SAPDataSetPackage.PackageRow packageRow in packageDataset.Package.Rows)
            {
                Sales.PackageRow salesPackageRow =
                    salesPackageDataTable.AddPackageRow(packageRow.PackageID, packageRow.PackageName);

                SAPDataSetEventAttendee attendeeDataset =
                    attendee.SelectByPackageID(packageRow.PackageID);

                SAPDataSetPackageEventMap packageEventMapDataset =
                    packageEventMap.SelectByPackageID(packageRow.PackageID);

                foreach (SAPDataSetEventAttendee.EventAttendeeRow eventAttendeeRow in attendeeDataset.EventAttendee.Rows)
                {
                    if ((eventAttendeeRow.Created.Month == month || month == 0) &&
                        (eventAttendeeRow.Created.Year == year || year == 0))
                    {
                        //build temp package table
                        Sales.PackageSaleRow salesPackageSaleRow =
                            salesPackageSaleDataTable.AddPackageSaleRow(
                                salesPackageRow,
                                eventAttendeeRow.EventAttendeeID,
                                eventAttendeeRow.Created,
                                eventAttendeeRow.DateOfBirth,
                                eventAttendeeRow.CustomerNumber,
                                0,
                                0);

                        SAPDataSetEventAttendeeAgencyMap eventAttendeeAgencyMapDataset =
                            eventAttendeeAgencyMap.SelectByEventAttendeeID(eventAttendeeRow.EventAttendeeID);

                        for (int i = 0; i < packageEventMapDataset.PackageEventMap.Rows.Count; i++)
                        {
                            SAPDataSetPackageEventMap.PackageEventMapRow packageEventMapRow =
                                packageEventMapDataset.PackageEventMap.Rows[i] as
                                SAPDataSetPackageEventMap.PackageEventMapRow;

                            SAPDataSetEvent eventDataset =
                                events.SelectByEventID(packageEventMapRow.EventID);

                            SAPDataSetEvent.EventRow eventRow = eventDataset.Event[0];

                            //assumes same record position as to event, need to revise!!!
                            //SAPDataSetEventAttendeeAgencyMap.EventAttendeeAgencyMapRow eventAttendeeAgencyMapRow =
                            //    eventAttendeeAgencyMapDataset.EventAttendeeAgencyMap.Rows[i] as
                            //    SAPDataSetEventAttendeeAgencyMap.EventAttendeeAgencyMapRow;

                            DataRow[] eventAttendeeAgencyMapDataRow =
                                eventAttendeeAgencyMapDataset.EventAttendeeAgencyMap.Select("EventID = " +
                                                                                            packageEventMapRow.EventID);

                            SAPDataSetEventAttendeeAgencyMap.EventAttendeeAgencyMapRow eventAttendeeAgencyMapRow =
                                eventAttendeeAgencyMapDataRow[0] as
                                SAPDataSetEventAttendeeAgencyMap.EventAttendeeAgencyMapRow;

                            Sales.EventRow salesEventRow = salesEventDataTable.FindByEventID(eventRow.EventID);
                            if (salesEventRow == null)
                            {
                                salesEventRow = salesEventDataTable.AddEventRow(
                                    eventRow.EventID,
                                    eventRow.EventName,
                                    eventRow.GoldPackagePrice,
                                    eventRow.SilverPackagePrice,
                                    eventRow.BronzePackagePrice,
                                    eventRow.GoldPackageTrueCost,
                                    eventRow.SilverPackageTrueCost,
                                    eventRow.BronzePackageTrueCost);
                            }

                            salesEventSaleDataTable.AddEventSaleRow(
                                salesEventRow,
                                packageRow.PackageID,
                                eventAttendeeRow.EventAttendeeID,
                                eventAttendeeAgencyMapRow.AgencyNumber,
                                eventAttendeeAgencyMapRow.TripNumber,
                                string.Empty,
                                0,
                                0);
                        }
                    }
                }
            }

            foreach (Sales.PackageSaleRow salesPackageSalesRow in salesPackageSaleDataTable.Rows)
            {
                foreach (DataRow row in salesPackageSalesRow.GetChildRows("PackageSale_EventSale"))
                {
                    Sales.EventSaleRow salesEventSaleRow = row as Sales.EventSaleRow;

                    flightTripHelper.GetList(
                        salesPackageSalesRow.CustomerNumber.Trim(),
                        salesEventSaleRow.AgencyNumber);

                    foreach (SAPServices.SAP_FLIGHTTRIPLIST.BAPISTRDAT trip in flightTripHelper._bapiFlightTripList)
                    {
                        if (salesEventSaleRow.TripNumber == trip.TRIPNUMBER)
                        {
                            flightConnectionHelper.GetDetail(
                                trip.FLCONN1,
                                trip.FLDATE1,
                                string.Empty,
                                salesEventSaleRow.AgencyNumber);

                            Sales.EventRow salesEventRow =
                                salesEventDataTable.FindByEventID(salesEventSaleRow.EventID);

                            decimal ticketPrice = 0;
                            switch (trip.CLASS)
                            {
                            case "F":
                                salesEventSaleRow.Cost        = salesEventRow.GoldPackageCost;
                                salesEventSaleRow.Price       = salesEventRow.GoldPackagePrice;
                                salesEventSaleRow.PackageType = "Gold";
                                ticketPrice =
                                    trip.NUMADULT == 1
                                            ? flightConnectionHelper._bapiPrice.PRICE_FST1
                                            :
                                    trip.NUMCHILD == 1
                                            ? flightConnectionHelper._bapiPrice.PRICE_FST2
                                            :
                                    trip.NUMINFANT == 1
                                            ? flightConnectionHelper._bapiPrice.PRICE_FST3
                                            : 0;
                                break;

                            case "C":
                                salesEventSaleRow.Cost        = salesEventRow.SilverPackageCost;
                                salesEventSaleRow.Price       = salesEventRow.SilverPackagePrice;
                                salesEventSaleRow.PackageType = "Silver";
                                ticketPrice =
                                    trip.NUMADULT == 1
                                            ? flightConnectionHelper._bapiPrice.PRICE_BUS1
                                            :
                                    trip.NUMCHILD == 1
                                            ? flightConnectionHelper._bapiPrice.PRICE_BUS2
                                            :
                                    trip.NUMINFANT == 1
                                            ? flightConnectionHelper._bapiPrice.PRICE_BUS3
                                            : 0;
                                break;

                            case "Y":
                                salesEventSaleRow.Cost        = salesEventRow.BronzePackageCost;
                                salesEventSaleRow.Price       = salesEventRow.BronzePackagePrice;
                                salesEventSaleRow.PackageType = "Bronze";
                                ticketPrice =
                                    trip.NUMADULT == 1
                                            ? flightConnectionHelper._bapiPrice.PRICE_ECO1
                                            :
                                    trip.NUMCHILD == 1
                                            ? flightConnectionHelper._bapiPrice.PRICE_ECO2
                                            :
                                    trip.NUMINFANT == 1
                                            ? flightConnectionHelper._bapiPrice.PRICE_ECO3
                                            : 0;
                                break;
                            }

                            salesPackageSalesRow.Cost  += salesEventSaleRow.Cost;
                            salesPackageSalesRow.Price += salesEventSaleRow.Price;

                            salesFlightDataTable.AddFlightRow(
                                salesEventSaleRow,
                                trip.FLCONN1,
                                trip.FLDATE1,
                                trip.CLASS,
                                ticketPrice,
                                trip.NUMADULT,
                                trip.NUMCHILD,
                                trip.NUMINFANT);
                        }
                    }
                }
            }
            return(salesDataset);
        }