Beispiel #1
0
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked)
            {
                SqlConnection con = new SqlConnection();

                con.ConnectionString = @"Data Source=DESKTOP-69MM1NJ\SQLEXPRESS;Initial Catalog=NadhamniDB;Integrated Security=True;Pooling=False";

                try
                {
                    con.Open();
                    string     sql = "select ProfilePic,Password,Email from Profile  where UserName = '******'";
                    SqlCommand cmd = new SqlCommand(sql, con);

                    SqlDataReader dr = cmd.ExecuteReader();


                    dr.Read();
                    if (dr.HasRows)
                    {
                        txt_password.Text = dr[1].ToString();
                        txt_Email.Text    = dr[2].ToString();


                        Byte[] img = (Byte[])(dr[0]);
                        if (img == null)
                        {
                            pictureBox1.Image = null;
                        }

                        else
                        {
                            MemoryStream ms = new MemoryStream(img);
                            pictureBox1.Image = Image.FromStream(ms);
                        }
                    }
                    else
                    {
                        CheckRegistration cr = new CheckRegistration();
                        cr.Show();
                        //MessageBox.Show("error img not found");
                    }
                }
                catch (Exception ex)
                { MessageBox.Show(ex.Message); }
                finally
                {
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                }

                //btnUploadPic.Visible = false;
            }
        }
Beispiel #2
0
 private void btn_signIn_Click(object sender, EventArgs e)
 {
     try
     {
         con.Open();
         cmd.Connection  = con;
         cmd.CommandText = "select * from Profile where UserName='******'";
         dr = cmd.ExecuteReader();
         if (dr.HasRows)
         {   //get the FK
             FK = txt_username.Text;
             Boolean ok = false;
             while (dr.Read() && ok == false)
             {
                 if (!txt_password.Text.Equals(dr["Password"]))
                 {
                     PasswordCheck pw = new PasswordCheck();
                     pw.Show();
                     // MessageBox.Show("You need to check your password!");
                     ok = true;
                 }
                 else if (!txt_Email.Text.Equals(dr["Email"]))
                 { //MessageBox.Show("You need to check your E-mail!");
                     EmailCheck ec = new EmailCheck();
                     ec.Show();
                     ok = true;
                 }
             }
             if (ok == false)
             {
                 dsh.Show();
                 this.Hide();
                 fb.Hide();
                 tw.Hide();
                 gp.Hide();
             }
         }
         else
         {
             if (txt_password.Text.Equals("") && txt_Email.Text.Equals("") && txt_username.Text.Equals(""))
             {
                 // MessageBox.Show("The fields are empty");
                 EmptyFields ep = new EmptyFields();
                 ep.Show();
             }
             else
             {
             }
             // MessageBox.Show("You need to register!");
             CheckRegistration crg1 = new CheckRegistration();
             crg1.Show();
             dr.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         if (con.State == ConnectionState.Open)
         {
             con.Close();
         }
     }
 }