Пример #1
0
        private void btnGenerar_Click_1(object sender, EventArgs e)
        {
            try
            {
                var random = new Random();

                for (int i = 0; i < 10; i++)
                {
                    var      value = random.Next(1, 200);
                    var      opc   = random.Next(1, 4);
                    Bomberos b     = new Bomberos();
                    b.ID      = value;
                    b.Nombre  = RandomString(4);
                    b.Inicial = RandomString();
                    b.Sueldo  = value;
                    b.Fecha   = DateTime.Now;
                    b.Seguro  = true;
                    b.Puesto  = RandomString(6);
                    lista.AgregarNodo(b);
                    AgregarTabla();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error {ex}");
            }
        }
Пример #2
0
        private Bomberos Buscando()
        {
            DataGridViewRow row = Tabla.CurrentRow;

            if (row != null)//Para cuando hago click en la tabla
            {
                try
                {
                    Bomberos empresa = new Bomberos();
                    empresa.Nombre  = Tabla.CurrentRow.Cells[1].Value.ToString();
                    empresa.ID      = int.Parse(Tabla.CurrentRow.Cells[0].Value.ToString());
                    empresa.Sueldo  = int.Parse(Tabla.CurrentRow.Cells[3].Value.ToString());
                    empresa.Inicial = char.Parse(Tabla.CurrentRow.Cells[2].Value.ToString());
                    empresa.Fecha   = (DateTime)Tabla.CurrentRow.Cells[4].Value;
                    empresa.Puesto  = Tabla.CurrentRow.Cells[6].Value.ToString();
                    string x = Tabla.CurrentRow.Cells[5].Value.ToString();
                    if (x == "Si")
                    {
                        empresa.Seguro = true;
                    }
                    else
                    {
                        empresa.Seguro = false;
                    }

                    return(empresa);
                }
                catch (NullReferenceException exx)
                {
                    throw new Exception("" + exx);
                }
                catch (Exception ex)
                {
                    throw new Exception("" + ex);
                }
            }


            if (row == null)
            {
                throw new Exception("Seleccione un renglon de la tabla");
            }
            throw new Exception("No se encontro");
        }
Пример #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         bom        = new Bomberos();
         bom.ID     = int.Parse(txtID.Text);
         bom.Nombre = txtNombre.Text;
         bom.Puesto = cmbRango.Text;
         bom.Seguro = bool.Parse(chbSeguro.Text);
         bom.Sueldo = double.Parse(txtSueldo.Text);
         bom.Fecha  = (DateTime)dtpFecha.Value;
         lista.AgregarNodo(bom);
         AgregarTabla();
     }
     catch (Exception ex)
     {
         MessageBox.Show("" + ex);
     }
 }