protected void Page_Load(object sender, EventArgs e) { Usuario u = new Usuario(); GeoCodificacao g = new GeoCodificacao(); u = g.ObterCoordenadas(u, Request.QueryString["cep"], Request.QueryString["num"]); string rEndereco = g.ObterEndereco(u); if (rEndereco != null) { Session["latlog"] = u; Response.Write(rEndereco); } else { Response.Write("Desculpe, não localizamos o seu endereço..."); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["sistema"] == null) { Response.Redirect("~/Views/SistemaLogin.aspx"); } int idPedido = 0; idPedido = int.Parse(Request.QueryString["idPedido"]); Pedido pedido = new Pedido(); pedido.Vendedor = new Usuario(); pedido.Id = idPedido; pedido.Comprador = (Usuario)Session["sistema"]; PedidoRepositorio carregaPedido = new PedidoRepositorio(); pedido = carregaPedido.CarregarPedidoComprador(pedido); lbNumPedido.Text = "Pedido" + pedido.Codigo; lbVendedor.Text = pedido.Vendedor.Nome; lbValorTotal.Text = Math.Round(pedido.Valor, 2).ToString(); lbStatus.Text = pedido.StatusPedido.Nome; lbTelefone.Text = pedido.Vendedor.Telefone; lbEmailVendedor.Text = pedido.Vendedor.Email; lbNumComplemento.Text = pedido.Vendedor.Numero + "/" + pedido.Vendedor.Complemento; GeoCodificacao g = new GeoCodificacao(); lbEndereco.Text = g.ObterEndereco(pedido.Vendedor); grdItens.DataSource = pedido.Item; grdItens.DataBind(); }
//ESTE METODO CARREGA AS INFORMAÇOES DO USUARIO PARA ALTERAÇÃO protected void Page_Load(object sender, EventArgs e) { int idtpousuario; int.TryParse(Request.QueryString["TipoUsuario"], out idtpousuario); if (idtpousuario.Equals(2)) { dvMetodo.Visible = true; } if (!IsPostBack) { Usuario u = (Usuario)Session["sistema"]; UsuarioRepositorio carregaUsuario = new UsuarioRepositorio(); if (Session["sistema"] != null && u.CpfCnpj.Length == 11) { dvMsg.Visible = false; dvPessoaJuridica.Visible = false; if (carregaUsuario.CarregarUsuario(u)) { txtCpf.Text = FormatarCnpjCpf.FormatCPF(u.CpfCnpj); txtNome.Text = u.Nome; txtSobrenome.Text = u.Sobrenome; txtEmail.Text = u.Email; txtTel.Text = u.Telefone; string caminho = string.Format("~/Imagens/{0}/Perfil/", u.Id); if (Directory.Exists(Server.MapPath(caminho))) { var diretorio = new DirectoryInfo(Server.MapPath(caminho)); var arquivos = diretorio.GetFiles(); string img = arquivos.Last().Name; userImage.ImageUrl = ResolveUrl(Path.Combine(caminho, img)); } GeoCodificacao g = new GeoCodificacao(); string endereco = g.ObterEndereco(u); lbEndereco_.Text = endereco; txtEndereco.Text = u.CEP; txtNumero.Text = u.Numero.ToString(); txtComplemento.Text = u.Complemento; dpArea.SelectedValue = Convert.ToString(u.AreaAtuacao); for (int i = 0; i < u.MetodoPagamento.Count; i++) { if (u.MetodoPagamento[i].tMetodoPgto.Id.Equals(2)) { cbMetodosPagamento.Items.Add(new ListItem("Cartão de Débito - " + u.MetodoPagamento[i].Nome, u.MetodoPagamento[i].Id.ToString())); cbMetodosPagamento.Items[i].Selected = u.MetodoPagamento[i].Desabilitado; } else if (u.MetodoPagamento[i].tMetodoPgto.Id.Equals(3)) { cbMetodosPagamento.Items.Add(new ListItem("Cartão de Crédito - " + u.MetodoPagamento[i].Nome, u.MetodoPagamento[i].Id.ToString())); cbMetodosPagamento.Items[i].Selected = u.MetodoPagamento[i].Desabilitado; } else { cbMetodosPagamento.Items.Add(new ListItem(u.MetodoPagamento[i].Nome, u.MetodoPagamento[i].Id.ToString())); cbMetodosPagamento.Items[i].Selected = u.MetodoPagamento[i].Desabilitado; } } } else { Response.Redirect("~/Views/Logout.aspx"); } } else if (Session["sistema"] != null && u.CpfCnpj.Length == 14) { dvMsg.Visible = false; dvPessoaFisica.Visible = false; if (carregaUsuario.CarregarUsuario(u)) { txtCnpj.Text = FormatarCnpjCpf.FormatCNPJ(u.CpfCnpj); txtRazaoSocial.Text = u.Nome; txtEmail.Text = u.Email; txtTel.Text = u.Telefone; string caminho = string.Format("~/Imagens/{0}/Perfil/", u.Id); if (Directory.Exists(Server.MapPath(caminho))) { var diretorio = new DirectoryInfo(Server.MapPath(caminho)); var arquivos = diretorio.GetFiles(); string img = arquivos.Last().Name; userImage.ImageUrl = ResolveUrl(Path.Combine(caminho, img)); } GeoCodificacao g = new GeoCodificacao(); string endereco = g.ObterEndereco(u); lbEndereco_.Text = endereco; txtEndereco.Text = u.CEP; txtNumero.Text = u.Numero.ToString(); txtComplemento.Text = u.Complemento; dpArea.SelectedValue = Convert.ToString(u.AreaAtuacao); for (int i = 0; i < u.MetodoPagamento.Count; i++) { if (u.MetodoPagamento[i].tMetodoPgto.Id.Equals(2)) { cbMetodosPagamento.Items.Add(new ListItem("Cartão de Débito - " + u.MetodoPagamento[i].Nome, u.MetodoPagamento[i].Id.ToString())); cbMetodosPagamento.Items[i].Selected = u.MetodoPagamento[i].Desabilitado; } else if (u.MetodoPagamento[i].tMetodoPgto.Id.Equals(3)) { cbMetodosPagamento.Items.Add(new ListItem("Cartão de Crédito - " + u.MetodoPagamento[i].Nome, u.MetodoPagamento[i].Id.ToString())); cbMetodosPagamento.Items[i].Selected = u.MetodoPagamento[i].Desabilitado; } else { cbMetodosPagamento.Items.Add(new ListItem(u.MetodoPagamento[i].Nome, u.MetodoPagamento[i].Id.ToString())); cbMetodosPagamento.Items[i].Selected = u.MetodoPagamento[i].Desabilitado; } } } else { Response.Redirect("~/Views/Logout.aspx"); } } else { Response.Redirect("~/Views/Logout.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { //RECEBE ID DO ITEM POR PARAMETRO E CARREGA NA TELA DADOS DO USUÁRIO Usuario user = null; UsuarioRepositorio carregaUsuario = new UsuarioRepositorio(); int idUsuario = 0; if (int.TryParse(Request.QueryString["idUsuario"], out idUsuario)) { user = carregaUsuario.DetalheUsuario(idUsuario); if (user != null) { if (user.CpfCnpj.Length == 11) { //USUÁRIO PESSOA FISICA lbNome.Text = user.Nome + ", " + user.Sobrenome; lbCpf.Text = FormatarCnpjCpf.FormatCPF(user.CpfCnpj); if (user.Genero == 1) { lbGenero.Text = "Masculino"; } else if (user.Genero == 2) { lbGenero.Text = "Feminino"; } else if (user.Genero == 3) { lbGenero.Text = "Outro"; } dvPessoaJuridica.Visible = false; } else if (user.CpfCnpj.Length == 14) { //USUARIO PESSOA JURIDICA lbRazao.Text = user.Nome; lbCnpj.Text = FormatarCnpjCpf.FormatCNPJ(user.CpfCnpj); dvPessoaFisica.Visible = false; } lbEmail.Text = user.Email; lbTelefone.Text = user.Telefone; lbTipoUsuario.Text = user.Tipousuario.Nome; if (user.Tipousuario.Nome == "Vendedor") { lbAreaAtuacao.Text = user.AreaAtuacao.ToString(); lbItensCadastrados.Text = user.QtdadeItens.ToString(); lbPedidosPendentes.Text = user.QtdPedidosPendente.ToString(); lbPedidosFinalizados.Text = user.QtdPedidosFinanlizado.ToString(); lbPedidosCancelados.Text = user.QtdPedidosCancelado.ToString(); } else { dvVendedor.Visible = false; } lbStatusUsuario.Text = user.StatusUsuario.Nome; lbDataCadastro.Text = user.DataCadastro.ToString(); //CARREGAR ENDEREÇO GeoCodificacao g = new GeoCodificacao(); lbEndereco.Text = g.ObterEndereco(user); lbComplemento.Text = user.Complemento; lbAreaAtuacao.Text = user.AreaAtuacao.ToString(); } } }
protected void btConfirmarPedido_Click(object sender, EventArgs e) { if (Session["sistema"] == null) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "$(function () { faltaLogin(); });", true); return; } List <Item> lstItem = (List <Item>)Session["carrinho"]; Usuario comprador = (Usuario)Session["sistema"]; List <Pedido> lstPedido = new List <Pedido>(); Pedido pedido = null; foreach (var item in lstItem.ToList()) { if (lstPedido.Exists(x => x.Vendedor.Id == item.Vendedor.Id)) { foreach (var pedidoLista in lstPedido) { if (pedidoLista.Vendedor.Id == item.Vendedor.Id) { pedidoLista.Item.Add(item); } } } else { pedido = new Pedido(); pedido.Vendedor = new Usuario(); pedido.Comprador = new Usuario(); pedido.Comprador = comprador; pedido.Vendedor.Id = item.Vendedor.Id; pedido.Vendedor.Email = item.Vendedor.Email; pedido.Item = new List <Item>(); pedido.Item.Add(item); lstItem.Remove(item); lstPedido.Add(pedido); } } PedidoRepositorio realizarPedido = new PedidoRepositorio(); MailMessage message = null; IsEmail enviarConfPedido = new IsEmail(); GeoCodificacao g = new GeoCodificacao(); StringBuilder strBody; foreach (var pedidoRealizar in lstPedido.ToList()) { strBody = new StringBuilder(); strBody.AppendLine("Olá Vendedor(a)!"); strBody.AppendLine("Tudo bom?"); strBody.AppendLine(""); strBody.AppendLine("O usuário " + comprador.Nome + ", acabou de confirar um pedido..."); strBody.AppendLine(""); strBody.AppendLine("DADOS DO CLIENTE"); strBody.AppendLine("E-mail: " + comprador.Email); strBody.AppendLine("Telefone: " + comprador.Telefone); strBody.AppendLine("Endereço: " + g.ObterEndereco(comprador)); strBody.AppendLine(""); strBody.AppendLine("Entre em contato com o seu cliente, para finalizar o pecesso de venda."); strBody.AppendLine(""); strBody.AppendLine("Unimarket Brasil"); strBody.AppendLine("http://unimarket.academico.trilema.com.br"); message = new MailMessage("*****@*****.**", pedidoRealizar.Vendedor.Email); message.Subject = "Unimarket Brasil - Confirmação de Pedido"; message.Body = strBody.ToString(); realizarPedido.RealizarPedido(pedidoRealizar); enviarConfPedido.Enviar(message); } Session["carrinho"] = null; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "$(function () { realizaPedido.show('CONFIRMAÇÃO DE PEDIDO'); });", true); }
protected void Page_Load(object sender, EventArgs e) { if (Session["sistema"] == null) { dvDuvida.Visible = false; } dvMsg.Visible = false; if (Session["latlog"] == null & Session["sistema"] == null) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "$(function () { chamaModal(); });", true); return; } if (!IsPostBack) { int idItem = 0; try { idItem = int.Parse(Request.QueryString["id"]); } catch { Response.Redirect("~/Views/SistemaErro.aspx"); } //Este metodoo apresenta os detalhes do item clicado pelo usuario comprador Item i = new Item(); ItemRepositorio carregarItem = new ItemRepositorio(); GeoCodificacao g = new GeoCodificacao(); i = carregarItem.DetalheItem(idItem); if (i != null) { lbIdItem.Text = i.Id.ToString(); lbNomeProduto.Text = i.Nome; lbValorUnitario.Text = i.ValorUnitario.ToString(); lbTotal.Text = i.ValorUnitario.ToString(); lbNomeVendedor.Text = i.Vendedor.Nome; lbTelefone.Text = i.Vendedor.Telefone; lbEmailVendedor.Text = i.Vendedor.Email; lbDescricao.Text = i.Descricao; Usuario u = new Usuario(); u.Latitude = i.Vendedor.Latitude; u.Longitude = i.Vendedor.Longitude; lbEndereco.Text = g.ObterEndereco(u); txtQuantidade.MaxLength = Convert.ToInt32(i.Quantidade); string caminho = string.Format("~/Imagens/{0}/{1}/", i.Vendedor.Id, i.Id); if (Directory.Exists(Server.MapPath(caminho))) { var diretorio = new DirectoryInfo(Server.MapPath(caminho)); var arquivos = diretorio.GetFiles(); string img = arquivos.Last().Name; imProduto.ImageUrl = ResolveUrl(Path.Combine(caminho, img)); } //MÉTODOS DE PAGAMENTO DO VENDEDOR MetodoPagamentoRepositorio carregaMetodos = new MetodoPagamentoRepositorio(); List <MetodoPagamento> mPagamentoList = new List <MetodoPagamento>(); mPagamentoList = carregaMetodos.ListarMetodoPagamento(i.Vendedor.Id); foreach (var item in mPagamentoList) { if (item.tMetodoPgto.Id.Equals(2)) { if (String.IsNullOrEmpty(lbCartaoDebito.Text)) { lbCartaoDebito.Text = item.Nome; } else { lbCartaoDebito.Text += " - " + item.Nome; } } else if (item.tMetodoPgto.Id.Equals(3)) { if (String.IsNullOrEmpty(lbCartaoCredito.Text)) { lbCartaoCredito.Text = item.Nome; } else { lbCartaoCredito.Text += " - " + item.Nome; } } } if (String.IsNullOrEmpty(lbCartaoDebito.Text)) { lbCartaoDebito.Text = "Não aceita."; } if (String.IsNullOrEmpty(lbCartaoCredito.Text)) { lbCartaoCredito.Text = "Não aceita."; } } else { Response.Redirect("~/Views/Sistema.aspx"); } } }