private static SeedEventDataList[] GetEvent(int packageID)
        {
            ArrayList arrEvent = new ArrayList();

            SAPPackageEventReadOnly packageEvent =
                new SAPPackageEventReadOnly(Config._dbConnectionName);

            using (SAPDataReaderPackageEvent rdrEvent =
                       packageEvent.ReaderSelectByPackageID(packageID))
            {
                if (rdrEvent.DataReader != null &&
                    rdrEvent.DataReader.HasRows)
                {
                    while (rdrEvent.DataReader.Read())
                    {
                        SeedEventDataList data = new SeedEventDataList();
                        data.VenueCity = rdrEvent.VenueCity;
                        data.EventID   = rdrEvent.EventID;
                        data.EventDate = rdrEvent.EventDate;
                        arrEvent.Add(data);
                    } //while (rdrEvent.DataReader.Read());
                }
            }
            return((SeedEventDataList[])arrEvent.ToArray(typeof(SeedEventDataList)));
        }
        private void BookEvent_Load(object sender, EventArgs e)
        {
            #region populate combobox country
            SAPRefCountryReadWrite country =
                new SAPRefCountryReadWrite(Config._dbConnectionName);
            comboBoxCountry.DataSource    = country.SelectAll().RefCountry;
            comboBoxCountry.DisplayMember = SAPRefCountryReadWrite._countryNameColumnName;
            comboBoxCountry.ValueMember   = SAPRefCountryReadWrite._countryCodeColumnName;
            #endregion

            #region populate combobox language
            SAPRefLanguageReadWrite language =
                new SAPRefLanguageReadWrite(Config._dbConnectionName);
            comboBoxLanguage.DataSource    = language.SelectAll().RefLanguage;
            comboBoxLanguage.DisplayMember = SAPRefLanguageReadWrite._languageColumnName;
            comboBoxLanguage.ValueMember   = SAPRefLanguageReadWrite._languageCodeColumnName;
            #endregion

            #region create grid
            SAPPackageEventReadOnly packageEvent =
                new SAPPackageEventReadOnly(Config._dbConnectionName);
            dtEventFlight = new DataTable();
            dtEventFlight.Columns.Add("EventName", typeof(string));
            dtEventFlight.Columns.Add("EventVenue", typeof(string));
            dtEventFlight.Columns.Add("EventDate", typeof(DateTime));
            dtEventFlight.Columns.Add("FlightDate", typeof(string));
            dtEventFlight.Columns.Add("FlightTime", typeof(string));
            dtEventFlight.Columns.Add("FlightAirport", typeof(string));
            dtEventFlight.Columns.Add("FlightConnection", typeof(string));
            dtEventFlight.Columns.Add("FlightAgency", typeof(string));
            dtEventFlight.Columns.Add("VenueCity", typeof(string));
            dtEventFlight.Columns.Add("EventID", typeof(int));

            using (SAPDataReaderPackageEvent rdrEvent =
                       packageEvent.ReaderSelectByPackageID(_packageID))
            {
                if (rdrEvent.DataReader != null &&
                    rdrEvent.DataReader.HasRows)
                {
                    while (rdrEvent.DataReader.Read())
                    {
                        dtEventFlight.Rows.Add(
                            rdrEvent.EventName,
                            rdrEvent.VenueName,
                            rdrEvent.EventDate,
                            string.Empty,
                            string.Empty,
                            string.Empty,
                            string.Empty,
                            string.Empty,
                            rdrEvent.VenueCity,
                            rdrEvent.EventID);
                    } //while (rdrEvent.DataReader.Read());
                }
            }
            dataGridViewEvent.DataSource = dtEventFlight;
            GridHelper.HideColumns(
                dataGridViewEvent,
                "FlightConnection",
                "FlightAgency",
                "VenueCity",
                "EventID");

            #endregion

            #region get customer from SAP
            dtCustomer = new DataTable();
            dtCustomer.Columns.Add("customername", typeof(string));
            dtCustomer.Columns.Add("customerid", typeof(string));

            PseudoProgressForm progress = new PseudoProgressForm();
            progress.ProgressLabel = "Querying SAP...";
            BackgroundWorker bgWorker = new BackgroundWorker();

            addCustomerItem = new AddCustomerItem(AddCustomer);

            bgWorker.DoWork +=
                delegate(object senderWorker, DoWorkEventArgs eWorker)
            {
                SAPCustomer sapCustomer = new SAPCustomer(Config.SAPUserName, Config.SAPPassword);
                if (sapCustomer.GetList() && sapCustomer._customerList.Length > 0)
                {
                    //customerList = sapCustomer._customerList;
                    customerList = new SortedList <string, BAPISCUDAT>();
                    foreach (BAPISCUDAT item in
                             sapCustomer._customerList)
                    {
                        if (!customerList.ContainsKey(item.CUSTOMERID))
                        {
                            customerList.Add(item.CUSTOMERID, item);
                            dtCustomer.Rows.Add(item.CUSTNAME, item.CUSTOMERID);
                        }
                    }
                }
            };

            bgWorker.RunWorkerCompleted +=
                delegate(object senderWorker, RunWorkerCompletedEventArgs eWorker)
            {
                progress.Close();
                progress.Dispose();
            };

            bgWorker.RunWorkerAsync();
            progress.ShowDialog();
            dtCustomer.DefaultView.Sort        = "customername";
            comboBoxCustomername.DataSource    = dtCustomer.DefaultView;
            comboBoxCustomername.DisplayMember = "customername";
            comboBoxCustomername.ValueMember   = "customerid";

            comboBoxCustomername.Text = string.Empty;
            #endregion
        }
        private void CreateEventSlide()
        {
            Slide slide;
            Shape pictureShape;
            Table table;

            //get statistics

            PseudoProgressForm progress = new PseudoProgressForm();

            progress.ProgressLabel = "Querying SAP...";
            BackgroundWorker backgroundWorker = new BackgroundWorker();

            backgroundWorker.DoWork +=
                delegate(object sender, DoWorkEventArgs e)
            {
                statList = FlightDetail.GetStatistics(_packageID);
            };
            backgroundWorker.RunWorkerCompleted +=
                delegate(object sender, RunWorkerCompletedEventArgs e)
            {
                progress.Close();
                progress.Dispose();
            };

            backgroundWorker.RunWorkerAsync();
            progress.ShowDialog();

            SAPPackageEventReadOnly eventReadOnly =
                new SAPPackageEventReadOnly(Config._dbConnectionName);

            using (SAPDataReaderPackageEvent rdrEvent =
                       eventReadOnly.ReaderSelectByPackageID(_packageID))
            {
                if (rdrEvent.DataReader != null &&
                    rdrEvent.DataReader.HasRows)
                {
                    while (rdrEvent.DataReader.Read())
                    {
                        string posterEventFile = string.Empty;
                        posterEventFile =
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
                                         "PackageImage" +
                                         _packageID.ToString() +
                                         "_" +
                                         rdrEvent.EventID.ToString() +
                                         ".jpg");

                        ByteToFile(rdrEvent.EventPhoto, posterEventFile);

                        #region event slide

                        slide = DuplicateSlide(slides[SlideTemplate.EventSlide]);

                        //event name
                        slide.Shapes[5].TextFrame.TextRange.Text = rdrEvent.EventName;

                        //event description
                        slide.Shapes[6].TextFrame.TextRange.Text = rdrEvent.EventDescription;

                        //event date
                        slide.Shapes[8].TextFrame.TextRange.Text = rdrEvent.EventDate.ToString("MM/dd/yyyy hh:mmtt");

                        //venue name + city
                        slide.Shapes[7].TextFrame.TextRange.Text = rdrEvent.VenueCity + ", " + rdrEvent.VenueState;

                        //event posters
                        slide.Shapes[2].Delete();
                        if (File.Exists(posterEventFile))
                        {
                            pictureShape = slide.Shapes.AddPicture(
                                posterEventFile,
                                MsoTriState.msoFalse,
                                MsoTriState.msoCTrue, imageLeft, imageTop, imageWidth, imageHeight);
                            pictureShape.ZOrder(MsoZOrderCmd.msoSendToBack);
                        }
                        #endregion

                        //create sports actor

                        //create pricing
                        slide = DuplicateSlide(slides[SlideTemplate.EventPricingSlide]);
                        table = slide.Shapes[4].Table;
                        if (table.Rows.Count == 4 && table.Columns.Count == 2)
                        {
                            table.Cell(2, 2).Shape.TextFrame.TextRange.Text = rdrEvent.GoldPackagePrice.ToString("c");
                            table.Cell(3, 2).Shape.TextFrame.TextRange.Text = rdrEvent.SilverPackagePrice.ToString("c");
                            table.Cell(4, 2).Shape.TextFrame.TextRange.Text = rdrEvent.BronzePackagePrice.ToString("c");
                            slide.Shapes[1].Delete();
                            if (File.Exists(posterEventFile))
                            {
                                pictureShape = slide.Shapes.AddPicture(
                                    posterEventFile,
                                    MsoTriState.msoFalse,
                                    MsoTriState.msoCTrue, imageLeft, imageTop, imageWidth, imageHeight);
                                pictureShape.ZOrder(MsoZOrderCmd.msoSendToBack);
                            }
                        }
                        else
                        {
                            slide.Delete();
                        }
                    } //while (rdrEvent.DataReader.Read());
                }
            }
        }