public void crearGastos()
        {
            var gastos = new Gastos
            {
                IdGasto     = 1,
                Monto       = 23.2,
                Descripcion = "retiro de soles",
                Fecha       = new DateTime(2020, 5, 15),
                idCuenta    = 1
            };

            var mocksession = new Mock <IGastos>();

            mocksession.Setup(o => o.crearGastos(gastos));

            var validadcion = new Mock <IValidar>();

            validadcion.Setup(o => o.validarGastos(gastos, null));
            validadcion.Setup(o => o.IsValid()).Returns(true);

            var controler = new GastosController(mocksession.Object, validadcion.Object);
            var view      = controler.Crear(gastos) as RedirectToRouteResult;

            Assert.IsInstanceOf <RedirectToRouteResult>(view);
            mocksession.Verify(o => o.crearGastos(gastos), Times.Once);
        }
        void btnExcluir(object sender, RoutedEventArgs e)
        {
            int idCompra = ((Produto)dgCompra.SelectedItem).ProdutoID;

            ProdutoController pc = new ProdutoController();
            GastosController  gc = new GastosController();

            pc.Excluir(idCompra);
            gc.ExcluiGastosCompra(idCompra);
            CarregarDgGastos();
        }
        private void btnMostrarGastos_Click(object sender, RoutedEventArgs e)
        {
            ProdutoController pc = new ProdutoController();
            GastosController  gc = new GastosController();

            //Produto p = pc.ListarPorUsuario(_Usuario.UsuarioID).First();
            //double soma = gc.SomaGastos(p.ProdutoID);

            MostraGastos mostraGastos = new MostraGastos(_Usuario);

            mostraGastos.Show();
        }
        private void CarregarDgGastos()
        {
            GastosController  gc = new GastosController();
            ProdutoController pc = new ProdutoController();

            dgGastos.ItemsSource = gc.ListarPorUsuario(_Usuario.UsuarioID);
            dgCompra.ItemsSource = pc.ListarPorUsuario(_Usuario.UsuarioID);



            //dgGastos.ItemsSource = pc.ListarTodos();
        }
        private void CalculaPrecoVenda(int id)
        {
            ProdutoController pc = new ProdutoController();
            GastosController  gc = new GastosController();

            Produto produto = pc.BuscarPorID(id);


            double precoFinal = 0;
            double lucro      = 0;

            double soma = gc.SomaGastos(produto.ProdutoID);

            lucro      = produto.Lucro / 100;
            precoFinal = ((produto.precoCompra + soma) / produto.Quantidade) + lucro;
            MessageBox.Show("Preço de Venda é: (" + precoFinal + ")");
        }
Ejemplo n.º 6
0
 private void btnSalvaGastos_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Gastos           g  = new Gastos();
         GastosController gc = new GastosController();
         g.Descricao = descricaoGastoTxt.Text;
         g.Valor     = double.Parse(valorGastoTxt.Text);
         g.ProdutoID = _Produto.ProdutoID;
         g.UsuarioID = _Produto.UsuarioID;
         gc.Adicionar(g);
         descricaoGastoTxt.Text = null;
         valorGastoTxt.Text     = null;
     }
     catch (Exception)
     {
         MessageBox.Show("Erro Fampos vazios ou com erros");
     }
 }
 public ExpenseCongressManDataReceive(IMessagingHubSender sender)
 {
     _sender  = sender;
     despesas = new GastosController();
 }