private void btnSalvar_Click(object sender, EventArgs e) { try { GastosDTO dto = new GastosDTO(); dto.Nome = txtNome.Text; dto.Descricao = txtDescricao.Text; dto.Data = mkbData.Text; dto.Valor = nudValor.Value; GastosBusiness buss = new GastosBusiness(); buss.Salvar(dto); string msg = "Gasto salvo com sucesso!"; frmMessage tela = new frmMessage(); tela.LoadScreen(msg); tela.ShowDialog(); } catch (Exception ex) { string msg = "Ocorreu um erro: " + ex.Message; frmException tela = new frmException(); tela.LoadScreen(msg); tela.ShowDialog(); } }
private void button1_Click(object sender, EventArgs e) { GastosDTO dto = new GastosDTO(); dto.Descricao = txtgastos.Text; dto.Data_gastos = dtpdata.Value; dto.tipo = cbotipo.Text; dto.Valor = Convert.ToDecimal(maskedTextBox1.Text); GastosBussiness bussiness = new GastosBussiness(); bussiness.Salvar(dto); MessageBox.Show("Gasto cadastrado com sucesso", "Realce Sua Beleza"); }
public async Task <ActionResult <GastosDTO> > Get([FromQuery] ParametrosBusquedaGastos parametrosBusqueda) { var gastosQueryable = context.Gastos.AsQueryable(); if (!string.IsNullOrWhiteSpace(parametrosBusqueda.Nombre)) { gastosQueryable = gastosQueryable .Where(x => x.Nombre.ToLower().Contains(parametrosBusqueda.Nombre.ToLower())); } if (parametrosBusqueda.Mes != 0) { gastosQueryable = gastosQueryable.Where(x => x.Fecha.Value.Month == parametrosBusqueda.Mes); } if (parametrosBusqueda.PersonaId != 0) { gastosQueryable = gastosQueryable.Where(x => x.PersonaId == parametrosBusqueda.PersonaId); } if (parametrosBusqueda.TipoId != 0) { gastosQueryable = gastosQueryable.Where(x => x.TipoId == parametrosBusqueda.TipoId); } if (parametrosBusqueda.Pagados) { gastosQueryable = gastosQueryable.Where(x => x.Pagado); } gastosQueryable = gastosQueryable.OrderByDescending(x => x.Fecha); await HttpContext.InsertarParametrosPaginacionEnRespuesta(gastosQueryable, parametrosBusqueda.CantidadRegistros); var gastos = new GastosDTO { totalGastos = gastosQueryable.Sum(x => x.Monto.Value), Gastos = await gastosQueryable.Paginar(parametrosBusqueda.Paginacion) .Include(x => x.Persona) .Include(x => x.Tipo) .ToListAsync() }; return(gastos); }