예제 #1
0
 private AssociatedEventList GetItem(int eventID)
 {
     if (_eventList == null)
     {
         _eventList = new Dictionary <int, AssociatedEventList>();
         SAPEventReadWrite eventRW =
             new SAPEventReadWrite(Config._dbConnectionName);
         using (SAPDataReaderEvent readerEvent =
                    eventRW.ReaderSelectAll())
         {
             if (readerEvent.DataReader != null &&
                 readerEvent.DataReader.HasRows)
             {
                 while (readerEvent.DataReader.Read())
                 {
                     AssociatedEventList item = new AssociatedEventList();
                     item.EventID          = readerEvent.EventID;
                     item.EventName        = readerEvent.EventName;
                     item.EventGoldPrice   = readerEvent.GoldPackagePrice;
                     item.EventSilverPrice = readerEvent.SilverPackagePrice;
                     item.EventBronzePrice = readerEvent.BronzePackagePrice;
                     _eventList.Add(item.EventID, item);
                 } //while (readerEvent.DataReader.Read());
             }
         }
     }
     if (_eventList.ContainsKey(eventID))
     {
         return(_eventList[eventID]);
     }
     return(null);
 }
        private void GetEventList()
        {
            _sourceEventList = new List <AssociatedEventList>();
            SAPEventReadWrite eventRW =
                new SAPEventReadWrite(Config._dbConnectionName);

            using (SAPDataReaderEvent readerEvent =
                       eventRW.ReaderSelectAll())
            {
                if (readerEvent.DataReader != null &&
                    readerEvent.DataReader.HasRows)
                {
                    while (readerEvent.DataReader.Read())
                    {
                        AssociatedEventList item = new AssociatedEventList();
                        item.EventID          = readerEvent.EventID;
                        item.EventName        = readerEvent.EventName;
                        item.EventDate        = readerEvent.EventDate;
                        item.EventGoldPrice   = readerEvent.GoldPackagePrice;
                        item.EventSilverPrice = readerEvent.SilverPackagePrice;
                        item.EventBronzePrice = readerEvent.BronzePackagePrice;
                        item.EventVenue       = readerEvent.VenueName;
                        _sourceEventList.Add(item);
                    } //while (readerEvent.DataReader.Read());
                }
            }

            comboBoxName.DataSource    = _sourceEventList;
            comboBoxName.DisplayMember = "EventName";
            comboBoxName.ValueMember   = "EventID";
        }
예제 #3
0
        private void GetAssociatedEvents()
        {
            dataGridViewEvents.RowCount = 0;
            SourceEvent = new List <AssociatedEventList>();
            decimal price = 0;

            SAPPackageEventMapReadWrite eventMap =
                new SAPPackageEventMapReadWrite(Config._dbConnectionName);

            using (SAPDataReaderPackageEventMap readerEventMap =
                       eventMap.ReaderSelectByPackageID(_packageID))
            {
                if (readerEventMap.DataReader != null &&
                    readerEventMap.DataReader.HasRows)
                {
                    while (readerEventMap.DataReader.Read())
                    {
                        AssociatedEventList item =
                            GetItem(readerEventMap.EventID);
                        if (item != null)
                        {
                            price           += item.EventGoldPrice;
                            item.PackageType = "Gold";
                            SourceEvent.Add(item);
                        }
                    } //while (readerEventMap.DataReader.Read());
                }
            }
            labelTotalPrice.Text        = price.ToString("c");
            dataGridViewEvents.RowCount = SourceEvent.Count;
        }
        private void buttonNewAssociatedEvent_Click(object sender, EventArgs e)
        {
            PackageEventPickerForm pickEvent = new PackageEventPickerForm();

            if (pickEvent.ShowDialog(this) == DialogResult.OK)
            {
                if (pickEvent._associatedEvent != null)
                {
                    AssociatedEventList item = pickEvent._associatedEvent;
                    int indexDeleted         = IndexFromDeleted(item.EventID);
                    if (indexDeleted != -1)
                    {
                        item.IsNewID = false;
                        _removedEvent.RemoveAt(indexDeleted);
                        _sourceEvent.Add(item);
                    }
                    else if (IsNewID(item.EventID))
                    {
                        item.IsNewID = true;
                        _sourceEvent.Add(item);
                    }
                    dataGridViewEvents.RowCount = _sourceEvent.Count;
                }
            }
        }
 private void comboBoxName_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBoxName.SelectedIndex > -1 &&
         (_sourceEventList.Count - 1) >= comboBoxName.SelectedIndex)
     {
         AssociatedEventList item = _sourceEventList[comboBoxName.SelectedIndex];
         textBoxDate.Text  = item.EventDate.ToString();
         textBoxVenue.Text = item.EventVenue;
     }
 }
 private void dataGridViewEvents_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex != 6)
     {
         AssociatedEventList item      = _sourceEvent[e.RowIndex];
         EventForm           eventForm = new EventForm();
         eventForm._isReadOnly = true;
         eventForm._eventID    = item.EventID;
         eventForm.ShowDialog(this);
         eventForm.Dispose();
     }
 }
 private void buttonDeleteAssociatedEvent_Click(object sender, EventArgs e)
 {
     if (_currentEventIndex >= 0)
     {
         AssociatedEventList assocList = _sourceEvent[_currentEventIndex];
         if (Message.DeleteMessage(assocList.EventName) == DialogResult.Yes)
         {
             _removedEvent.Add(_sourceEvent[_currentEventIndex]);
             _sourceEvent.RemoveAt(_currentEventIndex);
             dataGridViewEvents.RowCount = _sourceEvent.Count;
         }
     }
 }
 private int IndexFromDeleted(int eventID)
 {
     for (int index = 0; index < _removedEvent.Count; index++)
     {
         AssociatedEventList item =
             _removedEvent[index];
         if (item.EventID == eventID && !item.IsNewID)
         {
             return(index);
         }
     }
     return(-1);
 }
