Beispiel #1
0
 private void button_Save_Click(object sender, EventArgs e)
 {
     Model.Flight flight = new Model.Flight(
         textBox1.Text, textBox10.Text, textBox2.Text, textBox3.Text,
         dateTimePicker1.Value, dateTimePicker2.Value,
         float.Parse(textBox4.Text), int.Parse(textBox5.Text),
         float.Parse(textBox6.Text), int.Parse(textBox7.Text),
         float.Parse(textBox8.Text), int.Parse(textBox9.Text)
         );
     if (fno != "")
     {
         if (flight.Update())
         {
             MessageBox.Show("Successful!", "Information", MessageBoxButtons.OK);
             Log.Add(Program.user.ID, "Update flight " + fno + ".");
             this.Close();
         }
     }
     else
     {
         if (flight.Add())
         {
             MessageBox.Show("Successful!", "Information", MessageBoxButtons.OK);
             Log.Add(Program.user.ID, "Add a flight.");
             this.Close();
         }
     }
 }
Beispiel #2
0
 private void FlightInfo_Load(object sender, EventArgs e)
 {
     if (fno != "")
     {
         textBox1.ReadOnly = true;
         this.Text         = "  Edit flight " + fno;
         Model.Flight flight = new Model.Flight(fno);
         flight.Fetch();
         textBox1.Text         = flight.FlightNo;
         textBox2.Text         = flight.Start;
         textBox3.Text         = flight.Destination;
         textBox4.Text         = flight.EconomyPrice.ToString();
         textBox5.Text         = flight.EconomyCount.ToString();
         textBox6.Text         = flight.EconomyPlusPrice.ToString();
         textBox7.Text         = flight.EconomyPlusCount.ToString();
         textBox8.Text         = flight.BusinessPrice.ToString();
         textBox9.Text         = flight.BusinessCount.ToString();
         textBox10.Text        = flight.CarrierNo;
         dateTimePicker1.Value = flight.LeavingAt;
         dateTimePicker2.Value = flight.ArrivalAt;
     }
 }
Beispiel #3
0
        // delete rows
        private void button_Delete_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                return;
            }

            // collect ids to delete
            string flightNos = "(";

            for (int i = 0; i < dataGridView1.SelectedRows.Count; i++)
            {
                flightNos += "'" + dataGridView1.SelectedRows[i].Cells[0].Value.ToString() + "'";
                if (i != dataGridView1.SelectedRows.Count - 1)
                {
                    flightNos += ",";
                }
            }
            flightNos += ")";

            if (MessageBox.Show("Sure to delete flights whose no. in " + flightNos + "?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
            {
                return;
            }

            // call the model's delete method
            Model.Flight flight = new Model.Flight();
            if (flight.Delete(flightNos))
            {
                Log.Add(Program.user.ID, "Delete flight " + flightNos + ".");
                // delete from datagridview
                foreach (DataGridViewRow dataGridView1Row in dataGridView1.SelectedRows)
                {
                    dataGridView1.Rows.Remove(dataGridView1Row);
                }
            }
        }