private void pictureBoxNewVenue_Click(object sender, EventArgs e)
        {
            VenueForm venueForm = new VenueForm();

            venueForm._isChildForm = true;
            if (venueForm.ShowDialog(this) == DialogResult.OK)
            {
                SAPVenueReadWrite venue =
                    new SAPVenueReadWrite(Config._dbConnectionName);
                comboBoxVenue.DataSource    = venue.SelectAll().Venue;
                comboBoxVenue.DisplayMember =
                    SAPVenueReadWrite._venueNameColumnName;
                comboBoxVenue.ValueMember =
                    SAPVenueReadWrite._venueIDColumnName;
                comboBoxVenue.Text = venueForm._venueName;
            }
            venueForm.Dispose();
        }
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     if (_currentVenueIndex >= 0 &&
         mode == EnumFormMode.ViewMode)
     {
         DataRow dr = _dtVenue.Rows[_currentVenueIndex];
         if (!(bool)dr["DelTag"])
         {
             return;
         }
         if (Message.DeleteMessage((string)dr[SAPVenueReadWrite._venueNameColumnName])
             == DialogResult.Yes)
         {
             SAPVenueReadWrite venueRW =
                 new SAPVenueReadWrite(Config._dbConnectionName);
             venueRW.Delete(Convert.ToInt32(dr[SAPVenueReadWrite._venueIDColumnName]));
             _dtVenue.Rows.Remove(dr);
             dr = _dtVenue.Rows[_currentVenueIndex];
         }
     }
 }
        private void EventList_Load(object sender, EventArgs e)
        {
            #region Initialize Venue Combobox

            SAPVenueReadWrite venue =
                new SAPVenueReadWrite(Config._dbConnectionName);

            comboBoxVenue.DataSource    = venue.SelectAll().Venue;
            comboBoxVenue.DisplayMember =
                SAPVenueReadWrite._venueNameColumnName;
            comboBoxVenue.ValueMember =
                SAPVenueReadWrite._venueIDColumnName;

            comboBoxVenue.SelectedIndex = -1;

            #endregion

            PopulateEvents();

            monthCalendarSchedules.BoldedDates = GetEventSchedules();
        }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (!IsValid())
            {
                return;
            }

            SAPVenueReadWrite venueRW =
                new SAPVenueReadWrite(Config._dbConnectionName);

            if (mode == EnumFormMode.EditMode)
            {
                #region modify record
                _locationMapImage = FileToByte(_fileLocationMapImage, _locationMapImage);
                _facilityImage    = FileToByte(_fileFacilityImage, _facilityImage);
                _venueImage       = FileToByte(_fileVenueImage, _venueImage);
                venueRW.Update(
                    _venueID,
                    textBoxName.Text.Trim(),
                    textBoxDescription.Text.Trim(),
                    textBoxStreet.Text.Trim(),
                    textBoxCity.Text.Trim(),
                    textBoxState.Text.Trim(),
                    textBoxPostalCode.Text.Trim(),
                    _locationMapImage,
                    _facilityImage,
                    _venueImage);
                _dtVenue.Rows[_rowIndex][SAPVenueReadWrite._venueNameColumnName] =
                    textBoxName.Text.Trim();
                _dtVenue.Rows[_rowIndex][SAPVenueReadWrite._venueDescriptionColumnName] =
                    textBoxDescription.Text.Trim();
                _dtVenue.Rows[_rowIndex][SAPVenueReadWrite._venueStreetColumnName] =
                    textBoxStreet.Text.Trim();
                _dtVenue.Rows[_rowIndex][SAPVenueReadWrite._venueCityColumnName] =
                    textBoxCity.Text.Trim();
                _dtVenue.Rows[_rowIndex][SAPVenueReadWrite._venueStateColumnName] =
                    textBoxState.Text.Trim();
                _dtVenue.Rows[_rowIndex][SAPVenueReadWrite._venuePostalCodeColumnName] =
                    textBoxPostalCode.Text.Trim();
                _dtVenue.Rows[_rowIndex][SAPVenueReadWrite._venueGeographicMapColumnName] =
                    _locationMapImage;
                _dtVenue.Rows[_rowIndex][SAPVenueReadWrite._venueImageColumnName] =
                    _facilityImage;
                _dtVenue.Rows[_rowIndex][SAPVenueReadWrite._venueFacilityMapColumnName] =
                    _venueImage;
                #endregion
            }
            else
            {
                #region insert record
                _locationMapImage = FileToByte(_fileLocationMapImage, null);
                _facilityImage    = FileToByte(_fileFacilityImage, null);
                _venueImage       = FileToByte(_fileVenueImage, null);
                venueRW.Insert(
                    textBoxName.Text.Trim(),
                    textBoxDescription.Text.Trim(),
                    textBoxStreet.Text.Trim(),
                    textBoxCity.Text.Trim(),
                    textBoxState.Text.Trim(),
                    textBoxPostalCode.Text.Trim(),
                    _locationMapImage,
                    _facilityImage,
                    _venueImage,
                    out _venueID);

                if (mode == EnumFormMode.CallbackAdd)
                {
                    _venueName   = textBoxName.Text.Trim();
                    DialogResult = DialogResult.OK;
                    Close();
                    return;
                }
                else
                {
                    //byte[] editIco = UtilityHelper.BitmapToByte(Resources.icoedit);
                    //byte[] delIco = UtilityHelper.BitmapToByte(Resources.icodelete);

                    _dtVenue.Rows.Add(
                        //editIco,
                        //delIco,
                        _venueID,
                        textBoxName.Text.Trim(),
                        textBoxDescription.Text.Trim(),
                        textBoxStreet.Text.Trim(),
                        textBoxCity.Text.Trim(),
                        textBoxState.Text.Trim(),
                        textBoxPostalCode.Text.Trim(),
                        _locationMapImage,
                        _facilityImage,
                        _venueImage,
                        true,
                        true);
                }
                #endregion
            }
            mode = EnumFormMode.ViewMode;
            dataGridViewVenue.Enabled = true;
            buttonCancel.Text         = "Close";
            buttonAddSave.Text        = "Add";
            UtilityHelper.SetToReadOnly(Controls);
        }
        private void VenueForm_Load(object sender, EventArgs e)
        {
            #region create grid
            SAPEventReadWrite eventRW =
                new SAPEventReadWrite(Config._dbConnectionName);
            SAPVenueReadWrite venueRW =
                new SAPVenueReadWrite(Config._dbConnectionName);
            _dtVenue = new DataTable();
            //_dtVenue.Columns.Add("EditIco", typeof(byte[]));
            //_dtVenue.Columns.Add("DelIco", typeof(byte[]));
            _dtVenue.Columns.Add("VenueID", typeof(int));
            _dtVenue.Columns.Add("VenueName", typeof(string));
            _dtVenue.Columns.Add("VenueDescription", typeof(string));
            _dtVenue.Columns.Add("VenueStreet", typeof(string));
            _dtVenue.Columns.Add("VenueCity", typeof(string));
            _dtVenue.Columns.Add("VenueState", typeof(string));
            _dtVenue.Columns.Add("VenuePostalCode", typeof(string));
            _dtVenue.Columns.Add("VenueGeographicMap", typeof(byte[]));
            _dtVenue.Columns.Add("VenueFacilityMap", typeof(byte[]));
            _dtVenue.Columns.Add("VenueImage", typeof(byte[]));
            _dtVenue.Columns.Add("EditTag", typeof(bool));
            _dtVenue.Columns.Add("DelTag", typeof(bool));

            //byte[] editIco = UtilityHelper.BitmapToByte(Resources.icoedit);
            //byte[] delIco = UtilityHelper.BitmapToByte(Resources.icodelete);
            //byte[] editDisableIco = UtilityHelper.BitmapToByte(Resources.icoedit_disabled);
            //byte[] delDisableIco = UtilityHelper.BitmapToByte(Resources.icodelete_disabled);

            bool editAble = false;
            bool delAble  = false;

            List <int> usedVenue = new List <int>();
            using (SAPDataReaderEvent rdrEvent =
                       eventRW.ReaderSelectAll())
            {
                if (rdrEvent.DataReader != null &&
                    rdrEvent.DataReader.HasRows)
                {
                    while (rdrEvent.DataReader.Read())
                    {
                        usedVenue.Add(rdrEvent.VenueID);
                    } //while (rdrEvent.DataReader.Read());
                }
            }

            using (SAPDataReaderVenue rdrVenue =
                       venueRW.ReaderSelectAll())
            {
                if (rdrVenue.DataReader != null &&
                    rdrVenue.DataReader.HasRows)
                {
                    while (rdrVenue.DataReader.Read())
                    {
                        //byte[] editImage = editIco;
                        //byte[] delImage = delIco;


                        bool tag = usedVenue.Contains(rdrVenue.VenueID);
                        delAble  = !tag;
                        editAble = !tag;

                        _dtVenue.Rows.Add(
                            //editImage,
                            //delImage,
                            rdrVenue.VenueID,
                            rdrVenue.VenueName,
                            rdrVenue.VenueDescription,
                            rdrVenue.VenueStreet,
                            rdrVenue.VenueCity,
                            rdrVenue.VenueState,
                            rdrVenue.VenuePostalCode,
                            rdrVenue.VenueGeographicMap,
                            rdrVenue.VenueFacilityMap,
                            rdrVenue.VenueImage,
                            editAble,
                            delAble);
                    } //while (rdrVenue.DataReader.Read());
                }
            }

            dataGridViewVenue.DataSource = _dtVenue;
            #endregion

            #region utilize grid
            GridHelper.HideColumns(
                dataGridViewVenue,
                SAPVenueReadWrite._venueIDColumnName,
                SAPVenueReadWrite._venueDescriptionColumnName,
                SAPVenueReadWrite._venueGeographicMapColumnName,
                SAPVenueReadWrite._venueFacilityMapColumnName,
                SAPVenueReadWrite._venueImageColumnName,
                "EditTag",
                "DelTag");
            string[] columns = new string[]
            {
                //"EditIco",
                //"DelIco",
                SAPVenueReadWrite._venueNameColumnName,
                SAPVenueReadWrite._venueStreetColumnName,
                SAPVenueReadWrite._venueCityColumnName,
                SAPVenueReadWrite._venueStateColumnName,
                SAPVenueReadWrite._venuePostalCodeColumnName
            };
            string[] titles = new string[]
            {
                //"",
                //"",
                "Venue",
                "Street",
                "City",
                "State",
                "Postal Code"
            };
            int[] gridWidth = new int[]
            {
                //20,
                //20,
                200,
                100,
                100,
                100,
                100
            };
            GridHelper.SetColumnTitle(
                dataGridViewVenue,
                columns,
                titles);
            GridHelper.SetWidthColumn(
                dataGridViewVenue,
                columns,
                gridWidth);
            #endregion

            mode = EnumFormMode.ViewMode;
            UtilityHelper.SetToReadOnly(Controls);

            if (_isChildForm)
            {
                mode = EnumFormMode.CallbackAdd;
                buttonAddSave.Text        = "Save";
                buttonCancel.Text         = "Cancel";
                dataGridViewVenue.Enabled = false;
                UtilityHelper.ClearTextbox(Controls);
                UtilityHelper.EnableControls(Controls);
            }
        }
