-1
I need to take the ID of an already logged in user to create another product. How do I do this ?
So, soon, and with the email and password logged in, I want to find the ID logged in for when I register the car, it pull this ID and register. I’ve tried using Thread.CurrentPrincipal.Identity.Isauthenticated, Environment.Username and the Windowsidentity.Getcurrent() but these only take the name of the person logged in windows, not in the application.
Login
Empresa empresa = new Empresa();
empresa.Email = txtEmail.Text;
empresa.Senha = txtSenha.Text;
if(EmpresaDAO.BuscarEmpresaPorEmailESenha(empresa) != null)
{
empresa = EmpresaDAO.BuscarEmpresaPorEmailESenha(empresa);
this.Close();
MenuEmpresa menuEmpresa = new MenuEmpresa();
menuEmpresa.ShowDialog();
}
Register of the Car
try
{
if (WindowsIdentity.GetCurrent().IsAuthenticated)
{
empresa.Email = WindowsIdentity.GetCurrent().Name;
}
carro.Empresa = EmpresaDAO.BuscarEmpresaPorEmail(empresa);
carro.Nome = txtNome.Text;
carro.Cambio = txtCambio.Text;
carro.Cor = txtCor.Text;
carro.Marca = txtMarca.Text;
carro.Quilometragem = txtQuilometragem.Text;
carro.Placa = txtPlaca.Text;
carro.Portas = int.Parse(txtPorta.Text);
carro.Ano = int.Parse(txtPorta.Text);
carro.Preco = txtPreco.Text;
CarroDAO.Incluir(carro);
MessageBox.Show("O cadastro do carro: " + carro.Nome + " foi concluido com sucesso", "Cadastrado");
}
I tried to do as much as possible to Asp.NET, because I didn’t understand how I’m going to do this in C#.
ASP.NET
Usuario usu = new Usuario();
ItemVenda itemv = new ItemVenda();
if (Request.IsAuthenticated)
{
usu.Login = HttpContext.User.Identity.Name;
}
venda.Usuario = UsuarioDAO.BuscarUsuarioPorLogin(usu);
Present the context of your problem, this should include the source code that is having problems and exactly what you tried to do
– Samuel Fontebasso
I put the code I’m trying to make.
– Osvaldo Junior
@Osvaldojunior is programming for web or desktop?
– gato
@Desktop cat, but I already managed to fix.
– Osvaldo Junior