Ejemplo n.º 1
0
        public override void Activate()
        {
            Reservation = Values.SafeGetValue <Reservation>("Reservation");

            if (Reservation == null)
            {
                IsNewRecord = true;
                View.NumericUpDownVisitorAmount.Increment = 1;
                View.NumericUpDownVisitorAmount.Value     = View.NumericUpDownVisitorAmount.Minimum;
                View.ButtonAddEvent.Enabled      = true;
                View.ButtonAddReservee.Enabled   = true;
                View.ButtonAddProduct.Enabled    = true;
                View.ButtonDeleteProduct.Enabled = true;
                View.InteractiveMap.Clear();

                View.TextBoxReservee.Clear();
                View.TextBoxEvent.Clear();
                View.DataGridViewProducts.DataSource = null;
            }
            else
            {
                IsNewRecord = false;

                // Reset everything.
                View.NumericUpDownVisitorAmount.Increment = 0;
                View.ButtonAddEvent.Enabled      = false;
                View.ButtonAddReservee.Enabled   = false;
                View.ButtonAddProduct.Enabled    = false;
                View.ButtonDeleteProduct.Enabled = false;
                View.InteractiveMap.Clear();

                // Fill TextBoxReservee.
                Reservee reservee =
                    Reservee.Select("RESERVEEID = " + Reservation.ReserveeId.ToSqlFormat()).FirstOrDefault();
                if (reservee != null)
                {
                    View.TextBoxReservee.Text = reservee.FullName;
                }

                // Fill TextBoxEvent.
                Event dbEvent = Event.Select("EVENTID = " + Reservation.EventId.ToSqlFormat()).FirstOrDefault();
                if (dbEvent != null)
                {
                    View.TextBoxEvent.Text = dbEvent.Name;
                }

                // Fill NumericUpDownValue.
                View.NumericUpDownVisitorAmount.Value = Reservation.AmountOfPeople;

                // Fill interactive map.
                if (dbEvent != null)
                {
                    UpdateMap(dbEvent.Id);
                }

                // Fill products.
                IEnumerable <Rental> rentals = Rental.Select("VISITORCODE = " + reservee.VisitorCode.ToSqlFormat());
                View.DataGridViewProducts.DataSource = rentals.ToList();
            }
        }
Ejemplo n.º 2
0
 public override void Activate()
 {
     View.DataGridViewReservees.DataSource = Reservee.Select().ToList();
 }