Example #1
0
        private void button_Registration_Click(object sender, EventArgs e)
        {
            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                try
                {
                    string sql = "exec Register @Users=N'" + textbox_Login.Text + "',@Password=N'" + passwordbox_Password.Text.GetHashCode().ToString() + "',@Role=N'" + "User" + "',@Balancez=N'" + 0 + "'";
                    conn.Open();
                    SqlCommand command2 = new SqlCommand(sql, conn);
                    command2.CommandText = "exec selectUser @Username=N'" + textbox_Login.Text + "'";
                    if (command2.ExecuteScalar() == null)
                    {
                        SqlCommand cmd = new SqlCommand(sql, conn);


                        cmd.ExecuteNonQuery();
                        MessageBox.Show("New Client was successfully added!", "");
                        Authoriz form = new Authoriz();
                        form.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Пользователь с таким именем уже зарегстрирован");
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);// Лучше обработать все возможные исключения
                }
                finally
                {
                    conn.Close();
                }
            }
        }
Example #2
0
        private void Admin1_Closed(object sender, EventArgs e)
        {
            Authoriz form = new Authoriz();

            form.Show();
        }