Пример #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();
                }
            }
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var nombre   = textBox2.Text;
            var correo   = textBox3.Text;
            var telefono = textBox4.Text;

            if (string.IsNullOrEmpty(nombre) || string.IsNullOrWhiteSpace(nombre))
            {
                Mensajes.EmptyFields();
                textBox2.Focus();
            }
            else if (string.IsNullOrEmpty(correo) || string.IsNullOrWhiteSpace(correo))
            {
                Mensajes.EmptyFields();
                textBox3.Focus();
            }
            else if (!Validaciones.isEmailValid(correo))
            {
                Mensajes.CorreoNoValido();
                textBox3.Focus();
            }
            else if (string.IsNullOrEmpty(telefono) || string.IsNullOrWhiteSpace(telefono))
            {
                Mensajes.EmptyFields();
                textBox4.Focus();
            }
            else
            {
                var proveedor = new Proveedor();
                proveedor.nombre_proveedor   = nombre;
                proveedor.correo_proveedor   = correo;
                proveedor.telefono_proveedor = telefono;
                int re = ProveedorController.AddProveedor(proveedor);
                if (re > 0)
                {
                    Mensajes.AgregadoConExito();
                    Limpiar();
                    initData();
                }
                else
                {
                    Mensajes.OcurrioUnError();
                }
            }
        }
Пример #3
0
        private async void btnCrear_Click(object sender, EventArgs e)
        {
            var nombre   = txtNombre.Text;
            var apellido = txtApellido.Text;
            var username = txtUsername.Text;

            if (string.IsNullOrEmpty(nombre))
            {
                Mensajes.EmptyFields();
                txtNombre.Focus();
            }
            else if (string.IsNullOrEmpty(apellido))
            {
                Mensajes.EmptyFields();
                txtApellido.Focus();
            }
            else if (string.IsNullOrEmpty(username) || string.IsNullOrWhiteSpace(username))
            {
                Mensajes.EmptyFields();
                txtUsername.Focus();
            }
            else
            {
                _usuario.nombre   = nombre;
                _usuario.apellido = apellido;
                _usuario.username = username;
                _usuario.pass     = Encriptar.encriptarPassword(nombre + apellido + "123");

                var rs = await _controller.AddUsuarioAsync(_usuario);

                if (rs > 0)
                {
                    Mensajes.AgregadoConExito();
                    limpiar();
                }
                else
                {
                    Mensajes.EliminadoConExito();
                }
            }
        }
        private async void btnCrear_Click(object sender, EventArgs e)
        {
            if (btnCrear.Text == "Crear")
            {
                var nombre         = txtNombre.Text;
                var costoPorUnidad = double.Parse(txtCostoPorUnidad.Text);
                var costoPublico   = double.Parse(txtCostoPublico.Text);



                var cantidad = int.Parse(txtCantidad.Text);
                var ganacia  = Math.Round(costoPorUnidad - costoPublico);
                if (string.IsNullOrEmpty(nombre))
                {
                    Mensajes.EmptyFields();
                    txtNombre.Focus();
                }
                else if (string.IsNullOrEmpty(costoPorUnidad.ToString()) || string.IsNullOrWhiteSpace(costoPorUnidad.ToString()))
                {
                    Mensajes.EmptyFields();
                    txtCostoPorUnidad.Focus();
                }
                else if (string.IsNullOrEmpty(costoPublico.ToString()) || string.IsNullOrWhiteSpace(costoPublico.ToString()))
                {
                    Mensajes.EmptyFields();
                    txtCostoPublico.Focus();
                }
                else if (string.IsNullOrEmpty(cantidad.ToString()) || string.IsNullOrWhiteSpace(cantidad.ToString()))
                {
                    Mensajes.EmptyFields();
                    txtCantidad.Focus();
                }
                else
                {
                    _producto.nombre           = nombre;
                    _producto.costo_por_unidad = costoPorUnidad;
                    _producto.costo_publico    = costoPublico;
                    _producto.cantidad         = cantidad;
                    _producto.ganancia         = ganacia;
                    var rs = await _controller.AddMedicamento(_producto);

                    if (rs > 0)
                    {
                        Mensajes.AgregadoConExito();
                        limpiar();
                    }
                    else
                    {
                        Mensajes.OcurrioUnError();
                    }
                }
            }
            else
            {
                var nombre         = txtNombre.Text;
                var costoPorUnidad = double.Parse(txtCostoPorUnidad.Text);
                var costoPublico   = double.Parse(txtCostoPublico.Text);



                var cantidad = int.Parse(txtCantidad.Text);
                var ganacia  = Math.Round(costoPorUnidad - costoPublico);
                if (string.IsNullOrEmpty(nombre))
                {
                    Mensajes.EmptyFields();
                    txtNombre.Focus();
                }
                else if (string.IsNullOrEmpty(costoPorUnidad.ToString()) || string.IsNullOrWhiteSpace(costoPorUnidad.ToString()))
                {
                    Mensajes.EmptyFields();
                    txtCostoPorUnidad.Focus();
                }
                else if (string.IsNullOrEmpty(costoPublico.ToString()) || string.IsNullOrWhiteSpace(costoPublico.ToString()))
                {
                    Mensajes.EmptyFields();
                    txtCostoPublico.Focus();
                }
                else if (string.IsNullOrEmpty(cantidad.ToString()) || string.IsNullOrWhiteSpace(cantidad.ToString()))
                {
                    Mensajes.EmptyFields();
                    txtCantidad.Focus();
                }
                else
                {
                    _producto.nombre           = nombre;
                    _producto.costo_por_unidad = costoPorUnidad;
                    _producto.costo_publico    = costoPublico;
                    _producto.cantidad         = cantidad;
                    _producto.ganancia         = ganacia;
                    var rs = await _controller.UpdateMedicamento(_producto);

                    if (rs > 0)
                    {
                        Mensajes.ActualizadoConExito();
                        limpiar();
                    }
                    else
                    {
                        Mensajes.OcurrioUnError();
                    }
                }
            }
        }