Exemplo n.º 1
0
        private void createFila()
        {
            var cantidad = txtCantidad.Text;
            var precio   = txtPrecio.Text;
            var stock    = txtStock.Text;

            if (string.IsNullOrEmpty(cantidad) || string.IsNullOrWhiteSpace(cantidad))
            {
                Mensajes.EmptyFields();
            }
            else
            {
                var cant = int.Parse(cantidad);
                var sto  = int.Parse(stock);
                if (cant > sto)
                {
                    MessageBox.Show("No hay suficientes medicamentos debes solicitar mas a tu proveedor", "Advertencia", MessageBoxButtons.OK);
                    return;
                }
                else
                {
                    dgvVentas.Rows.Add(prod.id_producto, txtMedicamento.Text, cantidad, precio);
                    calcularTotal();
                }
            }
        }
Exemplo n.º 2
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();
                }
            }
        }
        private async void btnActualizar_Click(object sender, EventArgs e)
        {
            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();
                }
            }
        }
Exemplo n.º 4
0
        private void button2_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.id_proveedor       = Convert.ToInt32(textBox1.Text);
                proveedor.nombre_proveedor   = nombre;
                proveedor.correo_proveedor   = correo;
                proveedor.telefono_proveedor = telefono;
                int re = _controller.UpdateProveedor(proveedor);
                if (re > 0)
                {
                    Mensajes.ActualizadoConExito();
                    Limpiar();
                    initData();
                }
                else
                {
                    Mensajes.OcurrioUnError();
                }
            }
        }
Exemplo n.º 5
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();
                }
            }
        }
Exemplo n.º 6
0
        private async void button3_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrWhiteSpace(textBox1.Text))
            {
                Mensajes.EmptyFields();
            }
            else
            {
                var id  = int.Parse(textBox1.Text);
                var res = await _controller.DeleteTipoProducto(id);

                if (res > 0)
                {
                    Mensajes.EliminadoConExito();
                }
                else
                {
                    Mensajes.OcurrioUnError();
                }
            }
        }
Exemplo n.º 7
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrWhiteSpace(textBox1.Text))
            {
                Mensajes.EmptyFields();
            }
            else
            {
                var id  = Convert.ToInt32(textBox1.Text);
                var res = _controller.DeleteProveedor(id);

                if (res > 0)
                {
                    Mensajes.EliminadoConExito();
                }
                else
                {
                    Mensajes.OcurrioUnError();
                }
            }
        }
Exemplo n.º 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            var username      = txtUsername.Text;
            var pass          = txtPassword.Text;
            var userViewModel = new UserViewModel();

            if (username.Equals(""))
            {
                Mensajes.EmptyFields();
                txtUsername.Focus();
            }
            else if (pass.Equals(""))
            {
                Mensajes.EmptyFields();
                txtPassword.Focus();
            }
            else
            {
                userViewModel.Username = username;
                userViewModel.Pass     = Encriptar.encriptarPassword(pass);

                var user = Controller.GetUsuario(userViewModel);
                if (user != null)
                {
                    if (user.Nombre != "")
                    {
                        var userLogin = UserLogin.Instance;
                        MessageBox.Show($"Bienvenido  {user.Nombre}");
                        userLogin.ID_USER = user.ID;
                        userLogin.ROL     = user.ROL_ID;

                        Views.Menu.Mennu mennu = new Views.Menu.Mennu();
                        mennu.Show();
                        Hide();
                    }
                }
            }
        }