示例#1
0
 private void btneliminar_Click(object sender, EventArgs e)
 {
     if (txtId.Text != "")
     {
         DialogResult dialogResult = MessageBox.Show("Seguro que desea eliminar el bus", "Eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Hand);
         if (dialogResult == DialogResult.Yes)
         {
             CDBus bus = new CDBus(int.Parse(txtId.Text));
             try
             {
                 bus.eliminar();
                 mostrarBuses();
                 limpiar();
             }
             catch (Exception ex)
             {
                 MessageBox.Show("No se puede eliminar el bus, puede que este asociado a un viaje", "Aviso");
                 return;
             }
         }
         else if (dialogResult == DialogResult.No)
         {
             return;
         }
     }
     else
     {
         MessageBox.Show("Seleccione el bus a eliminar", "Aviso");
         return;
     }
 }
示例#2
0
 private void btnmodificar_Click(object sender, EventArgs e)
 {
     if (txtId.Text != "")
     {
         if (txtCatacteristicas.Text == "" || txtPlaca.Text == "" || txtCatacteristicas.Text == "")
         {
             MessageBox.Show("Todos los campos se deben llenar", "Aviso");
         }
         else
         {
             string pr = txtPlaca.Text.Substring(0, 2);
             MessageBox.Show(pr);
             if (pr == "AB")
             {
                 if (txtPlaca.Text.Length == 8)
                 {
                     CDBus bus = new CDBus(int.Parse(txtId.Text), txtPlaca.Text, int.Parse(comboBox2.SelectedValue.ToString()), int.Parse(comboBox1.SelectedValue.ToString()), int.Parse(nmCapacidad.Value.ToString()), txtCatacteristicas.Text);
                     try
                     {
                         bus.modificar();
                         mostrarBuses();
                         limpiar();
                     } catch (Exception ex)
                     {
                         MessageBox.Show("La placa del bus ya esta registrada. vuelva a intentarlo", "Advertencia");
                     }
                 }
                 else
                 {
                     MessageBox.Show("La placa de un bus, cuenta con 8 caracteres especificamente", "Aviso");
                     return;
                 }
             }
             else
             {
                 MessageBox.Show("El formato de placa de bus, debe iniciar con: AB", "Aviso");
                 return;
             }
         }
     }
     else
     {
         MessageBox.Show("Seleccione el bus a modificar", "Aviso");
         return;
     }
 }
示例#3
0
        void mostrarColores()
        {
            CDBus bus = new CDBus();

            bus.cargarColor(comboBox2);
        }
示例#4
0
        void mostrarMarcas()
        {
            CDBus bus = new CDBus();

            bus.cargarMarca(comboBox1);
        }
示例#5
0
        void mostrarBuses()
        {
            CDBus bus = new CDBus();

            dgvBuses.DataSource = bus.mostrar();
        }