Пример #1
0
 private void cbCaixa_Validating(object sender, CancelEventArgs e)
 {
     cb_Validating(sender, e);
     if (!e.Cancel)
     {
         if (cbCaixa.SelectedValue != null)
         {
             caixaBLL = new CaixaBLL();
             int          id_caixa  = Convert.ToInt32(cbCaixa.SelectedValue);
             int          status    = (int)StatusPedido.ENTREGUE;
             List <Caixa> CaixaList = caixaBLL.getCaixa(p => p.Id == id_caixa & p.pedido_otica.Any(c => c.status < status));
             if (CaixaList.Count > 0)
             {
                 if (Id != null)
                 {
                     if (Id != CaixaList.FirstOrDefault().pedido_otica.Where(t => t.status < status).FirstOrDefault().Id)
                     {
                         MessageBox.Show("Caixa selecionada está em uso no pedido : " + CaixaList.FirstOrDefault().pedido_otica.Where(t => t.status < status).FirstOrDefault().codigo, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                         epValidaDados.SetError(cbCaixa, "Caixa selecionada está em uso no pedido: " + CaixaList.FirstOrDefault().pedido_otica.Where(t => t.status < status).FirstOrDefault().codigo);
                         e.Cancel = true;
                     }
                 }
                 else
                 {
                     MessageBox.Show("Caixa selecionada está em uso no pedido : " + CaixaList.FirstOrDefault().pedido_otica.Where(t => t.status < status).FirstOrDefault().codigo, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                     epValidaDados.SetError(cbCaixa, "Caixa selecionada está em uso no pedido: " + CaixaList.FirstOrDefault().pedido_otica.Where(t => t.status < status).FirstOrDefault().codigo);
                     e.Cancel = true;
                 }
             }
         }
     }
 }
Пример #2
0
        protected override bool salvar(object sender, EventArgs e)
        {
            if (epValidaDados.Validar())
            {
                Caixa Caixa = new Caixa();
                CaixaBLL = new CaixaBLL();

                CaixaBLL.UsuarioLogado = Program.usuario_logado;

                Caixa = LoadFromControls();

                if (Id != null)
                {
                    CaixaBLL.AlterarCaixa(Caixa);
                }
                else
                {
                    CaixaBLL.AdicionarCaixa(Caixa);
                }

                if (Caixa.Id != 0)
                {
                    Id         = Caixa.Id;
                    txtId.Text = Caixa.Id.ToString();
                }
                txtNumero.Focus();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        private void FillCaixa()
        {
            CaixaBLL bll           = new CaixaBLL();
            decimal  saldoInicial  = 0;
            decimal  totalDinheiro = 0;
            decimal  totalCartao   = 0;
            decimal  totalFormasPg = 0;
            decimal  totalRetirada = 0;

            if (bll.CaixaAberto())
            {
                Caixa cx = bll.GetCaixaAberto();
                saldoInicial  = cx.GetSaldoInicial();
                totalDinheiro = cx.GetTotalFormaPg(FormaPagamento.DINHEIRO);
                totalCartao   = cx.GetTotalFormaPg(FormaPagamento.CARTAO);
                totalFormasPg = (totalDinheiro + totalCartao);
                totalRetirada = cx.GetTotalRetirada();
                btRetidadaCaixa.Visibility = Visibility.Visible;
            }
            else
            {
                btRetidadaCaixa.Visibility = Visibility.Hidden;
            }

            lbSaldoInicial.Content       = $"R$ {saldoInicial.ToString("N2")}";
            lbTotalDinheiro.Content      = $"R$ {totalDinheiro.ToString("N2")}";
            lbTotalCartao.Content        = $"R$ {totalCartao.ToString("N2")}";
            lbTotalEntradas.Content      = $"R$ {totalFormasPg.ToString("N2")}";
            lbTotalGeralDinheiro.Content = $"R$ {(saldoInicial + totalDinheiro - totalRetirada).ToString("N2")}";
            lbTotalGeralTudo.Content     = $"R$ {(saldoInicial + totalDinheiro + totalCartao - totalRetirada).ToString("N2")}";
            lbTotalRetirada.Content      = $"R$ {totalRetirada.ToString("N2")}";
        }
Пример #4
0
        protected virtual Caixa LoadFromControls()
        {
            Caixa caixa = new Caixa();

            if (Id != null)
            {
                caixa.Id = Convert.ToInt32(txtId.Text);
            }

            caixa.numero = txtNumero.Text;

            CaixaBLL = new CaixaBLL();

            List <Caixa> lstCaixa = CaixaBLL.getCaixa(p => p.numero == caixa.numero);

            if (lstCaixa.Count() > 0)
            {
                caixa      = lstCaixa.First();
                Id         = caixa.Id;
                txtId.Text = caixa.Id.ToString();
            }

            caixa.inativo = chkInativo.Checked ? "S" : "N";

            return(caixa);
        }
        private void btConcluirServico_Click(object sender, RoutedEventArgs e)
        {
            Valid();

            var cx = new CaixaBLL().GetCaixaAberto();

            if (cx == null)
            {
                MessageBox.Show("O caixa deve estar aberto antes de realizar o pagamento do serviço",
                                "Atenção", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            ServicoBLL         bll   = new ServicoBLL();
            decimal            total = bll.Find(int.Parse(txNumBloco.Text)).GetTotalGeral();
            PagamentoAdiantado pa    = new PagamentoAdiantado(total,
                                                              int.Parse(txNumBloco.Text), true);

            pa.ShowDialog();

            if (pa.Confirmado)
            {
                Close();
            }
        }
        public CadServico()
        {
            InitializeComponent();

            btConcluirServico.Visibility = Visibility.Hidden;
            btExcluir.Visibility         = Visibility.Hidden;
            txData.SelectedDate          = DateTime.Now;
            txNumBloco.ToNumeric();
            dataGrid.AplicarPadroesFinanceiro();
            datagridMateriais.AplicarPadroesFinanceiro();
            txTotalMateriais.ToMoney();
            txTotalServicos.ToMoney();
            txAdiantamento.ToMoney();
            txFalta.ToMoney();

            var cx = new CaixaBLL().GetCaixaAberto();

            if (cx != null)
            {
                btPagamentoAdiantado.Visibility = Visibility.Visible;
            }
            else
            {
                btPagamentoAdiantado.Visibility = Visibility.Hidden;
            }
        }
Пример #7
0
        private void Fecha()
        {
            CaixaBLL bll = new CaixaBLL();
            Caixa    cx  = bll.GetCaixaAberto();

            cx = bll.Find(cx.Id);
            cx.DataFechamento = DateTime.Now;

            SalvaTxt(cx);

            MovimentoCaixa mc = new MovimentoCaixa();

            mc.CaixaId        = cx.Id;
            mc.Valor          = decimal.Parse(txValorFinal.Text.Replace("R$", ""));
            mc.Obs            = "Fechamento do caixa";
            mc.FormaPagamento = (int)FormaPagamento.DINHEIRO;
            mc.Tipo           = (int)TipoMovCaixa.Saida;

            MovimentoCaixaBLL mcBll = new MovimentoCaixaBLL();

            mcBll.Save(mc);

            cx = bll.Find(cx.Id);
            cx.DataFechamento = DateTime.Now;
            cx.Aberto         = false;
            bll.Save(cx);
        }
Пример #8
0
        private void btAbrirFecharCaixa_Click(object sender, RoutedEventArgs e)
        {
            CaixaBLL bll = new CaixaBLL();

            if (!bll.CaixaAberto())
            {
                AbrirCaixa ac = new AbrirCaixa();
                ac.ShowDialog();
            }
            else
            {
                FecharCaixa fc = new FecharCaixa();
                fc.ShowDialog();
            }

            if (bll.CaixaAberto())
            {
                btAbrirFecharCaixa.Content = "Fechar Caixa";
            }
            else
            {
                btAbrirFecharCaixa.Content = "Abrir Caixa";
            }

            FillCaixa();
        }
Пример #9
0
        protected override void carregaConsulta()
        {
            base.carregaConsulta();
            CaixaBLL = new CaixaBLL();
            List <Caixa> lstCaixa = CaixaBLL.getCaixa(p => p.Id.ToString(), false, deslocamento, tamanhoPagina, out totalReg);

            dgvDados.DataSource = CaixaBLL.ToList_CaixaView(lstCaixa);
            colOrdem            = 0;
        }
Пример #10
0
        private void SalvaTxt(Caixa cx)
        {
            CaixaBLL bll = new CaixaBLL();

            decimal saldoInicial  = cx.GetSaldoInicial();
            decimal totalDinheiro = cx.GetTotalFormaPg(FormaPagamento.DINHEIRO);
            decimal totalCartao   = cx.GetTotalFormaPg(FormaPagamento.CARTAO);
            decimal totalFormasPg = (totalDinheiro + totalCartao);
            decimal totalRetirada = cx.GetTotalRetirada();

            string txt = $@"N° {cx.Id}
Caixa Cutelaria Retiro (Serviços)
Abertura: {cx.DataAbertura.ToString("dd/MM/yyyy HH:mm")}
Fechamento {cx.DataFechamento.Value.ToString("dd/MM/yyyy HH:mm")}

--------------------------------------
(+) SALDO INICIAL   {saldoInicial}
(+) ENTRADAS NO CAIXA
    DINHEIRO R$ {totalDinheiro.ToString("N2")}
    CARTÃO   R$ {totalCartao.ToString("N2")}
    ----------------------------------
    TOTAL    R$ {totalFormasPg.ToString("N2")}

(-) SAIDAS NO CAIXA  R$ {totalRetirada.ToString("N2")}
(=) SALDO FINAL
    SOMENTE DINHEIRO  R$ {(saldoInicial + totalDinheiro - totalRetirada).ToString("N2")}
    TUDO              R$ {(saldoInicial + totalDinheiro + totalCartao - totalRetirada).ToString("N2")}";

            string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

            path += $@"\CAIXA CUTELARIA - DIA {DateTime.Now.ToString("dd-MM-yyyy")}.txt";
            File.WriteAllText(path, txt);

            System.Diagnostics.Process.Start(path);

            if (!Directory.Exists(@".\Caixa\"))
            {
                Directory.CreateDirectory(@".\Caixa\");
            }

            int    counter    = 0;
            string backupName = $@".\Caixa\{DateTime.Now.ToString("dd-MM-yyyy")}.txt";

            while (File.Exists(backupName))
            {
                counter   += 1;
                backupName = $@".\Caixa\{DateTime.Now.ToString("dd-MM-yyyy")} ({counter}).txt";
            }

            File.Copy(path, backupName);
        }
Пример #11
0
        private void btRetidadaCaixa_Click(object sender, RoutedEventArgs e)
        {
            CaixaBLL bll = new CaixaBLL();

            if (!bll.CaixaAberto())
            {
                return;
            }

            RetiradaCaixa rc = new RetiradaCaixa();

            rc.ShowDialog();

            FillCaixa();
        }
Пример #12
0
        private void FillCaixa()
        {
            CaixaBLL bll = new CaixaBLL();

            if (bll.CaixaAberto())
            {
                Caixa   cx            = bll.GetCaixaAberto();
                decimal saldoInicial  = cx.GetSaldoInicial();
                decimal totalDinheiro = cx.GetTotalFormaPg(FormaPagamento.DINHEIRO);
                decimal totalCartao   = cx.GetTotalFormaPg(FormaPagamento.CARTAO);
                decimal totalFormasPg = (totalDinheiro + totalCartao);
                decimal totalRetirada = cx.GetTotalRetirada();

                txSaldoDinheiro.Text = $"R$ {(saldoInicial + totalDinheiro).ToString("N2")}";
                txValorFinal.Text    = $"R$ {(saldoInicial + totalDinheiro + totalCartao - totalRetirada).ToString("N2")}";
            }
        }
Пример #13
0
        private void btConfirmar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                decimal saldoInicial = decimal.Parse(txSaldoInicial.Text);
                string  obs          = txObs.Text;

                CaixaBLL bll = new CaixaBLL();
                bll.AbreCaixa(saldoInicial, obs);
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,
                                "Erro", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
Пример #14
0
        protected override void LoadToControls()
        {
            base.LoadToControls();

            if (Id != null)
            {
                CaixaBLL = new CaixaBLL();
                Caixa Caixa = CaixaBLL.Localizar(Id);

                if (Caixa != null)
                {
                    txtId.Text         = Caixa.Id.ToString();
                    txtNumero.Text     = Caixa.numero;
                    chkInativo.Checked = Caixa.inativo == "S";
                    txtNumero.Focus();
                }
            }
        }
Пример #15
0
        private void btConfirmar_Click(object sender, RoutedEventArgs e)
        {
            Caixa          cx = new CaixaBLL().GetCaixaAberto();
            MovimentoCaixa mc = new MovimentoCaixa();

            mc.ServicoId      = ServicoId;
            mc.CaixaId        = cx.Id;
            mc.FormaPagamento = (int)comboBox.SelectedValue;
            mc.Valor          = decimal.Parse(txValorAdiantamento.Text);
            mc.Tipo           = (int)TipoMovCaixa.Entrada;
            mc.Obs            = $"Adiantamento de pagamento do serviço N° {ServicoId}";

            if (mc.FormaPagamento == -1)
            {
                MessageBox.Show("Selecione uma forma de pagamento",
                                "Atenção", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            MovimentoCaixaBLL bll = new MovimentoCaixaBLL();

            bll.Save(mc);

            if (FecharServico)
            {
                ServicoBLL servBLL = new ServicoBLL();
                var        serv    = servBLL.Find(ServicoId);
                serv.Finalizado = true;
                servBLL.Save(serv);

                List <MaterialServico> materiaisServ = serv.MaterialServico.ToList();

                foreach (MaterialServico m in materiaisServ)
                {
                    MaterialBLL matBll   = new MaterialBLL();
                    var         material = matBll.Find(m.MaterialId);
                    material.Estoque -= m.Quantidade;
                    matBll.Save(material);
                }
            }

            Confirmado = true;
            Close();
        }
Пример #16
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            CaixaBLL bll = new CaixaBLL();
            Caixa    cx  = bll.GetCaixaAberto();

            MovimentoCaixa mc = new MovimentoCaixa();

            mc.CaixaId        = cx.Id;
            mc.Obs            = txDescricao.Text;
            mc.Tipo           = (int)TipoMovCaixa.Saida;
            mc.Valor          = decimal.Parse(txValor.Text);
            mc.FormaPagamento = (int)FormaPagamento.DINHEIRO;

            MovimentoCaixaBLL mcBll = new MovimentoCaixaBLL();

            mcBll.Save(mc);

            Close();
        }
Пример #17
0
        private void SetupCaixa(ComboBox cb)
        {
            CaixaBLL caixaBLL = new CaixaBLL();

            List <Caixa> CaixaList = caixaBLL.getCaixa();

            AutoCompleteStringCollection acc = new AutoCompleteStringCollection();

            foreach (Caixa item in CaixaList)
            {
                acc.Add(item.numero);
            }

            cb.DataSource = CaixaList;
            cb.AutoCompleteCustomSource = acc;
            cb.ValueMember   = "Id";
            cb.DisplayMember = "numero";
            cb.SelectedIndex = -1;
        }
Пример #18
0
 protected override void excluirRegistro(int Id)
 {
     base.excluirRegistro(Id);
     CaixaBLL = new CaixaBLL();
     try
     {
         if (Convert.ToInt32(dgvDados[0, dgvDados.CurrentRow.Index].Value) > 0)
         {
             Caixa Caixa = CaixaBLL.Localizar(Convert.ToInt32(dgvDados[0, dgvDados.CurrentRow.Index].Value));
             if (MessageBox.Show("Deseja realmente excluir o registro : " + Caixa.Id.ToString() + " - " + Caixa.numero, Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 CaixaBLL.ExcluirCaixa(Caixa);
             }
         }
     }
     finally
     {
         CaixaBLL.Dispose();
     }
 }
Пример #19
0
        public MainWindow()
        {
            InitializeComponent();

            if (!Directory.Exists(@".\Data\"))
            {
                Directory.CreateDirectory(@".\Data\");
            }

            CaixaBLL bll = new CaixaBLL();

            if (bll.CaixaAberto())
            {
                btAbrirFecharCaixa.Content = "Fechar Caixa";
            }
            else
            {
                btAbrirFecharCaixa.Content = "Abrir Caixa";
            }

            FillServicosAndamento();
            FillCaixa();
        }
Пример #20
0
        public ActionResult Vulso(CompraVM model)
        {
            if (string.IsNullOrEmpty(model.Fornecedor.nome))
            {
                ModelState.AddModelError("Fornecedor.nome", "Informe o fornecedor");
            }
            if (model.total <= 0)
            {
                ModelState.AddModelError("total", "Informe o total");
            }
            if (ModelState.IsValid)
            {
                try
                {
                    LogBLL.Insert(new LogDado("Vulso", "Compra", _idUsuario));
                    using (var db = new Context())
                    {
                        using (var trans = new RP.DataAccess.RPTransactionScope(db))
                        {
                            var _compra = model.GetCompra();

                            var _bll = new BLL.CompraBLL(db, _idUsuario);

                            _bll.Insert(_compra);
                            var _contaBLL = new ContaPagarBLL(db, _idUsuario);
                            var _caixaBLL = new CaixaBLL(db, _idUsuario);
                            if (model.Parcelas != null && model.Parcelas.Any())
                            {
                                int nrParcelas = model.Parcelas.Count;
                                foreach (var item in model.Parcelas)
                                {
                                    string situacao = ContaPagar.SITUACAO_AGUARDANDO_PAGAMENTO;
                                    decimal? vlPago = null;
                                    DateTime? dtPagamento = null;
                                    if (item.dtVencimento <= DateTime.Now.Date)
                                    {
                                        vlPago = item.vlParcela;
                                        situacao = ContaPagar.SITUACAO_PAGO;
                                        dtPagamento = item.dtVencimento;
                                    }

                                    // Lança conta a pagar referente a parcela
                                    var _conta = new ContaPagar
                                    {
                                        idFornecedor = _compra.idFornecedor,
                                        parcela = item.nrParcela,
                                        descricao = "Conta a pagar referente a " + item.nrParcela + "º parcela.  " + item.dsObservacao,
                                        vencimento = item.dtVencimento,
                                        pagamento = dtPagamento,
                                        valorConta = item.vlParcela,
                                        valorPago = vlPago,
                                        situacao = situacao,
                                        flFormaPagamento = item.flFormaPagamento,
                                        Compra = _compra
                                    };
                                    _contaBLL.Insert(_conta);

                                    //se a data de vencimento for a atual lança a entrada no caixa
                                    if (item.dtVencimento <= DateTime.Now.Date)
                                    {
                                        _caixaBLL.Insert(new Caixa
                                        {
                                            ContaPagar = _conta,
                                            situacao = Caixa.CORENTE,
                                            valor = (item.vlParcela * -1),
                                            descricao = _compra.descricao + " [" + model.Fornecedor.nome + "] " + item.dsObservacao,
                                            dtLancamento = item.dtVencimento
                                        });
                                    }
                                }
                            }
                            else
                            {
                                var _conta = new ContaPagar
                                {
                                    idFornecedor = _compra.idFornecedor,
                                    parcela = 1,
                                    descricao = "Conta a pagar referente a " + model.descricao + " [Fornecedor:" + model.Fornecedor.nome + "] ",
                                    vencimento = DateTime.Now,
                                    pagamento = DateTime.Now,
                                    valorConta = model.total,
                                    valorPago = model.total,
                                    situacao = ContaPagar.SITUACAO_PAGO,
                                    flFormaPagamento = string.Empty,
                                    Compra = _compra
                                };
                                _contaBLL.Insert(_conta);
                                _caixaBLL.Insert(new Caixa
                                {
                                    ContaPagar = _conta,
                                    situacao = Caixa.CORENTE,
                                    valor = (model.total * -1),
                                    descricao = model.descricao + " [" + model.Fornecedor.nome + "] " + model.descricao,
                                    dtLancamento = DateTime.Now
                                });
                            }
                            _bll.SaveChanges();

                            trans.Complete();

                            this.AddFlashMessage("Compra realizada com sucesso!", FlashMessage.SUCCESS);
                            return RedirectToAction("Index", "Compra");
                        }
                    }
                }
                catch (Exception ex)
                {
                    RP.Util.Entity.ErroLog.Add(ex, Session.SessionID, _idUsuario);
                    return RedirectToAction("Index", "Erro", new { area = string.Empty });
                }
            }
            return View(model);
        }
Пример #21
0
        public ActionResult Aprovar(AprovarVM model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    LogBLL.Insert(new LogDado("Aprovar", "Projeto", _idUsuario));
                    using (var db = new Context())
                    {
                        using (var trans = new RP.DataAccess.RPTransactionScope(db))
                        {
                            var _projeto = model.GetProjeto();

                            var _bll = new BLL.ProjetoBLL(db, _idUsuario);
                            if (_projeto.status == Projeto.VENDIDO)
                            {
                                var _movimentoBLL = new MovimentoProfissionalBLL(db, _idUsuario);
                                var _contaBLL = new ContaReceberBLL(db, _idUsuario);
                                int nrParcelas = model.Parcelas.Count;
                                foreach (var item in model.Parcelas)
                                {
                                    //comissao do vendedor
                                    _movimentoBLL.Insert(new MovimentoProfissional
                                    {
                                        tipo = MovimentoProfissional.TIPO_COMISSAO,
                                        idFuncionario = model.Vendedor.idFuncionario ?? 0,
                                        valor = ((model.porcentagemVendedor / 100) * item.vlParcela),
                                        idProjeto = _projeto.idProjeto,
                                        situacao = MovimentoProfissional.SITUACAO_PENDENTE,
                                        descricao = "Comissão referente a " + item.nrParcela + "º parcela do projeto " + _projeto.descricao,
                                        dtVencimento = item.dtVencimento
                                    });

                                    foreach (var produto in _projeto.Produtos)
                                    {
                                        decimal vlParcela = (produto.vlVenda ?? 0) / nrParcelas;

                                        //comissao do projetista
                                        _movimentoBLL.Insert(new MovimentoProfissional
                                        {
                                            tipo = MovimentoProfissional.TIPO_COMISSAO,
                                            idFuncionario = produto.idProjetista ?? 0,
                                            valor = (((produto.porcentagemProjetista ?? 0) / 100) * vlParcela),
                                            idProjeto = _projeto.idProjeto,
                                            situacao = MovimentoProfissional.SITUACAO_PENDENTE,
                                            descricao = "Comissão referente a " + item.nrParcela + "º parcela do projeto " + _projeto.descricao + " [" + produto.nome + "]",
                                            dtVencimento = item.dtVencimento
                                        });

                                        //comissao do marceneiro
                                        _movimentoBLL.Insert(new MovimentoProfissional
                                        {
                                            tipo = MovimentoProfissional.TIPO_COMISSAO,
                                            idFuncionario = produto.idMarceneiro ?? 0,
                                            valor = (((produto.porcentagemMarceneiro ?? 0) / 100) * vlParcela),
                                            idProjeto = _projeto.idProjeto,
                                            situacao = MovimentoProfissional.SITUACAO_PENDENTE,
                                            descricao = "Comissão referente a " + item.nrParcela + "º parcela do projeto " + _projeto.descricao + " [" + produto.nome + "]",
                                            dtVencimento = item.dtVencimento
                                        });

                                    }

                                    string situacao = ContaReceber.SITUACAO_AGUARDANDO_PAGAMENTO;
                                    decimal? vlPago = null;
                                    DateTime? dtPagamento = null;
                                    if (item.dtVencimento <= DateTime.Now.Date)
                                    {
                                        vlPago = item.vlParcela;
                                        situacao = ContaReceber.SITUACAO_PAGO;
                                        dtPagamento = item.dtVencimento;
                                    }

                                    // Lança conta a receber referente a parcela
                                    var _conta = new ContaReceber
                                    {
                                        idCliente = _projeto.idCliente,
                                        parcela = item.nrParcela,
                                        descricao = "Conta a receber referente a " + item.nrParcela + "º parcela do projeto " + _projeto.descricao + ".  " + item.dsObservacao,
                                        vencimento = item.dtVencimento,
                                        pagamento = dtPagamento,
                                        valorConta = item.vlParcela,
                                        valorPago = vlPago,
                                        situacao = situacao,
                                        flFormaPagamento = item.flFormaPagamento,
                                        idProjeto = _projeto.idProjeto
                                    };
                                    _contaBLL.Insert(_conta);

                                    //se a data de vencimento for a atual lança a entrada no caixa
                                    if (item.dtVencimento <= DateTime.Now.Date)
                                    {
                                        var _caixaBLL = new CaixaBLL(db, _idUsuario);
                                        _caixaBLL.Insert(new Caixa
                                        {
                                            ContaReceber = _conta,
                                            situacao = Caixa.CORENTE,
                                            valor = item.vlParcela,
                                            descricao = _conta.descricao + " [" +model.Cliente.nome + "] " + item.dsObservacao,
                                            dtLancamento = dtPagamento.Value
                                        });
                                    }
                                }
                            }

                            _bll.Aprovar(_projeto);
                            _bll.SaveChanges();
                            trans.Complete();

                            this.AddFlashMessage("Projeto atualizado com sucesso!", FlashMessage.SUCCESS);
                            return RedirectToAction("Index");
                        }
                    }
                }
                catch (Exception ex)
                {
                    RP.Util.Entity.ErroLog.Add(ex, Session.SessionID, _idUsuario);
                    return RedirectToAction("Index", "Erro", new { area = string.Empty });
                }
            }
            return View(model);
        }
Пример #22
0
        protected override void ordenaCelula(object sender, DataGridViewCellMouseEventArgs e)
        {
            base.ordenaCelula(sender, e);
            CaixaBLL = new CaixaBLL();

            DataGridViewColumn col    = dgvFiltro.Columns[e.ColumnIndex];
            DataGridViewColumn colAnt = dgvFiltro.Columns[colOrdem];

            ListSortDirection direction;

            switch (col.HeaderCell.SortGlyphDirection)
            {
            case SortOrder.None:
                direction = ListSortDirection.Ascending;
                break;

            case SortOrder.Ascending:
                direction = ListSortDirection.Ascending;
                break;

            case SortOrder.Descending:
                direction = ListSortDirection.Descending;
                break;

            default:
                direction = ListSortDirection.Ascending;
                break;
            }


            if (colOrdem == e.ColumnIndex)
            {
                if (direction == ListSortDirection.Ascending)
                {
                    direction = ListSortDirection.Descending;
                }
                else
                {
                    direction = ListSortDirection.Ascending;
                    col.HeaderCell.SortGlyphDirection = SortOrder.None;
                }
            }
            else
            {
                direction = ListSortDirection.Ascending;
                colAnt.HeaderCell.SortGlyphDirection = SortOrder.None;
            }

            switch (e.ColumnIndex)
            {
            case COL_NUMERO:
            {
                List <Caixa> CaixaList = CaixaBLL.getCaixa(p => p.numero, direction != ListSortDirection.Ascending, deslocamento, tamanhoPagina, out totalReg);
                dgvDados.DataSource = CaixaBLL.ToList_CaixaView(CaixaList);
            }
            break;

            //O default será executado quando o index for 0
            default:
            {
                List <Caixa> CaixaList = CaixaBLL.getCaixa(p => p.Id.ToString(), direction != ListSortDirection.Ascending, deslocamento, tamanhoPagina, out totalReg);
                dgvDados.DataSource = CaixaList;
            }
            break;
            }

            colOrdem = e.ColumnIndex;

            col.HeaderCell.SortGlyphDirection = direction == ListSortDirection.Ascending ?
                                                SortOrder.Ascending : SortOrder.Descending;
        }