public void AtualizarDados(bool grid = true) { _mPedido = _mPedido.FindById(idPedido).FirstOrDefault <Model.Pedido>(); if (grid) { _controllerTitulo.GetDataTableTitulos(GridListaFormaPgtos, idPedido); } dynamic devolucoes = _mPedido.Query() .SelectRaw("SUM(total) as total") .Where("excluir", 0) .Where("tipo", "Devoluções") .Where("Venda", idPedido) .FirstOrDefault <Model.Pedido>(); acrescimos.Text = Validation.FormatPrice(_controllerTitulo.GetTotalFrete(idPedido), true); discount.Text = Validation.FormatPrice( _controllerTitulo.GetTotalDesconto(idPedido) + Validation.ConvertToDouble(devolucoes.Total), true); troco.Text = Validation.FormatPrice(_controllerTitulo.GetTroco(idPedido), true).Replace("-", ""); pagamentos.Text = Validation.FormatPrice(_controllerTitulo.GetLancados(idPedido), true); total.Text = Validation.FormatPrice(_controllerTitulo.GetTotalPedido(idPedido), true); var aPagar = Validation.RoundTwo(_controllerTitulo.GetTotalPedido(idPedido) - _controllerTitulo.GetLancados(idPedido)); aPagartxt.Text = _controllerTitulo.GetLancados(idPedido) < _controllerTitulo.GetTotalPedido(idPedido) ? Validation.FormatPrice(aPagar, true) : "R$ 0,00"; if (_controllerTitulo.GetLancados(idPedido) > 0) { Desconto.Enabled = false; Acrescimo.Enabled = false; Devolucao.Enabled = false; } else { Desconto.Enabled = true; Acrescimo.Enabled = true; Devolucao.Enabled = true; } if (aPagar <= 0) { label15.BackColor = Color.FromArgb(46, 204, 113); aPagartxt.BackColor = Color.FromArgb(46, 204, 113); visualPanel1.BackColorState.Enabled = Color.FromArgb(46, 204, 113); visualPanel1.Border.Color = Color.FromArgb(39, 192, 104); Recebimentos = false; Dinheiro.Enabled = false; Cheque.Enabled = false; Debito.Enabled = false; Credito.Enabled = false; Crediario.Enabled = false; Boleto.Enabled = false; Refresh(); } else { label15.BackColor = Color.FromArgb(255, 40, 81); aPagartxt.BackColor = Color.FromArgb(255, 40, 81); visualPanel1.BackColorState.Enabled = Color.FromArgb(255, 40, 81); visualPanel1.Border.Color = Color.FromArgb(241, 33, 73); Recebimentos = true; Dinheiro.Enabled = true; Cheque.Enabled = true; Debito.Enabled = true; Credito.Enabled = true; Crediario.Enabled = true; Boleto.Enabled = true; Refresh(); } }