Beispiel #1
0
        private void Registration(object sender, RoutedEventArgs e)
        {
            try
            {
                if (Validator.ValidTextBoxes(this.Login.Text, this.Password.Password, this.Email.Text))
                {
                    using (SqlConnection cn = Connector.GetConnection())
                    {
                        cn.Open();
                        SqlCommand cmd = new SqlCommand("Registration", cn);
                        cmd.CommandType = System.Data.CommandType.StoredProcedure;

                        SqlParameter login = new SqlParameter();
                        login.ParameterName = "@login";
                        login.Value         = this.Login.Text;

                        SqlParameter pass = new SqlParameter();
                        pass.ParameterName = "@password";
                        pass.Value         = this.Password.Password;

                        SqlParameter email = new SqlParameter();
                        email.ParameterName = "@email";
                        email.Value         = this.Email.Text;

                        cmd.Parameters.Add(login);
                        cmd.Parameters.Add(pass);
                        cmd.Parameters.Add(email);

                        SqlParameter rc = new SqlParameter();
                        rc.ParameterName = "@rc";
                        rc.SqlDbType     = System.Data.SqlDbType.Bit;
                        rc.Direction     = System.Data.ParameterDirection.Output;
                        cmd.Parameters.Add(rc);

                        cmd.ExecuteNonQuery();

                        cn.Close();

                        if ((bool)cmd.Parameters["@rc"].Value)
                        {
                            MessageBox.Show("Регистрация прошла успешно!");
                            Main mainWnd = new Main();
                            mainWnd.Show();
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("Ошибка регистрации!");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Введите данные!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #2
0
 private void PackIcon_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     this.Close();
     main.Show();
 }