private void SelectYearForm_Load(object sender, EventArgs e) { SAPEventAttendeeReadWrite attendee = new SAPEventAttendeeReadWrite(Config._dbConnectionName); SAPDataReaderEventAttendee readerAttendee = attendee.ReaderSelectAll(); if (readerAttendee.DataReader.HasRows) { while (readerAttendee.DataReader.Read()) { int year = readerAttendee.Created.Year; if (!comboBoxYear.Items.Contains(year)) { comboBoxYear.Items.Add(year); } }// while (readerAttendee.DataReader.Read()); } else { comboBoxYear.Items.Add("No Data"); comboBoxYear.SelectedIndex = 0; } }
public static StatisticList GetStatistics(int packageID) { StatisticList statList = new StatisticList(); SortedDictionary <string, int> locationCount = new SortedDictionary <string, int>(); SortedDictionary <string, string> customerList = new SortedDictionary <string, string>(); SAPEventAttendeeAgencyMapReadWrite eventTrip = new SAPEventAttendeeAgencyMapReadWrite(Config._dbConnectionName); SAPEventAttendeeReadWrite eventAttendee = new SAPEventAttendeeReadWrite(Config._dbConnectionName); #region get customer list first SAPCustomer sapCustomer = new SAPCustomer(Config.SAPUserName, Config.SAPPassword); if (sapCustomer.GetList()) { foreach (SAPServices.SAP_FLIGHTCUSTOMERLIST.BAPISCUDAT customerItem in sapCustomer._customerList) { if (!customerList.ContainsKey(customerItem.CUSTOMERID)) { customerList.Add( customerItem.CUSTOMERID, customerItem.CITY); } } } #endregion #region get statistic using (SAPDataReaderEventAttendeeAgencyMap rdrTrip = eventTrip.ReaderSelectByPackageID(packageID)) { if (rdrTrip.DataReader != null && rdrTrip.DataReader.HasRows) { SAPFlightTrip flightTrip = new SAPFlightTrip(Config.SAPUserName, Config.SAPPassword); while (rdrTrip.DataReader.Read()) { if (flightTrip.GetList( rdrTrip.CustomerNumber.Trim(), rdrTrip.AgencyNumber.Trim())) { SAPServices.SAP_FLIGHTTRIPLIST.BAPISTRDAT[] _bapiFlightTripList = flightTrip._bapiFlightTripList; foreach (SAPServices.SAP_FLIGHTTRIPLIST.BAPISTRDAT _bapiFlightTrip in _bapiFlightTripList) { if (_bapiFlightTrip.TRIPNUMBER != rdrTrip.TripNumber.Trim()) { continue; } statList.AdultAgeStat += _bapiFlightTrip.NUMADULT; statList.ChildAgeStat += _bapiFlightTrip.NUMCHILD; statList.InfantAgeStat += _bapiFlightTrip.NUMINFANT; switch (_bapiFlightTrip.CLASS) { case "Y": statList.FirstClassStat++; break; case "C": statList.BusinessClassStat++; break; case "F": statList.EconomyClassStat++; break; } } } } //while (rdrTrip.DataReader.Read()); } } #endregion using (SAPDataReaderEventAttendee rdrEventAttendee = eventAttendee.ReaderSelectByPackageID(packageID)) { if (rdrEventAttendee.DataReader != null && rdrEventAttendee.DataReader.HasRows) { while (rdrEventAttendee.DataReader.Read()) { //location demographics if (customerList.ContainsKey(rdrEventAttendee.CustomerNumber.Trim())) { string location = customerList[rdrEventAttendee.CustomerNumber.Trim()].ToUpper(); if (locationCount.ContainsKey(location)) { locationCount[location]++; } else { locationCount.Add(location, 1); } } } //while (rdrEventAttendee.DataReader.Read()); } } Population populate = null; if (locationCount.Count > 0) { populate = new Population(); Population.PopulationTableDataTable dt = populate.PopulationTable; foreach (KeyValuePair <string, int> kvp in locationCount) { dt.AddPopulationTableRow( kvp.Key, kvp.Value); } } statList.LocationStat = populate; return(statList); }