Example #1
0
        // book a ticket
        private void button_Book_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                MessageBox.Show("Please select a flight!", "Information", MessageBoxButtons.OK);
                return;
            }

            string type = comboBox_Class.Text;
            string fno  = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();

            Model.Book book = new Model.Book(fno, Program.user.ID, type);
            if (book.Add())
            {
                Log.Add(Program.user.ID, "User book a flight.");
                MessageBox.Show("Successful!", "Information", MessageBoxButtons.OK);
                this.flightInfoTableAdapter.Fill(this.airlineDataSet.FlightInfo);
            }
            else
            {
                MessageBox.Show("Tickets not enough!", "Information", MessageBoxButtons.OK);
            }
        }
Example #2
0
        // unbook
        private void button_Unbook_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                MessageBox.Show("Please select a booking record!", "Information", MessageBoxButtons.OK);
                return;
            }
            int id = int.Parse(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
            //string id = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
            string fno  = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
            string type = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();

            Model.Book book = new Model.Book(id, fno, type);
            if (book.Delete())
            {
                Log.Add(Program.user.ID, "Unbook " + id + ".");
                MessageBox.Show("Successful!", "Information", MessageBoxButtons.OK);
                this.bookTableAdapter.Fill(this.airlineDataSet.Book);
            }
            else
            {
                MessageBox.Show("System error, please try again!", "Information", MessageBoxButtons.OK);
            }
        }