예제 #1
0
        private void ConfirmBtn_Click(object sender, EventArgs e)
        {
            const string message = "Confirm end trip? ";
            const string caption = "End Trip";
            var          result  = MessageBox.Show(message, caption,
                                                   MessageBoxButtons.YesNo,
                                                   MessageBoxIcon.Question);

            List <int> list = new List <int>();

            for (int i = 0; i < dataGridView.Rows.Count; i++)
            {
                if (dataGridView.Rows[i].Cells[2].Value.ToString() == carNo.Text)
                {
                    list.Add(Convert.ToInt32(dataGridView.Rows[i].Cells[1].Value));
                }
            }

            // If the no button was pressed ...
            if (result == DialogResult.No)
            {
                // cancel the closure of the form.
                this.Close();
            }
            else if (route == null)
            {
                string carNumber = carNo.Text;
                ParcelController.EndTransit(branchId, route, carNumber, list);
                this.Close();
                admin.ViewOutGoingParcel();
            }
            else
            {
                string carNumber = carNo.Text;
                ParcelController.EndTransit(branchId, route, carNumber, list);
                this.Close();
                admin.ViewIncomingParcel();
            }
        }