internal static Investidor logarUsuario(Investidor investidor) { Investidor usu = new Investidor(); MySqlConnection msc = new MySqlConnection("Server=cusko.db.8505846.hostedresource.com;Database=cusko;Uid=cusko;Pwd=Teste1234;"); string sql = "select * from Investidor iv where iv.login = '******' and iv.senha = '" + investidor.StrKeyPass + "'"; MySqlCommand msCommand = new MySqlCommand(sql, msc); try { msc.Open(); MySqlDataReader mdr = msCommand.ExecuteReader(); if (mdr.HasRows) while (mdr.Read()) { usu.ICodigo = int.Parse(mdr["idInvestidor"].ToString()); usu.StrNome = mdr["nome"].ToString(); usu.StrLogin = mdr["login"].ToString(); usu.StrKeyPass = mdr["senha"].ToString(); usu.LstCarteiras = CarteiraDAO.listarCarteirasUsuario(usu); } } catch (Exception ex) { throw ex; } finally { msc.Close(); MySqlConnection.ClearAllPools(); } return usu; }
public void Inserir(Investidor I) { DataBaseContext DBContext = new DataBaseContext(); DBContext.Investidor.Add(I); DBContext.SaveChanges(); }
protected void Button1_Click(object sender, DirectEventArgs e) { Investidor usu = new Investidor(); string strLoginApelido; string strPassword; strLoginApelido = this.txtUsuario.Text; strPassword = this.txtPassword.Text; Core.App.InvestidorAPL.asdasdasd(); try { usu.StrLogin = txtUsuario.Text; usu.StrKeyPass = strPassword; if (logarUsuario(ref usu)) { Session.Add("usuario", usu); Page.Response.Redirect("Desktop.aspx"); } else throw new Exception("Verifique o Login e Senha"); } catch (Exception ex) { X.Msg.Alert("Erro", ex.Message).Show(); return; } }
public void Editar(Investidor I) { DataBaseContext DBContext = new DataBaseContext(); DBContext.Entry(I).State = System.Data.Entity.EntityState.Modified; DBContext.SaveChanges(); }
static void Main(string[] args) { AcaoApple acaoApple = new AcaoApple(); AcaoMicrosoft acaoMicrosoft = new AcaoMicrosoft(); Investidor investidor = new Investidor(); Investidor investidor1 = new Investidor(); Investidor investidor2 = new Investidor(); Investidor investidor3 = new Investidor(); Investidor investidor4 = new Investidor(); acaoApple.AdicionarInscricao(investidor); acaoApple.AdicionarInscricao(investidor1); acaoApple.AdicionarInscricao(investidor2); acaoApple.AdicionarInscricao(investidor3); acaoApple.AdicionarInscricao(investidor4); acaoMicrosoft.AdicionarInscricao(investidor2); acaoApple.Valor = 4; acaoApple.RemoverInsricao(investidor4); acaoApple.Valor = 5; acaoMicrosoft.Valor = 12; Console.ReadKey(); }
public async Task Incluir(Investidor investidor, IDbTransaction transacao) { investidor.DataHoraInclusao = DateTime.Now; await PreSave(investidor); investidor.Id = await Conexao.Ativa.ExecuteScalarAsync <Int64>(cSql_Insert, investidor, transacao); }
public ActionResult ConfirmaDados(Investidor model) { model.pessoa = Repositorio.ListarPessoa(UserId); model.pacote = Repositorio.ListarPacote(model.pacote.IDPacote); var investidores = Repositorio.Listarinvestidores(); int qtdPct = 0; foreach (var inv in investidores.Where(iv => iv.pacote.IDPacote == model.pacote.IDPacote)) { qtdPct += inv.Quantidade; } if ((model.pacote.QtdTotal - qtdPct) - model.Quantidade >= 0) { bool enviamensagem = Repositorio.InseriInvestidor(model); if (enviamensagem) { ViewBag.Mensagem = "Obrigado!"; } else { ViewBag.Mensagem = "Ops! Algo deu errado, tente novamente mais tarde."; } } else { ViewBag.Mensagem = "Ops! Número de pacotes não disponível."; } return(RedirectToAction("AreaRestrita", new { id = model.pacote.IDPacote })); }
public void Excluir(int Id) { DataBaseContext DBContext = new DataBaseContext(); Investidor Investidor = ConsultarPorId(Id); DBContext.Entry(Investidor).State = System.Data.Entity.EntityState.Deleted; DBContext.SaveChanges(); }
public void Inserir(Investidor Invest) { using (DataBaseContext DbContext = new DataBaseContext()) { DbContext.Investidor.Add(Invest); DbContext.SaveChanges(); } }
public void Editar(Investidor Invest) { using (DataBaseContext DbContext = new DataBaseContext()) { DbContext.Entry(Invest).State = System.Data.Entity.EntityState.Modified; DbContext.SaveChanges(); } }
public void Deletar(int id) { using (DataBaseContext DbContext = new DataBaseContext()) { Investidor Investidor = Buscar(id); DbContext.Entry(Investidor).State = System.Data.Entity.EntityState.Deleted; DbContext.SaveChanges(); } }
public async Task Preencher(Investidor investidor) { if (investidor != null) { var carteiras = await _carteiraRepository.ObterPor(investidor.Id); investidor.Carteiras.Add(carteiras); } }
protected Carteira persisteCarteira(string txt, Investidor usu) { Carteira cart = new Carteira(); cart.StrNome = txt; cart.Usuario = usu; cart.ICodigo = CarteiraAPL.inserirCarteira(cart); return cart; }
public Investidor BuscarPorNome(String Nome) { Investidor Investidor = new Investidor(); using (DataBaseContext DbContext = new DataBaseContext()) { Investidor = DbContext.Investidor.Where(v => v.NomeInvestidor == Nome).SingleOrDefault <Investidor>(); } return(Investidor); }
public override bool isValid() { if (!Investidor.InvesteEm(Fundo)) { if (ValorInvestido < Fundo.MinimoExigido) { throw new DomainServiceException(Resources.Dicionario.VALOR_INVESTIDO_SERA_MAIOR_MINIMO_EXIGIDO); } } return(true); }
public ActionResult PesquisaInvestidor(Investidor InvestidorDigitado) { ViewBag.ListaInvestidorPesquisados = new InvestidorDAO() .ConsultarDinamico( InvestidorDigitado.Nome, InvestidorDigitado.Email, InvestidorDigitado.NomeEmpresa, InvestidorDigitado.CNPJ, InvestidorDigitado.Telefone, InvestidorDigitado.Cidade.Nome); return(View()); }
public ActionResult CadastrarInvestidor(Investidor investidor) { try { new InvestidorDAO().Inserir(investidor); } catch (Exception e) { return(Content("<script language='javascript' type='text/javascript'>alert('Erro ao Inserir Investidor!'); location.href='/Home/Index';</script>")); } return(Content("<script language='javascript' type='text/javascript'>alert('Cadastro Efetuado com Sucesso!'); location.href='/Home/Index';</script>")); }
public override bool isValid() { if (!Investidor.InvesteEm(Fundo)) { throw new DomainServiceException(Resources.Dicionario.IMPOSSIVEL_RESGATE_INVESTIDOR_NAO_INVESTE_NO_FUNDO); } else { if (Investidor.ValorTotalDisponivel(Fundo) < (ValorInvestido * -1)) { throw new DomainServiceException(Resources.Dicionario.IMPOSSIVEL_RESGATE_MAIOR_QUE_DISPONIVEL); } } return(true); }
public Investidor ConsultarPorNome(String Nome) { Investidor Investidor = new Investidor(); try { DataBaseContext DBContext = new DataBaseContext(); Investidor = DBContext.Investidor.Where(p => p.Nome == Nome).SingleOrDefault <Investidor>(); } catch (Exception ex) { Investidor = new Investidor(); } return(Investidor); }
public async Task Incluir(Investidor investidor) { var transacao = Conexao.Ativa.BeginTransaction(); try { var investidorRepository = new InvestidorRepository(); await investidorRepository.Incluir(investidor, transacao); Cache.Ativo.Incluir(investidor); transacao.Commit(); } catch (Exception) { transacao.Rollback(); throw; } }
internal static void inserirNegociacaoInvestidor(HistMovimentacao histMov, Investidor usu) { string sql = @"INSERT INTO `cusko`.`MovimentacaoInvestidor`(`Investidor_idInvestidor`,`Acao_idAcao`,`data`,`quantidade`,`valor`) VALUES (" + usu.ICodigo + "," + histMov.Acao.ICodigo + "," + histMov.DtNegociada + "," + histMov.Acao.INegociacoes + "," + histMov.FValorNegociado + ")"; MySqlConnection msc = new MySqlConnection("Server=cusko.db.8505846.hostedresource.com;Database=cusko;Uid=cusko;Pwd=Teste1234;"); MySqlCommand msCommand = new MySqlCommand(sql, msc); try { msc.Open(); msCommand.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } finally { msc.Close(); MySqlConnection.ClearAllPools(); } }
public ActionResult ConfirmaDados(int id) { Investidor invest = new Investidor(); invest.pacote = Repositorio.ListarPacote(id); invest.pessoa = Repositorio.ListarPessoa(UserId); var investidores = Repositorio.Listarinvestidores(); int qtdPct = 0; foreach (var inv in investidores.Where(iv => iv.pacote.IDPacote == invest.pacote.IDPacote)) { qtdPct += inv.Quantidade; } invest.pacote.QtdDisponivel = invest.pacote.QtdTotal - qtdPct; return(View(invest)); }
public ActionResult AreaRestrita(int?id) { if (id != null) { Investidor invest = new Investidor(); invest.pacote = Repositorio.ListarPacote((int)id); invest.pessoa = Repositorio.ListarPessoa(UserId); var investidor = Repositorio.FiltrarPacote(UserId); if (investidor == null || ((List <Investidor>)investidor).Count == 0) { ViewBag.Mensagem = "Nenhum cliente cadastrado"; } return(View(investidor)); } else { ViewBag.Mensagem = "Nenhum Investimento lançado"; return(View()); } }
public ActionResult Editar(Investidor Invest) { bool status = true; if (ModelState.IsValid) { InvestidorDAO InvestDAO = new InvestidorDAO(); //Pesquisar como funciona esse if Investidor InvestExiste = InvestDAO.BuscarPorNome(Invest.NomeInvestidor); if ((InvestExiste == null) || !String.Equals(InvestExiste.NomeInvestidor, Invest.NomeInvestidor)) { InvestDAO.Editar(Invest); TempData["mensagem"] = "Investidor Editado com Sucesso!"; //fazer o temp data para a Mensagem } else { ModelState.AddModelError("", "Investidor já existe"); status = false; } } else { status = false; } //Terminar as validações e redirecionamento //Fazendo o redirecionamento if (status) { return(RedirectToAction("Index")); } else { return(View()); } }
protected void reloadCarteiras(Investidor usu) { Ext.Net.TreeNode treeCarteiras = new Ext.Net.TreeNode("Carteiras"); treeCarteiras.Expandable = Ext.Net.ThreeStateBool.True; treeMenu.Root.Add(treeCarteiras); foreach (Carteira item in usu.LstCarteiras) { Ext.Net.TreeNode piece = new Ext.Net.TreeNode(item.StrNome, Icon.Money); piece.Listeners.Click.Handler = "addTab(#{DoodTp}, '" + item.StrNome + "' , 'CarteirasPnl.aspx?id=" + item.StrNome + "');"; treeCarteiras.Nodes.Add(piece); } Ext.Net.TreeNode add = new Ext.Net.TreeNode("Adicionar", Icon.Add); add.Listeners.Click.Handler = "Ext.net.DirectMethods.newCarteira();"; //Ext.Net.TreeNode lol = new Ext.Net.TreeNode(text, Icon.Money); //lol.Listeners.Click.Handler = "addTab(#{DoodTp}, '" + text + "' , 'CarteirasPnl.aspx?id=" + text + "');"; //treeCarteiras.Nodes.Add(lol); treeCarteiras.Nodes.Add(add); }
private bool logarUsuario(ref Investidor usu) { if (fillInvestidor(ref usu) != null) return true; return false; }
public static Investidor logarUsuario(Investidor investidor) { return InvestidorDAO.logarUsuario(investidor); }
private Investidor fillInvestidor(ref Investidor usu) { usu = InvestidorAPL.logarUsuario(usu); return usu; }
public async Task <IEnumerable <Carteira> > ObterCarteiras(Investidor investidor) { var carteiraRepository = new CarteiraRepository(); return(await carteiraRepository.ObterPor(investidor.Id)); }
internal static List<Carteira> listarCarteirasUsuario(Investidor investidor) { string sql = "select * from Carteira where Investidor_idInvestidor = " + investidor.ICodigo; MySqlConnection msc = new MySqlConnection("Server=cusko.db.8505846.hostedresource.com;Database=cusko;Uid=cusko;Pwd=Teste1234;"); MySqlCommand msCommand = new MySqlCommand(sql, msc); List<Carteira> LstCarteira = new List<Carteira>(); try { msc.Open(); MySqlDataReader mdr = msCommand.ExecuteReader(); if (mdr.HasRows) { Carteira cart = new Carteira(); while (mdr.Read()) { cart = new Carteira(); cart.ICodigo = int.Parse(mdr["idCarteira"].ToString()); cart.StrNome = mdr["nome"].ToString(); cart.Usuario = investidor; cart.LstAcoes = AcaoDAO.listarAcoesCarteira(cart); LstCarteira.Add(cart); } } } catch (Exception ex) { throw ex; } finally { msc.Close(); } return LstCarteira; }
public ActionResult Editar(Investidor i) { Repositorio.Instance().AlterarInvestidor(i); return(RedirectToAction("Listar")); }
public ActionResult Cadastrar(Investidor i) { Repositorio.Instance().IncluirInvestidor(i); return(RedirectToAction("Listar")); }
private void forDebugPurposes() { Investidor usu = new Investidor(); usu.StrEmail = "*****@*****.**"; usu.StrKeyPass = "******"; usu.StrLogin = "******"; for (int i = 0; i < 5; i++) { Carteira asd = new Carteira(); asd.StrNome = "Carteira_" + i; usu.LstCarteiras.Add(asd); } Session.Add("usuario", usu); }
public void InvestirMaiorQueMinimoInicialEMenorQueMinimoInicial() { Investidor.Investir(CopacabanaTrial, 2000.00M); Investidor.Investir(CopacabanaTrial, 500.00M); Assert.AreEqual(Investidor.Movimentacoes.Count(), 2); }
public async Task Alterar(Investidor investidor, IDbTransaction transacao) { await PreSave(investidor); await Conexao.Ativa.ExecuteAsync(cSql_Update, investidor, transacao); }
public async Task Excluir(Investidor investidor, IDbTransaction transacao) { await Conexao.Ativa.ExecuteAsync(cSql_Delete, investidor, transacao); }
private async Task PreSave(Investidor investidor) { await Task.Run(() => investidor.UltimaAlteracao = DateTime.Now); }