Example #1
0
        public void Add(string password, RegistrationForm regform, MainWindow mainWindow)
        {
            if (Code == EmailCode && Code != null && Code != "")
            {
                if (userLogName == null || password == null || userMail == null || userLogName == "" && password == "")
                {
                    MessageBox.Show("Заполните все поля!");
                }
                else
                {
                    bool       flag       = true;
                    SqlCommand sqlCommand = new SqlCommand();
                    sqlCommand.CommandText = "select * from users";
                    sqlCommand.Connection  = DBConnection.DBConnection.SqlConnection;
                    SqlDataReader reader = sqlCommand.ExecuteReader();



                    foreach (var i in reader)
                    {
                        if (reader.GetSqlString(1) == userLogName)
                        {
                            MessageBox.Show("Данный логин уже занят");
                            flag = false;
                            reader.Close();
                            break;
                        }
                    }
                    if (flag)
                    {
                        reader.Close();
                        sqlCommand.CommandText = $"insert into users (userLogName,userPassword,count_of_orders,userMail,bit ) values( @userLogName, @password, {count_of_orders}, @userMail, {bit})";
                        SqlParameter userLogNameParam = new SqlParameter("@userLogName", userLogName);
                        sqlCommand.Parameters.Add(userLogNameParam);
                        SqlParameter passwordParam = new SqlParameter("@password", password);
                        sqlCommand.Parameters.Add(passwordParam);

                        SqlParameter mailParam = new SqlParameter("@userMail", userMail);
                        sqlCommand.Parameters.Add(mailParam);

                        sqlCommand.ExecuteNonQuery();
                        regform.Hide();
                        mainWindow.Show();
                    }
                }
            }
            else
            {
                MessageBox.Show("Неверный код, попробуйте еще раз или другую почту");
            }
        }
Example #2
0
        public void Add(string password, RegistrationForm regform, MainWindow mainWindow)
        {
            if (Code == EmailCode)
            {
                if (userLogName == null || password == null || userMail == null)
                {
                    MessageBox.Show("Заполните все поля!");
                }
                else
                {
                    bool       flag       = true;
                    SqlCommand sqlCommand = new SqlCommand();
                    sqlCommand.CommandText = "select * from users";
                    sqlCommand.Connection  = DBConnection.DBConnection.SqlConnection;
                    SqlDataReader reader = sqlCommand.ExecuteReader();



                    foreach (var i in reader)
                    {
                        if (reader.GetSqlString(1) == userLogName)
                        {
                            MessageBox.Show("Данный логин уже занят");
                            flag = false;
                            reader.Close();
                            break;
                        }
                    }
                    if (flag)
                    {
                        reader.Close();
                        sqlCommand.CommandText = $"insert into users values('{userLogName}','{password}',{count_of_orders},'{userMail}',{bit})";
                        sqlCommand.ExecuteNonQuery();
                        regform.Hide();
                        mainWindow.Show();
                    }
                }
            }
            else
            {
                MessageBox.Show("Неверный код, попробуйте еще раз или другую почту");
            }
        }
Example #3
0
 public void Exit(MainWindow mainWindow, RegistrationForm regform)
 {
     regform.Hide();
     mainWindow.ShowDialog();
 }