private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         connection conn = new connection();
         SqlCommand cmd  = new SqlCommand("CheckLogin", conn.conn);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.Add("@UserN", SqlDbType.VarChar).Value = textBox1.Text;
         cmd.Parameters.Add("@PassW", SqlDbType.VarChar).Value = textBox2.Text;
         var returnParametre = cmd.Parameters.Add("@ReturnVal", SqlDbType.Bit);
         returnParametre.Direction = ParameterDirection.ReturnValue;
         conn.conn.Open();
         cmd.ExecuteNonQuery();
         var result = returnParametre.Value;
         int i      = Convert.ToInt32(result);
         if (i != 0)
         {
             // MessageBox.Show("login successe");
             errolabel.Text = "welcome Admin";
             LoginAcceuill obj = (LoginAcceuill)Application.OpenForms["LoginAcceuill"];
             obj.Hide();
             new admin_acceuil(i).Show();
         }
         else
         {
             // MessageBox.Show("the user doesn't existe");
             // label3.Text = "user dosen't existe ";
             errolabel.Text = "username ou mot de passe incorect !!";
         }
     }
     catch (SqlException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 2
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            LoginAcceuill login = new LoginAcceuill();

            login.Show();
            this.Close();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                connection conn = new connection();
                SqlCommand cmd  = new SqlCommand("CheckLogin_E", conn.conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@UserN", SqlDbType.VarChar).Value = textBox1.Text;
                cmd.Parameters.Add("@PassW", SqlDbType.VarChar).Value = textBox2.Text;
                var returnParametre = cmd.Parameters.Add("@ReturnVal", SqlDbType.Int);
                returnParametre.Direction = ParameterDirection.ReturnValue;
                conn.conn.Open();
                cmd.ExecuteNonQuery();
                var result = returnParametre.Value;
                int i      = Convert.ToInt32(result);
                if (i != 0)

                {
                    errorlabel.Text = "welcome Enseignant";
                    //MessageBox.Show("Login suuccesse");
                    LoginAcceuill obj = (LoginAcceuill)Application.OpenForms["LoginAcceuill"];
                    obj.Hide();
                    new ens_acceuil(i).Show();
                }
                else
                {
                    // MessageBox.Show("the user doesn't existe");
                    errorlabel.Text = "username ou mot de passe incorect !";
                }

                /*  cmd.Parameters.Add("@ens", SqlDbType.Int).Value = ensbox.SelectedValue;
                 * cmd.Parameters.Add("@semestre", SqlDbType.Int).Value = semestrebox.SelectedValue;
                 * cmd.Parameters.Add("@element", SqlDbType.Int).Value = elementbox.SelectedValue;
                 * cmd.Parameters.Add("@module", SqlDbType.Int).Value = modulebox.SelectedValue;
                 * cmd.Parameters.Add("@groupe", SqlDbType.Int).Value = groupebox.SelectedValue;
                 * cmd.Parameters.Add("@salle", SqlDbType.Int).Value = sallebox.SelectedValue;
                 * cmd.Parameters.Add("@filiere", SqlDbType.Int).Value = idf;
                 * cmd.Parameters.Add("@type", SqlDbType.VarChar).Value = typebox.Text;*/



                //  MessageBox.Show("Login successe");
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }