public bool Validausuario(Logar Login) { if (!Con.Checkconection()) { Con.Conectar(); } if (Con.Checkconection()) { DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand("SELECT * FROM USUARIO WHERE USUARIO = @usuario AND SENHA = @senha", Con.Traz_Conexao()); command.Parameters.Add("@usuario", MySqlDbType.VarChar).Value = Login.GetUsuario(); command.Parameters.Add("@senha", MySqlDbType.VarChar).Value = Login.GetSenha(); adapter.SelectCommand = command; adapter.Fill(table); //Verifica se há uma lina no banco com esse Usuário. if (table.Rows.Count > 0) { User_Exists = true; } Con.Desconectar(); } return(User_Exists); }
//Proje oluşturma public JsonResult ProjeEkle(tblProje proje) { proje.aktifMi = true; char x = TarihKontrol(Convert.ToDateTime(proje.baslangicTarihi), Convert.ToDateTime(proje.olusturmaTarihi), Convert.ToDateTime(proje.bitisTarihi)); if (x != '-') { return(Json(x)); } int s = ProjeIslem.ProjeEkle(proje); if (s == 0) { KullaniciProjeRol kpr = new KullaniciProjeRol { projeId = proje.projeId, kullaniciId = int.Parse(Session["kulId"].ToString()), rolId = 1 }; KullaniciProjeEkle(kpr); Logar lg = new Logar((int)proje.olusturanKullaniciId, " Tarihte Proje Ekledi"); return(Json("+")); } else { return(Json("-")); } }
//süreç ekleme public JsonResult SurecEkle(tblSurec veri) { veri.projeId = projeDetayId; char x = TarihKontrol(Convert.ToDateTime(veri.baslangicTarihi), Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(veri.bitisTarihi)); if (x != '-') { return(Json(x)); } int kullaniciId = 0; if (Session["kulId"] != null) { kullaniciId = int.Parse(Session["kulId"].ToString()); } else { return(Json('?')); // kullanıcı giriş yapmamış } veri.bitirmeOrani = 0; var sonuc = ProjeIslem.SurecEkle(veri, kullaniciId); if (sonuc == 0) { Logar lg = new Logar(kullaniciId, " Tarihte Süreç Ekledi"); return(Json(sonuc)); } else { return(Json("-")); } }
private void BtnEntrar_Click(object sender, EventArgs e) { Operfil = new PerfilImportacao() { Usuario = txtUsr.Text, Token = txtPwd.Text }; if (txtUsr.Text.Length < 6) { MessageBox.Show("O usuário deve conter no minimo 6 caracteres", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (txtPwd.Text.Length < 6) { MessageBox.Show("A senha deve conter no minimo 6 caracteres", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (Logar.LogarVipp(txtUsr.Text, txtPwd.Text)) { Hide(); IniFile oIniFile = new IniFile("Config"); oIniFile.IniWriteString("Usuario", txtUsr.Text); oIniFile.IniWriteString("Senha", txtPwd.Text); Properties.Settings.Default.LembrarSenha = checkLembrar.Checked; Properties.Settings.Default.Save(); new Form1().ShowDialog(); //Application.Exit(); } }
private void BtnEntrar_Click(object sender, EventArgs e) { Operfil = new PerfilImportacao() { Usuario = txtUsr.Text, Token = txtPwd.Text, IdPerfil = "5882" }; if (txtUsr.Text.Length < 6) { MessageBox.Show("O usuário deve conter no minimo 6 caracteres", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (txtPwd.Text.Length < 6) { MessageBox.Show("A senha deve conter no minimo 6 caracteres", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (Logar.LogarVipp(txtUsr.Text, txtPwd.Text)) { Hide(); new Form1().ShowDialog(); Application.Exit(); } }
//Şifre Değiştirme public JsonResult SifreGuncelle(string eski, string yeni) { int kId = int.Parse(Session["kulId"].ToString()); Logar lg = new Logar(kId, " Tarihte Şifre Güncelledi"); var sonuc = KullaniciIslem.SifreGuncelle(eski, yeni, kId); return(Json(sonuc)); }
private void gravarButton_Click(object sender, EventArgs e) { if (!Formulario.ValidarCamposObrigatorios(this, clientesErrorProvider) || !Formulario.ValidarTipoDosDados(this, clientesErrorProvider)) { return; } //wmp.URL = var cliente = new Cliente(); //var pessoa = new Pessoa(); cliente.Nome = nomeTextBox.Text; cliente.Endereco = enderecoTextBox.Text; cliente.DataNascimento = Convert.ToDateTime(nascimentoMaskedTextBox.Text); //cliente.Documentos = cpfMaskedTextBox.Text; var cpf = new Documento(); cpf.Numero = cpfMaskedTextBox.Text; cpf.TipoDocumento = TipoDocumento.Cpf; //cliente.Documentos = new List<Documento>(); cliente.Documentos.Add(cpf); cliente.Email = emailTextBox.Text; cliente.Renda = Convert.ToDecimal(rendaTextBox.Text); try { cliente.Validar(); new ClienteRepositorio().Gravar(cliente); MessageBox.Show("Cliente cadastrado com sucesso!"); Formulario.Limpar(this); } catch (DirectoryNotFoundException) { MessageBox.Show(string.Format("O caminho {0} não foi encontrado. Sua gravação não foi realizada.", _caminho)); } catch (UnauthorizedAccessException) { MessageBox.Show(string.Format("Desmarque a opção de Read-Only do arquivo {0}. Sua gravação não foi realizada.", _caminho)); } catch (RegraNegocioException ex) { MessageBox.Show(ex.Message); } catch (Exception ex) { MessageBox.Show("Ooops! Houve um erro no aplicativo e a gravação não foi realizada." + "A equipe de suporte já foi comunicada e em breve teremos uma solução"); Logar.PorEmail(ex); } }
//Çıkış public ActionResult Cikis() { int id = int.Parse(Session["kulId"].ToString()); Logar lg = new Logar(id, " Tarihte Çıkış Yaptı"); //session çıkış Session.Remove("kulMail"); Session.Remove("kulId"); Session.Remove("kulAd"); return(View("Index")); }
//Profil Güncelleme public JsonResult ProfilGuncelle(tblKullanici kul) { int kId = int.Parse(Session["kulId"].ToString()); Logar lg = new Logar(kId, " Tarihte Profil Güncelledi"); var sonuc = KullaniciIslem.ProfilGuncelle(kul, kId); if (sonuc == '+') { return(Json("+")); } else { return(Json("-")); } }
private void button1_Click(object sender, EventArgs e) { lblErroSenha.Visible = false; lblErroUsuario.Visible = false; lblErroLogin.Visible = false; DALConexao dal = new DALConexao(); BLLUSuario user = new BLLUSuario(dal); SqlDataReader Logar; user.usuario = txtCpf.Text; user.senha = txtSenha.Text; if (txtCpf.Text != "CPF") { if (txtSenha.Text != "SENHA") { Logar = user.IniciaSessao(); if (Logar.Read() == true) { this.Hide(); frmPrincipal frm = new frmPrincipal(); frm.Show(); } else { lblErroLogin.Text = "Usuário/Senha inválido!"; lblErroLogin.Visible = true; txtSenha.Text = ""; txtSenha_Leave(null, e); txtCpf.Focus(); } } else { lblErroSenha.Text = "Favor preencher o Usuário"; lblErroSenha.Visible = true; } } else { lblErroUsuario.Text = "Favor preencher a Senha"; lblErroUsuario.Visible = true; } }
private void codigoTextBox_KeyDown(object sender, KeyEventArgs e) { if ((e.Key >= Key.D0 && e.Key <= Key.D9 || e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9) || e.Key == Key.Back || e.Key == Key.Enter || e.Key == Key.Tab) { if (e.Key == Key.Enter && codigoTextBox.Text.Trim() != string.Empty) { try { Mercadoria mercadoria = new Mercadoria(); mercadoria.Pesquisar(Convert.ToInt32(codigoTextBox.Text)); produtoTextBox.Text = mercadoria.Nome; precoTextBox.Text = mercadoria.Preco.ToString("C2"); estoqueTextBox.Text = mercadoria.QtdEstoque.ToString(); familiaTextBox.Text = mercadoria.Familia.Nome; codigoTextBox.SelectAll(); } // É possível capturar (catch) múltiplas exceções, sempre da mais específica para a mais genérica catch (FileNotFoundException) { MessageBox.Show("O arquivo Produtos.txt não foi localizado."); Close(); } catch (RegistroNaoEncontradoException ex) { MessageBox.Show(ex.Message); JanelaWpf.Limpar(controlesGrid); } catch (Exception ex) { MessageBox.Show("Oops! Algo não deu certo. Um email acaba de ser enviado para a equipe de suporte!"); Logar.PorEmail(ex); JanelaWpf.Limpar(controlesGrid); } } } else { e.Handled = true; } }
private void codigoTextBox_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar >= 48 && e.KeyChar <= 57 || e.KeyChar == 8 || e.KeyChar == 13) { if (e.KeyChar == 13 && codigoTextBox.Text.Trim() != string.Empty) { try { Mercadoria mercadoria = new Mercadoria(); mercadoria.Pesquisar(Convert.ToInt32(codigoTextBox.Text)); produtoTextBox.Text = mercadoria.Nome; precoTextBox.Text = mercadoria.Preco.ToString("C2"); estoqueTextBox.Text = mercadoria.QtdEstoque.ToString(); familiaTextBox.Text = mercadoria.Familia.Nome; codigoTextBox.SelectAll(); } // É possível capturar (catch) múltiplas exceções, sempre da mais específica para a mais genérica catch (FileNotFoundException) { MessageBox.Show("O arquivo Produtos.txt não foi localizado."); Close(); } catch (RegistroNaoEncontradoException ex) { MessageBox.Show(ex.Message); Formulario.Limpar(this); } catch (Exception ex) { MessageBox.Show("Oops! Algo não deu certo. Um email acaba de ser enviado para a equipe de suporte!"); Logar.PorEmail(ex); Formulario.Limpar(this); } } } else { e.KeyChar = '\0'; } }
public ActionResult CadastroLogar([Bind(Include = "Id,Login,Senha")] Logar usuario) { if (ModelState.IsValid) { ConexaoSql bd = new ConexaoSql(); MySqlConnection conexao = bd.conexaobd(); Criptografia crip = new Criptografia(); MySqlCommand comando = new MySqlCommand(" INSERT INTO usuario( Login, Senha) values ( @Login, @Senha)", conexao); comando.Parameters.AddWithValue("@Login", usuario.Login); comando.Parameters.AddWithValue("@Senha", crip.GerarMD5(usuario.Senha)); conexao.Open(); MySqlDataReader leitor = comando.ExecuteReader(); if (leitor.HasRows) //siginifica que login e senha digitados iguais aos do BD { { leitor.Close(); return(RedirectToAction("Home", "Home")); } } return(View(usuario)); }
//public JsonResult SureceKisiEkle(int kisiId, int ) //altsüreç ekleme public JsonResult AltSurecEkle(tblAltSurec alt) { char x = TarihKontrol(Convert.ToDateTime(alt.baslangicTarihi), Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(alt.bitisTarihi)); if (x != '-') { return(Json(x)); } alt.bitirmeOrani = 0; var s = ProjeIslem.AltSurecEkle(alt); if (s == 0) { int id = int.Parse(Session["kulId"].ToString()); Logar lg = new Logar(id, " Tarihte Alt Süreç Ekledi"); return(Json("+")); } else { return(Json("-")); } }
public ActionResult Logar([Bind(Include = "Id,Login,Senha")] Logar usuario) { if (ModelState.IsValid) { ConexaoSql bd = new ConexaoSql(); MySqlConnection conexao = bd.conexaobd(); Criptografia crip = new Criptografia(); MySqlCommand comando = new MySqlCommand("SELECT * from usuario where Login = @Login and Senha = @Senha", conexao); comando.Parameters.AddWithValue("@Login", usuario.Login); comando.Parameters.AddWithValue("@Senha", crip.GerarMD5(usuario.Senha)); conexao.Open(); MySqlDataReader leitor = comando.ExecuteReader(); if (leitor.HasRows) //siginifica que login e senha digitados iguais aos do BD { { FormsAuthentication.SetAuthCookie(usuario.Login, false); leitor.Close(); return(RedirectToAction("Home", "Home")); } } return(View(usuario)); }
public IActionResult Login(Login logando) { foreach (Login L in Logar.Login()) { if (L.login == logando.login) { if (L.senha == logando.senha) { HttpContext.Session.SetString("Nome", L.nome); if ((L.nome == Global.NomeDB) && (Global.TipoGlobal == 1)) { HttpContext.Session.SetInt32("Tipo", L.tipo); } else if ((L.nome == Global.NomeDB) && (Global.TipoGlobal == 2)) { HttpContext.Session.SetInt32("Tipo", L.tipo); } else { HttpContext.Session.SetInt32("Tipo", L.tipo); } HttpContext.Session.SetString("logado", "yes"); return(RedirectToAction("Index")); } else { continue; } } else { continue; } } ViewBag.Erro = 2; return(View("Erro")); }
public IActionResult Login(Logar dados) { string mensagem = ""; string caminho = ""; var Banco = Db.Usuarios.ToList(); foreach (var item in Banco) { if (dados.Email == item.Email && dados.Senha == item.Senha) { mensagem = item.Nome_social; caminho = "Login"; break; } else { mensagem = "usuario não encontrado ou email/senha estão incorretos"; caminho = "Index"; } } ViewBag.MSG = mensagem; ViewBag.Banco = Banco; return(View(caminho)); }
//Giriş public JsonResult GirisYapKullanici(string kulMail, string kulSifre) { if (kulMail == "" || kulSifre == "") { return(Json("-")); } char c = KullaniciIslem.KullaniciGiris(kulMail, kulSifre); if (c == '+') { var sessionKulId = KullaniciIslem.KullaniciVer(kulMail); Session.Add("kulId", sessionKulId.kullaniciId); Session.Add("kulAd", sessionKulId.kullaniciAdi); Session.Add("kulMail", sessionKulId.email); //kullanıcı sisteme giriş yaptııııı int id = int.Parse(Session["kulId"].ToString()); Logar lg = new Logar(id, " Tarihte Giriş Yaptı"); } return(Json(c)); }
public void LogarPorEmailTest() { Exception ex = new Exception("Teste"); Logar.PorEmail(ex); }
private static void ExibirMensagemDeErro(Exception ex) { MessageBox.Show("Houve um erro e a gravação não foi realzada! O suporte já foi comunicado."); Logar.PorEmail(ex); }