Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

Untitled
Wednesday, May 16th, 2012 at 10:02:23am MDT 

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Data.SqlClient;
  10.  
  11.  
  12. namespace WindowsFormsApplication1
  13. {
  14.     public partial class frmLogin : Form
  15.     {
  16.         public frmLogin()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.  
  21.         public static string usuarioConectado;
  22.         public static string nivelAcesso;
  23.  
  24.         private void frmLogin_Load(object sender, EventArgs e)
  25.         {
  26.  
  27.            
  28.         }
  29.  
  30.         private void btnSair_Click(object sender, EventArgs e)
  31.         {
  32.             Application.Exit();
  33.         }
  34.  
  35.         private void btnConectar_Click(object sender, EventArgs e)
  36.         {
  37.             /* ligação a base de dados*/
  38.             SqlConnection cn = new SqlConnection(Properties.Settings.Default.nivelacessoConnectionString);
  39.  
  40.             /*destino onde o comando vai ser executado + connection string */
  41.             SqlCommand cmd = new SqlCommand("SELECT * FROM tbUsuario WHERE usuario = @usuario and senha = @senha and nivelAcesso = @nivelAcesso", cn);
  42.             cmd.Parameters.Add("@usuario", SqlDbType.VarChar).Value = usuarioComboBox;
  43.             cmd.Parameters.Add("@senha", SqlDbType.VarChar).Value = senhaTextBox;
  44.             cmd.Parameters.Add("@nivelAcesso", SqlDbType.VarChar).Value = nivelAcessoComboBox;
  45.             cn.Open();
  46.  
  47.             SqlDataReader le = null;
  48.  
  49.             le = cmd.ExecuteReader();
  50.  
  51.             if (le.Read())
  52.             {
  53.                 this.Hide();
  54.                 usuarioConectado = usuarioComboBox.Text;
  55.                 nivelAcesso = nivelAcessoComboBox.Text;
  56.                 frmMain tela = new frmMain();
  57.                 tela.Show();
  58.             }
  59.             else
  60.             {
  61.                 MessageBox.Show("Usuario e/ou senha invalida");
  62.             }
  63.         }
  64.  
  65.     }
  66. }

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right
fantasy-obligation