コード例 #1
0
        /* Redirects the user to userLogin_form. */
        private void labelCatreAutentificare_Click(object sender, EventArgs e)
        {
            this.Close();
            userLogin_form loginform = new userLogin_form();

            loginform.Show();
        }
コード例 #2
0
        /* User logout method. */
        private void btnIesire_Click(object sender, EventArgs e)
        {
            userLogin_form.UtilizatorID = 0;
            userLogin_form.username     = "";
            this.Close();
            userLogin_form loginform = new userLogin_form();

            loginform.Show();
        }
コード例 #3
0
        /* Registers the textboxes values in the table Utilizatori. */
        private void btnInregistrare_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtUtilizator.Text) || string.IsNullOrEmpty(txtParola.Text))
            {
                MessageBox.Show("Completati campurile obligatorii.");
            }
            else if (txtTipUtilizator.SelectedIndex != 0 && txtTipUtilizator.SelectedIndex != 1)
            {
                MessageBox.Show("Selectati tipul de utilizator.");
            }
            else if (txtParola.Text != txtConfirmareParola.Text)
            {
                MessageBox.Show("Campurile parolei trebuie sa coincida!");
            }
            else
            {
                using (SqlConnection DatabaseConnection = new SqlConnection(connection_class.connectionString))
                {
                    DatabaseConnection.Open();

                    SqlCommand checkUser = new SqlCommand("VerificareUtilizatorUnic", DatabaseConnection);
                    checkUser.CommandType = CommandType.StoredProcedure;
                    checkUser.Parameters.AddWithValue("@utilizator", txtUtilizator.Text.Trim());
                    int UserExists = (int)checkUser.ExecuteScalar();
                    if (UserExists > 0)
                    {
                        /* User already exists. */
                        MessageBox.Show("Numele de utilizator exista deja!");
                        return;
                    }
                    else
                    {
                        SqlCommand sqlCmd = new SqlCommand("InregistrareUtilizator", DatabaseConnection);
                        sqlCmd.CommandType = CommandType.StoredProcedure;

                        sqlCmd.Parameters.AddWithValue("@Utilizator", txtUtilizator.Text.Trim());
                        sqlCmd.Parameters.AddWithValue("@Tip_Utilizator", txtTipUtilizator.SelectedItem);
                        sqlCmd.Parameters.AddWithValue("@Nume", txtNume.Text.Trim());
                        sqlCmd.Parameters.AddWithValue("@Prenume", txtPrenume.Text.Trim());
                        sqlCmd.Parameters.AddWithValue("@Parola", connection_class.PasswordEncrypt(txtParola.Text.Trim()));
                        sqlCmd.ExecuteNonQuery();
                        MessageBox.Show("Utilzatorul a fost inregistrat cu succes!");
                        DatabaseConnection.Close();
                        connection_class.ClearTextBoxes(this.Controls);
                        this.Hide();
                        userLogin_form loginform = new userLogin_form();
                        loginform.Show();
                    }
                }
            }
        }