예제 #1
0
 private void CrewInfo_Load(object sender, EventArgs e)
 {
     if (cno != "")
     {
         textBox1.ReadOnly = true;
         this.Text         = "  Edit crew " + cno;
         Model.Crew crew = new Model.Crew(cno);
         crew.Fetch();
         textBox1.Text = crew.CrewNo;
         textBox2.Text = crew.FlightNo;
         textBox3.Text = crew.CrewName;
         textBox4.Text = crew.Role;
     }
 }
예제 #2
0
        // delete rows
        private void button_Delete_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                return;
            }

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

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

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

            // call the model's delete method
            Model.Crew crew = new Model.Crew();
            if (crew.Delete(crewNos))
            {
                Log.Add(Program.user.ID, "Delete crew " + crewNos + ".");
                // delete from datagridview
                foreach (DataGridViewRow dataGridView1Row in dataGridView1.SelectedRows)
                {
                    dataGridView1.Rows.Remove(dataGridView1Row);
                }
            }
        }
예제 #3
0
 private void button_Save_Click(object sender, EventArgs e)
 {
     Model.Crew crew = new Model.Crew(
         textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text
         );
     if (cno != "")
     {
         if (crew.Update())
         {
             MessageBox.Show("Successful!", "Information", MessageBoxButtons.OK);
             Log.Add(Program.user.ID, "Update crew " + cno + ".");
             this.Close();
         }
     }
     else
     {
         if (crew.Add())
         {
             MessageBox.Show("Successful!", "Information", MessageBoxButtons.OK);
             Log.Add(Program.user.ID, "Add a crew.");
             this.Close();
         }
     }
 }