public CampSpotGuest SearchCampGuest(int acc)
        {
            connect();
            string       sql     = "SELECT CampingSpot_Camp_id FROM  campingspotguest WHERE Client_AccountNumber = '" + acc + "';";
            MySqlCommand command = new MySqlCommand(sql, TempConnect);

            tempCampSpotGuest = null;
            try
            {
                TempConnect.Open();
                MySqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    int campID = Convert.ToInt32(reader["CampingSpot_Camp_id"]);

                    tempCampSpotGuest = new CampSpotGuest(campID, acc);
                }
            }

            catch (MySqlException ex)
            {
                System.Windows.Forms.MessageBox.Show("Bad " + ex.Message);;
            }
            finally
            {
                TempConnect.Close();
            }
            return(tempCampSpotGuest);
        }
Beispiel #2
0
        public void ProcessThisTag(object sender, TagEventArgs e)
        {
            // show current RFID tag to label
            theRFIDstring = Convert.ToString(e.Tag);
            // just test
            tempClient        = null;
            tempCampSpotGuest = null;

            if ((tempClient = connectionDB.SearchClient(theRFIDstring)) != null)
            {
                if (!assignOtherGuests)
                {
                    tempCampHost = null;

                    if ((tempCampHost = connectionDB.SearchCampHost(tempClient.AccountNumber)) != null)
                    {
                        groupBox1.BackColor = Color.Green;
                        groupBox2.BackColor = Color.Gray;
                        HostName.Text       = "Name: " + tempClient.First_name;
                        NrOfGuest.Text      = "Guest to assign :" + tempCampHost.NumberOfGuests.ToString();
                        CampSpotNumber.Text = "Number: " + tempCampHost.Camp_id.ToString();

                        assignOtherGuests    = true;
                        LatterButton.Visible = true;
                    }
                    else if ((tempCampSpotGuest = connectionDB.SearchCampGuest(tempClient.AccountNumber)) != null)
                    {
                        groupBox1.BackColor = Color.Yellow;
                        HostName.Text       = "Name: " + tempClient.First_name;
                        NrOfGuest.Text      = " ";
                        groupBox2.BackColor = Color.Green;
                        CampSpotNumber.Text = "Number: " + tempCampSpotGuest.CampId;
                    }
                    else
                    {
                        groupBox1.BackColor = Color.Red;
                        groupBox2.BackColor = Color.Red;

                        HostName.Text       = "..";
                        NrOfGuest.Text      = "..";
                        CampSpotNumber.Text = "..";
                        MessageBox.Show(tempClient.First_name + " is not assignet to any Camp Spot Or had paid for one!");
                    }
                }
                else
                {
                    connectionDB.AssignGuest(tempCampHost, tempClient.AccountNumber);
                    groupBox1.BackColor = Color.Gray;
                    HostName.Text       = "Name: " + tempClient.First_name;
                    groupBox2.BackColor = Color.Green;
                    CampSpotNumber.Text = "Number: " + tempCampHost.Camp_id;
                    tempCampHost.numberOfGuests--;
                    NrOfGuest.Text = tempCampHost.numberOfGuests.ToString();
                    if (tempCampHost.numberOfGuests == 0)
                    {
                        assignOtherGuests    = false;
                        LatterButton.Visible = false;
                    }
                }
            }
            else
            {
                groupBox1.BackColor = Color.Red;
                groupBox2.BackColor = Color.Red;
                HostName.Text       = "RFID is not registered!";
                NrOfGuest.Text      = "...";
                CampSpotNumber.Text = "..";
                MessageBox.Show("RFID is not registered!");
            }

            MapPictureBox.Refresh();
        }
Beispiel #3
0
        public void ProcessThisTag(object sender, TagEventArgs e)
        {
            // show current RFID tag to label
            theRFIDstring = Convert.ToString(e.Tag);
            // just test
            tempClient        = null;
            tempCampSpotGuest = null;

            if ((tempClient = connectionDB.SearchClient(theRFIDstring)) != null) // if RFID is assigned
            {
                if (!assignOtherGuests)                                          // if assigning other guest
                {
                    tempCampHost = null;

                    if ((tempCampHost = connectionDB.SearchCampHost(tempClient.AccountNumber)) != null) // check if Client payed for camp spot
                    {
                        groupBox1.BackColor = Color.Green;
                        groupBox2.BackColor = Color.Gray;
                        HostName.Text       = "Name: " + tempClient.First_name;
                        NrOfGuest.Text      = "Guest to assign :" + tempCampHost.NumberOfGuests.ToString();
                        CampSpotNumber.Text = "Number: " + tempCampHost.Camp_id.ToString();

                        if (tempCampHost.numberOfGuests > 0) // checks if he stil have some guest to assign
                        {
                            assignOtherGuests    = true;     // next rfid (if in db) will be assigned to same camp spot as HOST
                            LatterButton.Visible = true;
                        }
                    }
                    else if ((tempCampSpotGuest = connectionDB.SearchCampGuest(tempClient.AccountNumber)) != null) //checks if client is assigned to any camp spot
                    {
                        groupBox1.BackColor = Color.Yellow;
                        HostName.Text       = "Name: " + tempClient.First_name;
                        NrOfGuest.Text      = " ";
                        groupBox2.BackColor = Color.Green;
                        CampSpotNumber.Text = "Number: " + tempCampSpotGuest.CampId;
                    }
                    else      // Client is in db but not assiged to any camp spot ar have payed for one
                    {
                        groupBox1.BackColor = Color.Red;
                        groupBox2.BackColor = Color.Red;

                        HostName.Text       = "..";
                        NrOfGuest.Text      = "..";
                        CampSpotNumber.Text = "..";
                        MessageBox.Show(tempClient.First_name + " is not assignet to any Camp Spot Or had payed for one!");
                    }
                }
                else
                {
                    if (tempCampHost.numberOfGuests > 0)   //check if there is still guest left to assign
                    {
                        connectionDB.AssignGuest(tempCampHost, tempClient.AccountNumber);
                        groupBox1.BackColor = Color.Gray;
                        HostName.Text       = "Name: " + tempClient.First_name;
                        groupBox2.BackColor = Color.Green;
                        CampSpotNumber.Text = "Number: " + tempCampHost.Camp_id;
                        tempCampHost.numberOfGuests--;
                        NrOfGuest.Text = tempCampHost.numberOfGuests.ToString();
                    }
                    else
                    {
                        assignOtherGuests    = false;
                        LatterButton.Visible = false;
                    }
                }
            }
            else // rfid is not assigned to any client
            {
                groupBox1.BackColor = Color.Red;
                groupBox2.BackColor = Color.Red;
                HostName.Text       = "RFID is not registered!";
                NrOfGuest.Text      = "...";
                CampSpotNumber.Text = "..";
                MessageBox.Show("RFID is not registered!");
            }

            MapPictureBox.Refresh();
        }