Example #1
0
        public ActionResult pagarparcela(int id)
        {
            if (Session["idVendedor"] != null)
            {
                ParcelasDAO    objPD  = new ParcelasDAO();
                PagamentoDAO   objPgD = new PagamentoDAO();
                Parcelas       objP   = new Parcelas();
                VendaaPrazoDAO objVPD = new VendaaPrazoDAO();

                //retorna a idPagamento
                int idPagamento = objPgD.realizaPagamento(id);
                objP.idPagamento = idPagamento;
                objP.idParcela   = id;
                objPD.pagarParcela(objP);

                TempData["idPag"] = idPagamento;
                // string retorno = Request["idPagamento"].ToString();
                //ViewBag.retorno = idPagamento.ToString();


                //atualizar as parcelas restantes da vendaaprazo
                int idvendaaprazo = objPD.selecionaidVendaaPrazo(id);
                objVPD.atualizaVendaaprazo(idvendaaprazo);

                return(RedirectToAction("sucessopg/" + idPagamento + ""));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Example #2
0
        public ActionResult ERRelatorioVencimentos()
        {
            if (Session["idVendedor"] != null)
            {
                string          data    = DateTime.Now.ToString("dd-MM-yyyy");
                List <Parcelas> Retorno = new List <Parcelas>();
                ParcelasDAO     OP      = new ParcelasDAO();
                Retorno = OP.Vencimentos();

                ReportDocument rd = new ReportDocument();
                rd.Load(Path.Combine(Server.MapPath("~/Reports"), "RelatorioVencimentos.rpt"));
                rd.SetDataSource(Retorno);

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();

                try
                {
                    Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    stream.Seek(0, SeekOrigin.Begin);
                    return(File(stream, "application/pdf", "JeR_RelatorioVencimentos_" + data + ".pdf"));
                }
                catch (Exception e)
                {
                    throw;
                }
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Example #3
0
        //se o pagamento for bem sucedido
        public ActionResult sucessopg(int id)
        {
            if (Session["idVendedor"] != null)
            {
                PagamentoDAO objPD = new PagamentoDAO();
                Pagamento    objP  = objPD.GetPagamento(id);

                ParcelasDAO objPrD = new ParcelasDAO();
                Parcelas    objPr  = objPrD.GetParcelas(id);

                return(View(Tuple.Create(objPr, objP)));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Example #4
0
        public ActionResult verParcelas(string id)
        {
            if (Session["idVendedor"] != null)
            {
                /*ClientesDAO objClDAO = new ClientesDAO();
                 * string nomeCliente = objClDAO.selecionanomeCliente(id);
                 *
                 * TempData["Msg"] = nomeCliente;*/


                VendaaPrazoDAO objVAPDAO     = new VendaaPrazoDAO();
                string         idVendaaPrazo = objVAPDAO.pegaridVendaaprazo(id);

                ParcelasDAO     objPaDAO      = new ParcelasDAO();
                List <Parcelas> listaParcelas = new List <Parcelas>();
                listaParcelas = objPaDAO.listarParcelas(idVendaaPrazo);

                return(View(listaParcelas));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Example #5
0
        public ActionResult realizarVendaaPrazo()
        {
            if (Session["idVendedor"] != null)
            {
                VendasDAO      objVDAO  = new VendasDAO();
                VendaaPrazoDAO objVpDAO = new VendaaPrazoDAO();
                PedidosDAO     objPe    = new PedidosDAO();
                ProdutosDAO    objPr    = new ProdutosDAO();
                ParcelasDAO    objPaD   = new ParcelasDAO();
                Parcelas       objPa    = new Parcelas();
                Vendas         objV     = new Vendas();
                ClientesDAO    objCl    = new ClientesDAO();


                List <Pedidos> objP = new List <Pedidos>();
                objP = objPe.MostrarPedidos();
                for (int i = 0; i < objP.Count; i++)
                {
                    string idProduto;
                    int    qtdProduto;
                    idProduto  = objP[i].idProduto;
                    qtdProduto = objP[i].qtdProduto;
                    objPr.atualizaEstoque(qtdProduto, idProduto);
                }



                //pegando do form o idCliente
                string idCliente = Request.Form["idCliente"];
                objV.idCliente = Int32.Parse(idCliente);

                //pegando o nome do cliente
                TempData["nomeCliente"] = objCl.selecionanomeCliente(Int32.Parse(idCliente));


                int parcelas = Convert.ToInt32(Request.Form["parcelas"]);


                //realiza a venda (a prazo) retorna o idVenda
                string retorno = objVDAO.vendaAprazo(objV);

                //realiza a vendaaprazo e retorna o idVendaaprazo
                int idVendaaprazo = Int32.Parse(objVpDAO.vendaaprazo(retorno, parcelas));


                //método que atualiza o pedido com o idVenda e o status do pedido
                objPe.atualizaStatus(retorno);

                DateTime today = DateTime.Now;


                //pegar o valorTotal da venda
                decimal total        = objVDAO.pegartotalVenda(retorno);
                decimal valorParcela = total / parcelas;
                TempData["parcelas"]     = parcelas;
                TempData["valorParcela"] = valorParcela;

                //método que faz as parcelas da venda a prazo
                for (int i = 0; i < parcelas; i++)
                {
                    DateTime dtvenc        = today.AddDays((30 * (i + 1)));
                    string   dtvencParcela = dtvenc.ToString("dd/MM/yyyy");

                    objPa.valorParcela  = valorParcela;
                    objPa.idVendaaPrazo = idVendaaprazo;
                    objPa.numParcela    = i + 1;
                    objPa.statusParcela = 0;
                    objPa.dtvencParcela = dtvencParcela;
                    objPaD.criarParcela(objPa);
                }


                ViewBag.retorno = retorno;

                return(RedirectToAction("sucessoap/" + retorno + ""));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }