示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Authentification adm = new Authentification();

            adm.Show();
            Close();
        }
示例#2
0
        public void Close()
        {
            Authentification closeform = new Authentification();

            closeform.FormClosed += Cl_FormClosed;
            this.Hide();
        }
示例#3
0
        private void button2_Click(object sender, EventArgs e)
        {
            Registration reg2 = new Registration();

            reg2.FormClosed += Reg2_FormClosed;
            this.Hide();
            Authentification adm = new Authentification();

            adm.Show();
        }
示例#4
0
        private void button1_Click(object sender, EventArgs e)
        {
            string          connStr = "server=localhost;user=root;password=;database=mydb;port=3306;";
            MySqlConnection conn    = new MySqlConnection(connStr);

            try
            {
                conn.Open();
                string          sql  = "SELECT username FROM users WHERE username=\"" + textBox1.Text + "\";";
                MySqlCommand    cmd  = new MySqlCommand(sql, conn);
                MySqlDataReader rdr  = cmd.ExecuteReader();
                int             chek = 0;
                while (rdr.Read())
                {
                    string name = "";
                    name = Convert.ToString(rdr[0]);
                    if (name != "")
                    {
                        MessageBox.Show("Пользователь " + name + " уже зарегестрирован");
                        chek = 1;
                    }
                }
                rdr.Close();

                if (chek == 0)
                {
                    string       regis    = "INSERT INTO `mydb`.`users`(`username`,`password`)VALUES(\"" + textBox1.Text + "\",\"" + textBox2.Text + "\");";
                    MySqlCommand regiscmd = new MySqlCommand(regis, conn);
                    regiscmd.ExecuteNonQuery();
                    MessageBox.Show(" Регистрация прошла успешно \n\tВаш логин:\"" + textBox1.Text + "\"\n\tВаш пароль: \"" + textBox2.Text + "\"");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            conn.Close();

            Registration reg2 = new Registration();

            reg2.FormClosed += Reg2_FormClosed;
            this.Hide();
            Authentification adm = new Authentification();

            adm.Show();
        }