Beispiel #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string          connectionString = "Server=localhost;DATABASE=inwork;UID=root;password=root";
            MySqlConnection connection       = new MySqlConnection(connectionString);
            MySqlCommand    cmd = new MySqlCommand("select * from authorization where user_login='******' and user_password='******' and user_status_id = " + status_id + ";", connection);

            try
            {
                if (connection.State == ConnectionState.Closed)
                {
                    connection.Open();
                }
                if (status_id == 1)
                {
                    cmd.CommandType = CommandType.Text;
                    MySqlDataAdapter adapter = new MySqlDataAdapter();
                    adapter.SelectCommand = cmd;
                    DataSet dataSet = new DataSet();
                    adapter.Fill(dataSet);
                    if (dataSet.Tables[0].Rows.Count > 0)
                    {
                        MainMenuWindow mainMenuWindow = new MainMenuWindow();
                        mainMenuWindow.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Пароль или логин неверный!");
                    }
                }
                else
                {
                    cmd.CommandType = CommandType.Text;
                    MySqlDataAdapter adapter = new MySqlDataAdapter();
                    adapter.SelectCommand = cmd;
                    DataSet dataSet = new DataSet();
                    adapter.Fill(dataSet);
                    if (dataSet.Tables[0].Rows.Count > 0)
                    {
                        MainMenu2 mainMenuWindow2 = new MainMenu2();
                        mainMenuWindow2.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Пароль или логин неверный!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                connection.Close();
            }
        }
Beispiel #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string          connectionString = "Server=localhost;DATABASE=menu;UID=root;password=c_ronaldo";
            MySqlConnection connection       = new MySqlConnection(connectionString);

            //MySqlCommand cmd = new MySqlCommand("select * from users where user_login='******' and user_password='******';", connection);
            //connection.Open();
            //DataTable dt = new DataTable();
            //dt.Load(cmd.ExecuteReader());
            //connection.Close();
            //MainMenuWindow mainMenuWindow = new MainMenuWindow();
            //mainMenuWindow.mainMenu.DataContext = dt;
            //this.Close();
            //mainMenuWindow.Show();


            try
            {
                if (connection.State == ConnectionState.Closed)
                {
                    connection.Open();
                }

                MySqlCommand cmd = new MySqlCommand("select * from users where name='" + user_name.Text + "' and password='******';", connection);
                cmd.CommandType = CommandType.Text;
                MySqlDataAdapter adapter = new MySqlDataAdapter();
                adapter.SelectCommand = cmd;
                DataSet dataSet = new DataSet();
                adapter.Fill(dataSet);
                if (dataSet.Tables[0].Rows.Count > 0)
                {
                    MainMenuWindow mainMenuWindow = new MainMenuWindow();
                    mainMenuWindow.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Пароль или логин неверный!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                connection.Close();
            }
        }
Beispiel #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string          connectionString = "Server=localhost;DATABASE=dota2;UID=root;password=root";
            MySqlConnection connection       = new MySqlConnection(connectionString);
            MySqlCommand    cmd = new MySqlCommand("select * from users where user_login='******' and user_password='******';", connection);

            connection.Open();
            DataTable dt = new DataTable();

            dt.Load(cmd.ExecuteReader());
            connection.Close();
            MainMenuWindow mainMenuWindow = new MainMenuWindow();

            mainMenuWindow.mainMenu.DataContext = dt;
            this.Close();
            mainMenuWindow.Show();
        }