Exemple #1
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            Guests        g      = (Guests)listBox1.SelectedItem;
            List <Guests> guests = new List <Guests>();

            foreach (Guests d in dh.GetHosts(Cust))
            {
                if (d.hostid != g.hostid)
                {
                    guests.Add(d);
                }
            }
            dh.InserPending(guests);

            if (dh.Accout(g.hostid) > 0)
            {
                dh.UpdateConfirm(g.hostid, g.guestid);
                dh.UpdateHostAccout(g.hostid);
                string q = "" + Getuser(g.guestid) + GetTent(g.tentid);
                foreach (Guests d in dh.GetHosts(g.guestid))
                {
                    if (d.tentid != g.tentid)
                    {
                        dh.UpdateTents(d.tentid);
                    }
                }

                MessageBox.Show(q);
                listBox1.Items.Clear();
                listBox1.Visible = false;
                label2.Visible   = false;
                //label1.Visible = false;
            }
            else
            {
                dh.UpdateConfirm(g.hostid, g.guestid);
                dh.UpdateHostAccout(g.hostid);
                string q = "" + Getuser(g.guestid) + GetTent(g.tentid);

                foreach (Guests d in dh.GetHosts(g.guestid))
                {
                    if (d.tentid != g.tentid)
                    {
                        dh.UpdateTents(d.tentid);
                    }
                }



                MessageBox.Show(q + "   You Host has not sufficient money");
            }
        }
Exemple #2
0
        public List <Guests> GetHosts(int id)
        {
            List <Guests> hosters = new List <Guests> {
            };
            String       sql      = "SELECT * FROM `camping`";
            MySqlCommand command  = new MySqlCommand(sql, connection);



            try
            {
                connection.Open();
                MySqlDataReader reader = command.ExecuteReader();

                int nr;

                int tent;
                int host;

                while (reader.Read())
                {
                    nr = Convert.ToInt32(reader["Customer_Id"]);
                    if (nr == id)
                    {
                        tent = Convert.ToInt32(reader["Tent_Number"]);
                        host = Convert.ToInt32(reader["Hoster"]);
                        Guests g = new Guests(nr, tent, host);
                        hosters.Add(g);
                    }
                }
            }
            catch
            {
                MessageBox.Show("error while connection");
            }
            finally
            {
                connection.Close();
            }

            return(hosters);
        }