示例#1
0
        private void button2_Click(object sender, EventArgs e)
        {
            // Check that a reservation is selected
            if (listBox1.SelectedItem != null)
            {
                // Confirm removal of reservation
                if (MessageBox.Show("Confirm reservation cancellation.", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    // TODO : Search for selected info in DB and remove it
                    DAL.ReservationService r = new DAL.ReservationService();
                    string   s        = listBox1.SelectedItem.ToString();
                    string[] strarray = s.Split(' ');
                    r.DeleteByReservationId(int.Parse(strarray[0]));

                    // Refresh the listbox from DB
                    refreshReservationsList(monthCalendar1.SelectionStart.Year,
                                            monthCalendar1.SelectionStart.Month,
                                            monthCalendar1.SelectionStart.Day);
                    MessageBox.Show("Reservation Canceled.");
                }
            }
            else
            {
                MessageBox.Show("Please Select a reservation to cancel");
            }
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Check that party name is valid
            if (textBox1.Text != "" && tableComboBox.Text != "")
            {
                // TODO : Check selected table is not reserved already!

                // Confirm Reservation
                if (MessageBox.Show("Confirm Reservation for " + textBox1.Text + "\nSize of Party : " + partyNumberUd.Value + "\nDate : " + monthCalendar1.SelectionRange.Start.ToShortDateString() + "\nTime : " + timeUd.Value + ":00\n Table : " + tableComboBox.Text, "Confirm Reservation", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    // Send information to DB
                    DAL.ReservationService r   = new DAL.ReservationService();
                    Model.Reservation      res = new Model.Reservation();
                    // need a better way to allocate unique IDs!
                    res.id      = (int)partyNumberUd.Value * textBox1.Text.Length * (int)timeUd.Value;
                    res.name    = textBox1.Text;
                    res.tableId = int.Parse(tableComboBox.Text);
                    res.year    = monthCalendar1.SelectionStart.Year;
                    res.month   = monthCalendar1.SelectionStart.Month;
                    res.day     = monthCalendar1.SelectionStart.Day;
                    res.hour    = (int)timeUd.Value;
                    res.number  = (int)partyNumberUd.Value;
                    r.AddNew(res);

                    // Get information from DB and load to listbox
                    refreshReservationsList(monthCalendar1.SelectionStart.Year,
                                            monthCalendar1.SelectionStart.Month,
                                            monthCalendar1.SelectionStart.Day);
                    MessageBox.Show("Reservation Successful");

                    // Reset all values
                    checkBox1.Checked   = false;
                    textBox1.Text       = "";
                    partyNumberUd.Value = 1;
                    timeUd.Value        = 12;
                }
            }
            else
            {
                MessageBox.Show("Please type in the party name.");
            }
        }