示例#1
0
文件: form1.cs 项目: DDarkeron/pit2
        public void sortMem()
        {
            member temp = null;

            for (int i = 0; i < members.Count; i++)
            {
                for (int j = 0; j < members.Count - 1; j++)
                {
                    if (members[j].score < members[j + 1].score)
                    {
                        temp           = members[j + 1];
                        members[j + 1] = members[j];
                        members[j]     = temp;
                    }
                }
            }
        }
示例#2
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            DB     db       = new DB();
            String username = textboxUsername.Text;
            String password = textboxPassword.Text;
            var    account  = new member(username, password);

            DataTable table = new DataTable();

            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand     command = new MySqlCommand("SELECT * FROM `users` WHERE `username` = @usn and `password` = @pass", db.GetConnection());

            command.Parameters.Add("@usn", MySqlDbType.VarChar).Value  = username;
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = password;
            adapter.SelectCommand = command;
            adapter.Fill(table);

            //Mengecek bahwa user ada dalam database atau tidak.
            if (table.Rows.Count > 0)
            {
                MessageBox.Show(string.Format("Hello, {0}", username));
                Usermenu usermenu = new Usermenu();
                this.Hide();
                usermenu.Show();
            }
            else
            {
                if (username.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Username.");
                }
                else if (password.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Password.");
                }
                else
                {
                    MessageBox.Show("Wrong username or password.");
                }
            }
        }