Beispiel #1
0
 private void btnGrabar_Click(object sender, EventArgs e)
 {
     if (_ModoAM == Negocios.FuncionesGlobales.Globales.Modo.Agregar)
     {
         _CategoriaN = new CategoriaN(txtNombre.Text);
         if (_CategoriaN.Guardar())
         {
             if (_CategoriaN.Succed == true)
             {
                 MessageBox.Show("Se Grabo la Categoria " + txtNombre.Text);
             }
             else
             {
                 MessageBox.Show("No se pudo grabar la Categoria " + txtNombre.Text);
             }
         }
     }
     else if (_ModoAM == Negocios.FuncionesGlobales.Globales.Modo.Agregar)
     {
         _CategoriaN.Nombre = txtNombre.Text;
         if (_CategoriaN.Actualizar())
         {
             MessageBox.Show("Se Actualizó la Categoria");
         }
         else
         {
             MessageBox.Show("No se pudo Actulizar la Categoria");
         }
     }
     LimpiarPantalla();
     CambiarModoPantalla(Negocios.FuncionesGlobales.Globales.Modo.Inicial);
 }
Beispiel #2
0
 private void txtId_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter && txtId.Text == "")
     {
         CambiarModoPantalla(Negocios.FuncionesGlobales.Globales.Modo.Agregar);
     }
     else if (e.KeyCode == Keys.Enter && txtId.Text != "")
     {
         _CategoriaN = new CategoriaN(int.Parse(txtId.Text));
         if (_CategoriaN.Nombre != null)
         {
             txtNombre.Text = _CategoriaN.Nombre;
             CambiarModoPantalla(Negocios.FuncionesGlobales.Globales.Modo.Consultar);
         }
         else
         {
             txtId.Text = ""; 
             CambiarModoPantalla(Negocios.FuncionesGlobales.Globales.Modo.Agregar);
         }
     }
 }
        private void txtCodigocategoria_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter && txtCodigoCategoria.Text != "")
            {
                _Categoria = new CategoriaN(int.Parse(txtCodigoCategoria.Text));

                if (_Categoria.Succed)
                {
                    txtNombreCategoria.Text = _Categoria.Nombre;
                    epControlCampos.Clear();
                }
            }
            else if (e.KeyCode == Keys.Enter && txtCodigoCategoria.Text == "")
	    	{
                txtNombreCategoria.Text = "";
	        }
            else if (e.KeyCode == Keys.F3)
            {
                try
                {
                    List<CategoriaN> Categoria = Negocios.FuncionesGlobales.CategoriaS.ListarCategoria();
                    string[] cool = { "Id", "Nombre" };
                    txtCodigoCategoria.Parametros<CategoriaN>(Keys.F3, cool, "Id", Categoria, "Nombre");
                }
                catch (Exception E)
                {
                    MessageBox.Show(E.StackTrace);
                    throw;
                }
            }
        }