private void checkBox1_CheckedChanged(object sender, EventArgs e)
 {
     if (checkBox1.Checked)
     {
         ParolaTextbox.UseSystemPasswordChar = false;
     }
     else
     {
         ParolaTextbox.UseSystemPasswordChar = true;
     }
     groupBox1.Focus();
     ParolaTextbox.Focus();
 }
示例#2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (NumeTextbox.Text == "")
     {
         MessageBox.Show("Introdu numele tau!", "Atentie", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else if (PrenumeTextbox.Text == "")
     {
         MessageBox.Show("Introdu prenumele tau!", "Atentie", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else if (UserTextbox.Text == "")
     {
         MessageBox.Show("Introdu numele tau de utilizator!", "Atentie", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else if (ParolaTextbox.Text == "")
     {
         MessageBox.Show("Introdu o parola!", "Atentie", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else if (VerParolaTextbox.Text == "" && checkBox1.Checked == false)
     {
         MessageBox.Show("Introdu verificarea parolei!", "Atentie", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else if (checkBox1.Checked == false && ParolaTextbox.Text != VerParolaTextbox.Text)
     {
         MessageBox.Show("Parola nu se potriveste cu verificarea ei.\nReintrodu parola!", "Atentie", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         ParolaTextbox.Clear();
         VerParolaTextbox.Clear();
         groupBox2.Focus();
         ParolaTextbox.Focus();
     }
     else
     {
         cale = Directory.GetCurrentDirectory();
         SqlConnection conn = new SqlConnection(@"server = .\sqlexpress;Database=Utilizatori.mdf;trusted_connection=True;AttachDbFileName = " + cale + @"\Utilizatori.mdf");
         conn.Open();
         SqlCommand    cmd    = new SqlCommand(@"SELECT * FROM Users", conn);
         SqlDataReader reader = cmd.ExecuteReader();
         bool          exista = false;
         while (reader.Read())
         {
             if (reader[3].ToString() == UserTextbox.Text)
             {
                 exista = true;
                 break;
             }
         }
         reader.Close();
         if (exista)
         {
             MessageBox.Show("Un alt utilizator are acelasi Username.\nIncearca altul!", "Atentie", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             UserTextbox.Clear();
             groupBox2.Focus();
             UserTextbox.Focus();
         }
         else
         {
             cmd = new SqlCommand(@"INSERT INTO Users (Nume, Prenume, UserName, Parola) VALUES ( '" + NumeTextbox.Text + "', '" + PrenumeTextbox.Text + "', '" + UserTextbox.Text + "', '" + ParolaTextbox.Text + "' )", conn);
             cmd.ExecuteReader();
             conn.Close();
             MessageBox.Show("Operatie reusita!");
         }
     }
 }