Exemplo n.º 1
0
        private void EditDataButton_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(LoginRegText.Text) &&
                !String.IsNullOrEmpty(PasswordRegBox.Text) &&
                !String.IsNullOrEmpty(NumberPhoneText.Text) &&
                !String.IsNullOrEmpty(EmailTextBox.Text) &&
                !String.IsNullOrEmpty(PasswordRegBox.Text))
            {
                // строка подключения к БД
                string connStr = "server=localhost;user=root;database=estateagency;password=root";
                // создаём объект для подключения к БД
                MySqlConnection conn = new MySqlConnection(connStr);
                // устанавливаем соединение с БД
                conn.Open();
                // запрос
                string sql = "select max(id_profile) from profile;";
                // объект для выполнения SQL-запроса
                MySqlCommand command = new MySqlCommand(sql, conn);
                // выполняем запрос и получаем ответ
                try
                {
                    id_profile = (int)command.ExecuteScalar() + 1;
                }
                catch
                {
                    id_profile = 0;
                }


                // запрос
                sql = "INSERT INTO `estateagency`.`profile` (`id_profile`, `login`, `password`, `phoneNumber`, `email`, `nickname`)" +
                      $" VALUES ('{id_profile.ToString()}', " +
                      $"'{LoginRegText.Text}', " +
                      $"'{PasswordRegBox.Text}', " +
                      $"'{NumberPhoneText.Text}', " +
                      $"'{EmailTextBox.Text}', " +
                      $"'{PasswordRegBox.Text}');";
                // объект для выполнения SQL-запроса
                command = new MySqlCommand(sql, conn);
                // выполняем запрос и получаем ответ
                command.ExecuteScalar();
                // закрываем соединение с БД
                conn.Close();

                this.tabControl1.SelectedIndex = 0;

                MessageBox.Show("Вы успешно зарегистрированы! Теперь войдите в систему");

                EditDataButton.Hide();
            }
            else
            {
                MessageBox.Show("Сначала заполните ВСЕ поля");
            }
        }
Exemplo n.º 2
0
 private void FilterForm_Load(object sender, EventArgs e)
 {
     AddDataButton.Hide();
     EditDataButton.Hide();
     DelDataButton.Hide();
 }