Exemple #6
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);
        }
        private void frmEvent_Load(object sender, EventArgs e)
        {
            #region Initialize Venue Combobox
            SAPVenueReadWrite venue =
                new SAPVenueReadWrite(Config._dbConnectionName);
            comboBoxVenue.DataSource    = venue.SelectAll().Venue;
            comboBoxVenue.DisplayMember =
                SAPVenueReadWrite._venueNameColumnName;
            comboBoxVenue.ValueMember =
                SAPVenueReadWrite._venueIDColumnName;

            #endregion

            #region Get Event Types
            SAPEventTypeReadWrite eventTypeRW =
                new SAPEventTypeReadWrite(Config._dbConnectionName);
            SAPDataSetEventType.EventTypeDataTable dtEventType =
                eventTypeRW.SelectAll().EventType;

            comboBoxEventType.DataSource    = dtEventType;
            comboBoxEventType.DisplayMember = SAPEventTypeReadWrite._eventTypeNameColumnName;
            comboBoxEventType.ValueMember   = SAPEventTypeReadWrite._eventTypeIDColumnName;

            SAPEventActorReadWrite actors =
                new SAPEventActorReadWrite(Config._dbConnectionName);
            comboBoxActor.DataSource    = actors.SelectAll().EventActor;
            comboBoxActor.DisplayMember =
                SAPEventActorReadWrite._eventActorNameColumnName;
            comboBoxActor.ValueMember =
                SAPEventActorReadWrite._eventActorIDColumnName;
            #endregion

            #region Initialize Event Package Grid

            dataGridViewPackage.VirtualMode = true;

            DataGridViewTextBoxColumn columnPackageType =
                new DataGridViewTextBoxColumn();
            columnPackageType.HeaderText = "Name";
            columnPackageType.Name       = "ColumnName";
            columnPackageType.Width      = 70;
            columnPackageType.ReadOnly   = true;
            columnPackageType.Frozen     = true;
            columnPackageType.DefaultCellStyle.BackColor =
                Color.FromKnownColor(KnownColor.Control);
            columnPackageType.SortMode =
                DataGridViewColumnSortMode.NotSortable;
            dataGridViewPackage.Columns.Add(columnPackageType);

            DataGridViewTextBoxColumn columnPrice =
                new DataGridViewTextBoxColumn();
            columnPrice.HeaderText = "Price";
            columnPrice.Name       = "ColumnPrice";
            columnPrice.Width      = 85;
            columnPrice.DefaultCellStyle.Format    = "c";
            columnPrice.DefaultCellStyle.Alignment =
                DataGridViewContentAlignment.BottomRight;
            columnPrice.SortMode =
                DataGridViewColumnSortMode.NotSortable;
            dataGridViewPackage.Columns.Add(columnPrice);

            DataGridViewTextBoxColumn columnCost =
                new DataGridViewTextBoxColumn();
            columnCost.HeaderText = "Cost";
            columnCost.Name       = "ColumnCost";
            columnCost.Width      = 85;
            columnCost.DefaultCellStyle.Format    = "c";
            columnCost.DefaultCellStyle.Alignment =
                DataGridViewContentAlignment.BottomRight;
            columnCost.SortMode =
                DataGridViewColumnSortMode.NotSortable;
            dataGridViewPackage.Columns.Add(columnCost);

            SAPActorEventReadOnly actorEvent =
                new SAPActorEventReadOnly(Config._dbConnectionName);
            DataTable dtEventActor = new DataTable();
            dtEventActor.Columns.Add("ActorName", typeof(string));
            dtEventActor.Columns.Add("ActorID", typeof(string));
            if (_eventID > 0)
            {
                using (SAPDataReaderActorEvent rdrActorEvent =
                           actorEvent.ReaderSelectByEventID(_eventID))
                {
                    if (rdrActorEvent.DataReader != null &&
                        rdrActorEvent.DataReader.HasRows)
                    {
                        while (rdrActorEvent.DataReader.Read())
                        {
                            dtEventActor.Rows.Add(
                                rdrActorEvent.EventActorName,
                                rdrActorEvent.EventActorID);
                        } //while (rdrActorEvent.DataReader.Read());
                    }
                }
            }
            dsEventActor = new DataSet();
            dsEventActor.Tables.Add(dtEventActor);
            dataGridViewActor.DataSource = dsEventActor.Tables[0];

            #endregion

            #region Populate Values
            openFileDialog.FileName = string.Empty;
            _packageTypeList        = new List <PackageTypeList>();
            if (_eventID > 0)
            {
                SAPEventReadWrite eventRW =
                    new SAPEventReadWrite(Config._dbConnectionName);

                using (SAPDataReaderEvent rdrEvent =
                           eventRW.ReaderSelectByEventID(_eventID))
                {
                    rdrEvent.DataReader.Read();
                    textBoxName.Text             = rdrEvent.EventName;
                    textBoxDescription.Text      = rdrEvent.EventDescription;
                    dateTimePickerSchedule.Value = rdrEvent.EventDate;
                    comboBoxEventType.Text       = rdrEvent.EventTypeName;
                    comboBoxVenue.Text           = rdrEvent.VenueName;
                    monthCalendarSchedule.SetDate(rdrEvent.EventDate);
                    _packageTypeList.Add(
                        new PackageTypeList(
                            "Gold",
                            rdrEvent.GoldPackagePrice,
                            rdrEvent.GoldPackageTrueCost));
                    _packageTypeList.Add(
                        new PackageTypeList(
                            "Silver",
                            rdrEvent.SilverPackagePrice,
                            rdrEvent.SilverPackageTrueCost));
                    _packageTypeList.Add(
                        new PackageTypeList(
                            "Bronze",
                            rdrEvent.BronzePackagePrice,
                            rdrEvent.BronzePackageTrueCost));
                    _previousImage = rdrEvent.EventPhoto;
                    using (MemoryStream ms =
                               new MemoryStream(rdrEvent.EventPhoto, 0, rdrEvent.EventPhoto.Length))
                    {
                        ms.Write(rdrEvent.EventPhoto, 0, rdrEvent.EventPhoto.Length);
                        pictureBoxPoster.Image = Image.FromStream(ms, true);
                    }
                }
            }
            else
            {
                _packageTypeList.Add(new PackageTypeList("Gold", 0, 0));
                _packageTypeList.Add(new PackageTypeList("Silver", 0, 0));
                _packageTypeList.Add(new PackageTypeList("Bronze", 0, 0));
            }
            if (_isReadOnly)
            {
                UtilityHelper.SetToReadOnly(Controls);
                buttonSave.Enabled           = false;
                dataGridViewPackage.ReadOnly = true;
                GridHelper.HideColumns(
                    dataGridViewActor,
                    "ColumnActorID",
                    "ColumnDelete");
                buttonAddToList.Enabled    = false;
                pictureBoxNewVenue.Enabled = false;
            }

            pictureBoxNewVenue.Image = Resources.iconew;

            dataGridViewPackage.RowCount = _packageTypeList.Count;
            #endregion
        }