private void btn_OK_Click(object sender, EventArgs e)
        {
            PersonalInformation p = new PersonalInformation();

            p.Show();
            this.Hide();
            Facebook   f  = new Facebook();
            GooglePlus gp = new GooglePlus();
            twitter    t  = new twitter();

            f.Hide();
            gp.Hide();
            t.Hide();
        }
Example #2
0
 private void btn_register_Click(object sender, EventArgs e)
 {
     try
     {
         con.Open();
         cmd.Connection  = con;
         cmd.CommandText = "select * from Profile where UserName='******'";
         dr = cmd.ExecuteReader();
         if (dr.HasRows)
         {
             MessageBox.Show("This username exists,choose another one!");
         }
         else
         {   //we have to close the DataReader so we can execute the insert query
             dr.Close();
             //we will add a new user by inserting his UserName,his Password and his E-mail
             SqlCommand cmd1 = new SqlCommand("insert into Profile(UserName,Password,Email) values(@UserName,@Password,@Email)", con);
             //Je dois confgurer les paramétres
             cmd1.CommandType = CommandType.Text;//Cette instruction donne le type de la commande , la valeur par defaut est text et elle n'est pas obligatoire
             cmd1.Parameters.AddWithValue("@UserName", txt_username.Text);
             cmd1.Parameters.AddWithValue("@Password", txt_password.Text);
             cmd1.Parameters.AddWithValue("@Email", txt_Email.Text);
             //get the FK
             FK = txt_username.Text;
             //Execut the query
             cmd1.ExecuteNonQuery();
             PersonalInformation p = new PersonalInformation();
             p.Show();
             this.Hide();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         if (con.State == ConnectionState.Open)
         {
             con.Close();
         }
     }
 }