public override void Activate()
        {
            Task.Factory.StartNew(() =>
            {
                Task.Delay(5000).Wait();
                FormMain.Form.Open <ControllerScanRFID>();
            });
            InteractiveMap map = View.InteractiveMap;

            map.ImageMap    = Image.FromFile("location1.png");
            map.MouseClick += (sender, e) => { MessageBox.Show(string.Format("X: {0}, Y: {1}", e.X, e.Y)); };
            var visitor       = Values.SafeGetValue <Visitor>("visitor");
            int reservationID = visitor.ReservationId;


            IEnumerable <ReservationSpot> reservation =
                ReservationSpot.Select("RESERVATIONID = " + reservationID.ToSqlFormat());
            double x = reservation.FirstOrDefault().Spot.LocX;
            double y = reservation.FirstOrDefault().Spot.LocY;

            map.Add(x, y);
        }
Пример #2
0
        private void ViewOnSaveReservationClick(object sender, EventArgs e)
        {
            if (IsNewRecord)
            {
                Reservation = new Reservation();
            }

            Reservation.EventId        = ((Event)View.TextBoxEvent.Tag).Id;
            Reservation.ReserveeId     = ((Reservee)View.TextBoxReservee.Tag).Id;
            Reservation.AmountOfPeople = (int)View.NumericUpDownVisitorAmount.Value;

            if (IsNewRecord)
            {
                Reservation.Insert();
                Reservation =
                    Reservation.Select("RESERVATIONID = (SELECT MAX(RESERVATIONID) FROM RESERVATION)").First();
            }
            else
            {
                Reservation.Update();
            }

            // Clear all reservations first.
            foreach (ReservationSpot spot in Reservation.ReservationSpots)
            {
                spot.Delete();
            }

            // Insert all spots into database.
            foreach (InteractiveMap.Spot spot in View.InteractiveMap.Spots)
            {
                var dbSpot = new ReservationSpot();
                dbSpot.SpotId        = (int)spot.Tag;
                dbSpot.ReservationId = Reservation.Id;
                dbSpot.Insert();
            }

            // Generate random RFIDs.
            var           r           = new Random();
            List <string> randomRFIDs =
                Enumerable.Repeat("", (int)View.NumericUpDownVisitorAmount.Value)
                .Select(
                    s =>
                    Enumerable.Repeat("", 8)
                    .Select(s2 => r.Next(16).ToString("X"))
                    .Aggregate((s1, s2) => s1 + s2))
                .ToList();

            // Popup window which shows input fields based on the amount of RFIDs required.
            var rfidPopup = MainForm.PopupControllerOptions <ControllerAddVisitorsToReservation>(true,
                                                                                                 new KeyValuePair <string, object>("Visitors",
                                                                                                                                   randomRFIDs), new KeyValuePair <string, object>("Reservation", Reservation),
                                                                                                 new KeyValuePair <string, object>("Reservee", View.TextBoxReservee.Tag));

            if (rfidPopup.DialogResult == DialogResult.OK)
            {
                // Send the mail.
                SendReservationConfirmationEmail(((Reservee)View.TextBoxReservee.Tag));
            }
            else
            {
                Reservation.Delete();
            }
        }