예제 #9
0
        private void dataGridViewEvents_CellValuePushed(object sender, DataGridViewCellValueEventArgs e)
        {
            if (SourceEvent.Count == 0)
            {
                return;
            }

            AssociatedEventList currentEvent =
                SourceEvent[e.RowIndex];

            switch (dataGridViewEvents.Columns[e.ColumnIndex].Name)
            {
            case "PackageType":
                currentEvent.PackageType = e.Value.ToString();
                SourceEvent[e.RowIndex]  = currentEvent;
                SetTotalPrice();
                break;
            }
        }
 private void buttonAssociate_Click(object sender, EventArgs e)
 {
     _associatedEvent = new AssociatedEventList();
     if (_sourceEventList[comboBoxName.SelectedIndex] != null)
     {
         _associatedEvent =
             _sourceEventList[comboBoxName.SelectedIndex];
     }
     if (_associatedEvent != null)
     {
         this.DialogResult = DialogResult.OK;
     }
     else
     {
         this.DialogResult = DialogResult.Cancel;
         _associatedEvent  = null;
     }
     Close();
 }
예제 #11
0
        private void dataGridViewEvents_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
        {
            if (SourceEvent.Count == 0)
            {
                return;
            }

            AssociatedEventList currentEvent =
                SourceEvent[e.RowIndex];

            switch (dataGridViewEvents.Columns[e.ColumnIndex].Name)
            {
            case "EventName":
                e.Value = currentEvent.EventName;
                break;

            case "PackageType":
                e.Value = currentEvent.PackageType;
                break;
            }
        }
        private void dataGridViewEvents_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
        {
            if (_sourceEvent.Count == 0)
            {
                return;
            }

            AssociatedEventList currentEvent =
                _sourceEvent[e.RowIndex];

            switch (dataGridViewEvents.Columns[e.ColumnIndex].Name)
            {
            case EventNameColumn:
                e.Value = currentEvent.EventName;
                break;

            case EventVenueColumn:
                e.Value = currentEvent.EventVenue;
                break;

            case EventDateColumn:
                e.Value = currentEvent.EventDate;
                break;

            case EventGoldPriceColumn:
                e.Value = currentEvent.EventGoldPrice.ToString();
                break;

            case EventSilverPriceColumn:
                e.Value = currentEvent.EventSilverPrice.ToString();
                break;

            case EventBronzePriceColumn:
                e.Value = currentEvent.EventBronzePrice.ToString();
                break;
            }
        }
        private void PopulateItems()
        {
            _sourceEvent = new List <AssociatedEventList>();
            if (_packageID > 0)
            {
                //get associated events
                SAPPackageEventMapReadWrite eventMap =
                    new SAPPackageEventMapReadWrite(Config._dbConnectionName);

                using (SAPDataReaderPackageEventMap readerEventMap =
                           eventMap.ReaderSelectByPackageID(_packageID))
                {
                    if (readerEventMap.DataReader != null &&
                        readerEventMap.DataReader.HasRows)
                    {
                        while (readerEventMap.DataReader.Read())
                        {
                            AssociatedEventList item =
                                GetItem(readerEventMap.EventID);
                            item.EventID      = readerEventMap.EventID;
                            item.IsNewID      = false;
                            item.PackageMapID = readerEventMap.PackageEventMapID;
                            _sourceEvent.Add(item);
                        }// while (readerEventMap.DataReader.Read());
                    }
                }
                //get pacakage info
                SAPPackageReadWrite package =
                    new SAPPackageReadWrite(Config._dbConnectionName);
                using (SAPDataReaderPackage readerPackage =
                           package.ReaderSelectByPackageID(_packageID))
                {
                    if (readerPackage.DataReader != null &&
                        readerPackage.DataReader.HasRows)
                    {
                        readerPackage.DataReader.Read();
                        textBoxName.Text        = readerPackage.PackageName;
                        textBoxDescription.Text = readerPackage.PackageDescription;
                        pictureBoxPoster.Image  =
                            UtilityHelper.ByteToImage(readerPackage.PackageImage);
                        _imageSelected = readerPackage.PackageImage;
                    }
                }
            }

            #region Create Datagrid
            dataGridViewEvents.VirtualMode = true;
            dataGridViewEvents.Columns.Add(
                CreateColumn("Name", EventNameColumn, 100, ""));
            dataGridViewEvents.Columns.Add(
                CreateColumn("Date", EventDateColumn, 100, ""));
            dataGridViewEvents.Columns.Add(
                CreateColumn("Venue", EventVenueColumn, 100, ""));
            dataGridViewEvents.Columns.Add(
                CreateColumn("Gold Price", EventGoldPriceColumn, 75, "c"));
            dataGridViewEvents.Columns.Add(
                CreateColumn("Silver", EventSilverPriceColumn, 75, "c"));
            dataGridViewEvents.Columns.Add(
                CreateColumn("Bronze", EventBronzePriceColumn, 75, "c"));


            #endregion

            _removedEvent = new List <AssociatedEventList>();
            dataGridViewEvents.RowCount = _sourceEvent.Count;
        }
 private void buttonClose_Click(object sender, EventArgs e)
 {
     this.DialogResult = DialogResult.Cancel;
     _associatedEvent  = null;
     Close();
 }