Пример #1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            var nombre      = textBox2.Text;
            var descripcion = textBox3.Text;


            if (string.IsNullOrEmpty(nombre) || string.IsNullOrWhiteSpace(nombre))
            {
                Mensajes.EmptyFields();
                textBox2.Focus();
            }
            else if (string.IsNullOrEmpty(descripcion) || string.IsNullOrWhiteSpace(descripcion))
            {
                Mensajes.EmptyFields();
                textBox3.Focus();
            }
            else
            {
                var tipoProducto = new TipoProducto();
                tipoProducto.tipo_producto = nombre;
                tipoProducto.descripcion   = descripcion;
                int re = await _controller.AddTipoProduco(tipoProducto);

                if (re > 0)
                {
                    Mensajes.AgregadoConExito();
                    Limpiar();
                    await initData();
                }
                else
                {
                    Mensajes.OcurrioUnError();
                }
            }
        }