Example #1
0
        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();
            }
        }
Example #2
0
        private void LoadTable(DataGridView table)
        {
            table.Rows.Clear();

            var pedidos = new Pedido().Query();

            pedidos.WhereFalse("excluir");
            pedidos.Where(q => q.Where("tipo", "Delivery").OrWhere("tipo", "Balcao").OrWhere("campof", "MESA"));
            pedidos.OrderByDesc("id");

            #region Filtros

            if (!string.IsNullOrEmpty(BuscaID.Text))
            {
                pedidos.Where("id", BuscaID.Text);
            }

            if (Entregador.SelectedValue.ToString() != "0")
            {
                pedidos.Where("id_transportadora", Entregador.SelectedValue.ToString());
            }

            if (Status.SelectedValue.ToString() != "0")
            {
                pedidos.Where("campoa", Status.SelectedValue.ToString());
            }

            if (!string.IsNullOrEmpty(BuscarPessoa.Text))
            {
                pedidos.Where("cliente", collectionClientes.Lookup(BuscarPessoa.Text));
            }

            if (!noFilterData.Checked)
            {
                pedidos.Where("emissao", ">=", Validation.ConvertDateToSql(dataInicial.Text));
                pedidos.Where("emissao", "<=", Validation.ConvertDateToSql(dataFinal.Text));
            }

            #endregion

            var data = pedidos.Get <Pedido>();
            if (data.Any())
            {
                foreach (var pedido in data)
                {
                    var cliente = "";
                    if (GetDataPessoa(pedido.Cliente) != null)
                    {
                        cliente = GetDataPessoa(pedido.Cliente).Nome;
                    }

                    var entregador = "";
                    if (GetDataPessoa(pedido.Id_Transportadora) != null)
                    {
                        entregador = GetDataPessoa(pedido.Id_Transportadora).Nome;
                    }

                    var statusPagamento =
                        _controllerTitulo.GetLancados(pedido.Id) < _controllerTitulo.GetTotalPedido(pedido.Id)
                            ? "Receber"
                            : "Recebido";

                    table.Rows.Add(
                        pedido.Id,
                        pedido.Tipo,
                        pedido.Id,
                        cliente,
                        entregador,
                        GetStatus(pedido.campoa),
                        statusPagamento,
                        Validation.FormatPrice(pedido.Total, true)
                        );
                }
            }

            table.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
        }