示例#1
0
        //Tạo phòng
        public static void TaoRoom(string host_id, string room_no, string room_key)
        {
            Random random   = new Random();
            int    start    = random.Next(0, roomName.Length);
            string roomname = roomName[start];

            if (room_key != null)
            {
                if (room_key.Equals("duelyst"))
                {
                    roomname = "THIS IS A DUEL";
                }
            }


            MySqlConnection conn = DBUtils.GetDBConnection();
            MySqlCommand    MyCommand;

            MyCommand = conn.CreateCommand();
            conn.Open();
            try
            {
                MyCommand.CommandText = "INSERT INTO room (host_id, roomname, room_no, room_key)  VALUES (@host_id, @roomname, @room_no, @room_key) ";
                MyCommand.Parameters.AddWithValue("@host_id", host_id);
                MyCommand.Parameters.AddWithValue("@room_no", room_no);
                MyCommand.Parameters.AddWithValue("@roomname", roomname);
                MyCommand.Parameters.AddWithValue("@room_key", room_key);
                //MyCommand.Parameters.AddWithValue("@join_id", join_id);
                MyCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                conn.Dispose();
                conn.Close();
            }
        }
示例#2
0
        //Clear Room

        public static void ClearRoom()
        {
            MySqlConnection conn = DBUtils.GetDBConnection();
            MySqlCommand    MyCommand;

            MyCommand = conn.CreateCommand();
            conn.Open();
            try
            {
                MyCommand.CommandText = "TRUNCATE TABLE room;";
                MyCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                conn.Dispose();
                conn.Close();
            }
        }
示例#3
0
        //Xóa Phòng
        public static void XoaRoom(string host_id)
        {
            MySqlConnection conn = DBUtils.GetDBConnection();
            MySqlCommand    MyCommand;

            MyCommand = conn.CreateCommand();
            conn.Open();
            try
            {
                MyCommand.CommandText = "DELETE FROM room WHERE host_id = @host_id;";
                MyCommand.Parameters.AddWithValue("@host_id", host_id);
                MyCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                conn.Dispose();
                conn.Close();
            }
        }
示例#4
0
        public static void ChangeStatusFriendList(string user_id)
        {
            MySqlConnection conn = DBUtils.GetDBConnection();
            MySqlCommand    MyCommand;

            MyCommand = conn.CreateCommand();
            conn.Open();
            try
            {
                MyCommand.CommandText = $"UPDATE friendlist SET status = @status WHERE name = '" + user_id + "';";
                MyCommand.Parameters.AddWithValue("@status", SqlDbType.Int).Value = 0;
                MyCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                conn.Dispose();
                conn.Close();
            }
        }
示例#5
0
        //Update join_id
        public static void UpdateRoom(string host_id, string join_id, string room_no)
        {
            MySqlConnection conn = DBUtils.GetDBConnection();
            MySqlCommand    MyCommand;

            MyCommand = conn.CreateCommand();
            conn.Open();
            try
            {
                MyCommand.CommandText = "UPDATE room SET host_id = @host_id, join_id = @join_id WHERE room_no = '" + room_no + "';";
                MyCommand.Parameters.AddWithValue("@host_id", host_id);
                MyCommand.Parameters.AddWithValue("@join_id", join_id);
                MyCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                conn.Dispose();
                conn.Close();
            }
        }
示例#6
0
        // Xoa Ban
        public static void XoaBan(string username, string name)
        {
            MySqlConnection conn = DBUtils.GetDBConnection();
            MySqlCommand    MyCommand;

            MyCommand = conn.CreateCommand();
            conn.Open();
            try
            {
                MyCommand.CommandText = "DELETE FROM friendlist WHERE name = @name and username = @username;";
                MyCommand.Parameters.AddWithValue("@name", name);
                MyCommand.Parameters.AddWithValue("@username", username);
                MyCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                conn.Dispose();
                conn.Close();
            }
        }
示例#7
0
        public static void ResetFriendList()
        {
            int             status = 0;
            MySqlConnection conn   = DBUtils.GetDBConnection();
            MySqlCommand    MyCommand;

            MyCommand = conn.CreateCommand();
            conn.Open();
            try
            {
                MyCommand.CommandText = "UPDATE friendlist SET status = @status;";
                MyCommand.Parameters.AddWithValue("@status", status);
                MyCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                conn.Dispose();
                conn.Close();
            }
        }