private void btn_EliminarServicio_Click(object sender, EventArgs e)
 {
     if (dt_Servicios.SelectedRows.Count > 0)
     {
         int          id = (int)dt_Servicios.SelectedRows[0].Cells[0].Value;
         CLS.Servicio s  = new CLS.Servicio();
         s.Eliminar(id);
         Cargar();
     }
     else
     {
         MessageBox.Show("Seleccione el servicio a eliminar");
     }
 }
Exemplo n.º 2
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            CLS.Servicio s = new CLS.Servicio();


            try
            {
                s.Nombre       = txbNombre.Text;
                s.Valorcontado = float.Parse(txbValorContado.Text);
                s.Valorcuota   = float.Parse(txbValorCuota.Text);
                s.Prima        = float.Parse(txbPrima.Text);
                s.Descripcion  = txbDescripcion.Text;
                if (s.Guardar())
                {
                    MessageBox.Show("Registro añadido exitosamente");
                    this.Close();
                }
            }
            catch
            {
                MessageBox.Show("No se pudo añadir el registro, intente rellenar debidamente los campos");
            }
        }