예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool          ok  = false;
            SqlConnection con = new SqlConnection(Form1.constr);

            con.Open();
            SqlCommand    cmd = new SqlCommand("Select email,parola from Utilizatori", con);
            SqlDataReader dr;

            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                if (textBox1.Text == dr.GetValue(0).ToString() && textBox2.Text == dr.GetValue(1).ToString())
                {
                    email = dr.GetValue(0).ToString();
                    ok    = true;
                    MessageBox.Show("Connectarea reusita");
                    Meniu s = new Meniu();
                    this.Hide();
                    s.Show();
                }
            }
            if (!ok)
            {
                MessageBox.Show("Verifica datele");
            }
            con.Close();
            cmd.Dispose();
        }
예제 #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     //for (int i = 1; i <= 20; i++)
     // {
     if (textBox4.Text == textBox5.Text && textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && textBox5.Text != "")
     {
         SqlConnection con = new SqlConnection(Form1.constr);
         con.Open();
         SqlCommand     cmd = new SqlCommand("Insert into Utilizatori(email,parola,nume,prenume) values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')", con);
         SqlDataAdapter da  = new SqlDataAdapter(cmd);
         DataSet        ds  = new DataSet();
         da.Fill(ds);  mail = textBox1.Text;
         MessageBox.Show("Inregistrarea a reusit");
         this.Hide();
         Meniu s = new Meniu();
         s.Show();
     }
     else
     {
         MessageBox.Show("Verifica datele");
     }
     //}
 }