private void btnDelete_Click(object sender, EventArgs e)
        {
            string id = lbId.Text;

            try
            {
                BusBLL bll = new BusBLL();
                bll.DeleteBus(id);
                BusDTO busflag = null;
                foreach (var bus in _listBus)
                {
                    if (bus.Id.Equals(id))
                    {
                        busflag = bus;
                    }
                }
                _listBus.Remove((BusDTO)listBus.SelectedItem);
                loadListBus();
                if (_listBus.Count != 0)
                {
                    listBus.SelectedIndex = 0;
                    dto = _listBus[0];
                    FillBusDetail();
                }
                else
                {
                    MessageBox.Show("Delete successful");
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (txtId.ReadOnly)
     {
         try
         {
             if (MessageBox.Show("Delete Bus will delete all Schedule of Bus? (Y/N)", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 bll.DeleteBus(txtId.Text);
                 main_busDto = null;
                 LoadData();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     else
     {
         MessageBox.Show("Please choose bus before Delete");
     }
 }