private void button1_Click(object sender, EventArgs e) { assignOtherGuests = false; LatterButton.Visible = false; tempCampHost = null; // MapPictureBox.Refresh(); }
public CampHost SearchCampHost(int acc) { connect(); string sql = "SELECT Camp_id,NumberOfGuests FROM campingspot WHERE Client_AccountNumber = '" + acc + "';"; MySqlCommand command = new MySqlCommand(sql, TempConnect); tempCampHost = null; try { TempConnect.Open(); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { int campID = Convert.ToInt32(reader["Camp_id"]); int numberOfGuest = Convert.ToInt32(reader["NumberOfGuests"]); tempCampHost = new CampHost(acc, numberOfGuest, campID); } } catch (MySqlException ex) { System.Windows.Forms.MessageBox.Show("Bad " + ex.Message);; } finally { TempConnect.Close(); } return(tempCampHost); }
public List <CampHost> AllCampHost() { connect(); tempCampHoustList = new List <CampHost>(); string sql = "SELECT Camp_id,NumberOfGuests FROM campingspot ;"; MySqlCommand command = new MySqlCommand(sql, TempConnect); tempCampHost = null; try { TempConnect.Open(); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { int campID = Convert.ToInt32(reader["Camp_id"]); int numberOfGuest = Convert.ToInt32(reader["NumberOfGuests"]); tempCampHost = new CampHost(0, numberOfGuest, campID); tempCampHoustList.Add(tempCampHost); } } catch (MySqlException ex) { System.Windows.Forms.MessageBox.Show("Bad " + ex.Message);; } finally { TempConnect.Close(); } return(tempCampHoustList); }
public void AssignGuest(CampHost campH, int acc) { connect(); string sql = "Insert into campingspotguest(CampingSpot_Camp_id,Client_AccountNumber) values(" + campH.Camp_id + "," + acc + ");"; MySqlCommand command = new MySqlCommand(sql, TempConnect); string sql2 = "UPDATE `campingspot` SET `NumberOfGuests`=" + (campH.numberOfGuests - 1) + " where Camp_id=" + campH.Camp_id + ";"; MySqlCommand command2 = new MySqlCommand(sql2, TempConnect); try { TempConnect.Open(); command.ExecuteNonQuery(); } catch (MySqlException ex) { System.Windows.Forms.MessageBox.Show("Bad " + ex.Message);; } finally { TempConnect.Close(); } try { TempConnect.Open(); command2.ExecuteNonQuery(); } catch (MySqlException ex) { System.Windows.Forms.MessageBox.Show("Bad " + ex.Message);; } finally { TempConnect.Close(); } }
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(); }
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(); }