private void Btn_Aceptar_Click(object sender, EventArgs e)
        {
            try
            {
                Datos.Enfermedad_categoria EC = new Datos.Enfermedad_categoria();

                EC.Id_Enfermedad_Categoria            = (int)id_Enfermedad_CategoriaNumericUpDown.Value;
                EC.Codigo_Enfermedad_Categoria        = codigo_Enfermedad_CategoriaTextBox.Text;
                EC.Descripcion_Enfermedad_Categoria   = descripcion_Enfermedad_CategoriaTextBox.Text;
                EC.Observaciones_Enfermedad_Categoria = observaciones_Enfermedad_CategoriaTextBox.Text;

                if (id_Enfermedad_CategoriaNumericUpDown.Value == 0)
                {
                    Datos.Enfermedad_categoria.Add(EC);
                    MessageBox.Show("Se ha agregado un nuevo registro.");
                }
                else
                {
                    Datos.Enfermedad_categoria.Set(EC);
                    MessageBox.Show("Se ha modificado correctamente el registro.");
                }
                Close();
            }
            catch (Exception Error)
            {
                MessageBox.Show(Error.Message);
            }
        }
        public FrmEnfermedadesCategoriasABM(string IdEnfermedadCategoria)
        {
            InitializeComponent();
            try
            {
                //Busco el una unica fila por su id
                Datos.Enfermedad_categoria EC = Datos.Enfermedad_categoria.GetEnfermedad_categoria(IdEnfermedadCategoria, "", "").ListaEnfermedad_categoria[0];

                id_Enfermedad_CategoriaNumericUpDown.Value     = EC.Id_Enfermedad_Categoria;
                codigo_Enfermedad_CategoriaTextBox.Text        = EC.Codigo_Enfermedad_Categoria;
                descripcion_Enfermedad_CategoriaTextBox.Text   = EC.Descripcion_Enfermedad_Categoria;
                observaciones_Enfermedad_CategoriaTextBox.Text = EC.Observaciones_Enfermedad_Categoria;
            }
            catch (Exception Error)
            {
                MessageBox.Show(Error.Message);
            }
        }
        private void Buscar()
        {
            try
            {
                //Borro todo las filas y columnas anteriores
                DG_Datos.Columns.Clear();
                DG_Datos.Rows.Clear();

                //Busco la lista de datos
                Datos.Enfermedad_categoria EC = Datos.Enfermedad_categoria.GetEnfermedad_categoria(Txt_Id.Text, Txt_Codigo.Text, Txt_Categoria.Text);

                //Agrego las columnas de la regilla de datos.
                DG_Datos.Columns.Add("Clm_Codigo", "Codigo");
                DG_Datos.Columns.Add("Clm_Categoria", "Categoría");
                DG_Datos.Columns.Add("Clm_Observacion", "Observación");

                DG_Datos.Font = new Font(Config.NombreFont, Config.TamañoFont);
                DG_Datos.Columns["Clm_Codigo"].AutoSizeMode      = DataGridViewAutoSizeColumnMode.AllCells;
                DG_Datos.Columns["Clm_Categoria"].AutoSizeMode   = DataGridViewAutoSizeColumnMode.AllCells;
                DG_Datos.Columns["Clm_Observacion"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

                Progreso.Minimum           = 0;
                Progreso.Maximum           = EC.ListaEnfermedad_categoria.Count;
                Progreso.Value             = 0;
                LblPorcentaje.Text         = "0 %";
                Txt_CantidadRegistros.Text = EC.ListaEnfermedad_categoria.Count.ToString();

                CancelarBusqueda = false;
                //Agrego las filas
                foreach (Datos.Enfermedad_categoria ItemEnfermedad_categoria in EC.ListaEnfermedad_categoria)
                {
                    if (CancelarBusqueda)
                    {
                        break;
                    }

                    if (DetenerBusqueda)
                    {
                        DetenerBusqueda = false;
                        break;
                    }

                    Application.DoEvents();
                    Progreso.Value++;
                    LblPorcentaje.Text = (Progreso.Value * 100 / Progreso.Maximum).ToString("##0") + " %";

                    DG_Datos.Rows.Add();
                    DG_Datos.Rows[DG_Datos.Rows.Count - 1].Tag = ItemEnfermedad_categoria.Id_Enfermedad_Categoria;

                    DG_Datos.Rows[DG_Datos.Rows.Count - 1].Cells["Clm_Codigo"].Value      = ItemEnfermedad_categoria.Codigo_Enfermedad_Categoria;
                    DG_Datos.Rows[DG_Datos.Rows.Count - 1].Cells["Clm_Categoria"].Value   = ItemEnfermedad_categoria.Descripcion_Enfermedad_Categoria;
                    DG_Datos.Rows[DG_Datos.Rows.Count - 1].Cells["Clm_Observacion"].Value = ItemEnfermedad_categoria.Observaciones_Enfermedad_Categoria;
                }

                LblPorcentaje.Text = "0 %";
                Progreso.Value     = 0;

                if (NumeroFilaUltimaSeleccion != 0 && DG_Datos.Rows.Count > NumeroFilaUltimaSeleccion)
                {
                    DG_Datos.Rows[NumeroFilaUltimaSeleccion].Selected = true;
                }

                Btn_Buscar.Enabled  = true;
                Btn_Detener.Enabled = false;
            }
            catch (Exception Error)
            {
                if (!CancelarBusqueda)
                {
                    MessageBox.Show(Error.Message);
                }
            }
        }