Example #1
0
        //Crear nuevo catalogo
        private void registrarCatalogo(object sender, RoutedEventArgs e)
        {
            int         filas = 0;
            byte        estado;
            CADCatalogo con = new CADCatalogo();
            Catalogo    cat = new Catalogo();

            if (String.IsNullOrEmpty(txtNombre.Text) ||
                String.IsNullOrEmpty(txtEstado.Text))
            {
                MessageBox.Show("Por favor, llene todos los campos");
            }
            else
            {
                if (txtEstado.Text == "Activado")
                {
                    estado = 1;
                }
                else
                {
                    estado = 0;
                }
                cat.nombre = txtNombre.Text;
                cat.estado = estado;
                filas      = con.registrarCatalogo(cat);
                switch (filas)
                {
                case 1:
                    MessageBox.Show("Catalogo registrado");
                    break;

                case -2:
                    MessageBox.Show("Ya hay un Catalogo con este nombre");
                    break;

                default:
                    MessageBox.Show("Catalogo no registrado");
                    break;
                }
            }
        }