protected void btnConfirmar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtNombre.Text))
            {
                ClientScript.RegisterStartupScript(this.GetType(), "mensaje", "verificacionNull(true)", true);
            }
            else
            {
                List <Unidad> listaUnidad = new UnidadCollection().ReadAll().ToList();
                Unidad        unidad      = new Unidad();
                unidad.IdUnidad = listaUnidad.Max(iu => iu.IdUnidad) + 1;


                unidad.Nombre = txtNombre.Text;

                if (unidad.Create())
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "mensaje", "verificacion(true)", true);
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "mensaje", "verificacion(false)", true);
                }
            }
        }
        public static object CargarDataTable()
        {
            List <Unidad> ls   = new UnidadCollection().ReadAll().OrderBy(s => s.IdUnidad).ToList();
            object        json = new { data = ls };

            return(json);
        }
 protected void btnConfirmarModificar_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtNombreEdit.Text))
     {
         ClientScript.RegisterStartupScript(this.GetType(), "mensaje", "verificacionNull(true)", true);
     }
     else
     {
         int    selec  = ddlUnidadesEdit.SelectedIndex;
         Unidad unidad = new UnidadCollection().ReadAll().First(es => es.IdUnidad == selec);
         unidad.Nombre = txtNombreEdit.Text;
         if (unidad.Update())
         {
             ClientScript.RegisterStartupScript(this.GetType(), "mensaje", "verificacionModifi(true)", true);
         }
         else
         {
             ClientScript.RegisterStartupScript(this.GetType(), "mensaje", "verificacionModifi(false)", true);
         }
     }
 }