Example #1
0
        private void OKBtn_Click(object sender, RoutedEventArgs e)
        {// Xử lý khi ấn button OK để hoàn thành việc lưu ván đấu
            if (txtUserName.Text.Count() == 0)
            {
                MessageBox.Show("Please enter ID to know which your match is.");
                return;
            }
            if (txtPassword.Password.Count() == 0)
            {
                MessageBox.Show("Please enter password.");
                return;
            }

            matchToSave.id       = txtUserName.Text;
            matchToSave.password = txtPassword.Password;
            matchToSave.ate      = GlobalItem.ate;

            MatchBUS bus    = new MatchBUS();
            int      result = bus.SaveMatch(matchToSave);

            if (result == 0)
            {
                MessageBox.Show("Can not save, please try again later");
            }
            else if (result == 1)
            {
                MessageBox.Show("Match saved");

                this.Close();
            }
            else
            {
                MessageBox.Show("ID was existed, please enter other ID");
            }
        }
        private void OKClicked()
        {
            if (boxPass.Password.Count() == 0)
            {
                lblWrongAcc.Content    = "Please enter password";
                lblWrongAcc.Visibility = Visibility.Visible;
                return;
            }

            MatchBUS bus   = new MatchBUS();
            MatchDTO match = bus.LoadMatch(ID);

            if (boxPass.Password != match.password)
            {
                lblWrongAcc.Content    = "Wrong password";
                lblWrongAcc.Visibility = Visibility.Visible;
                return;
            }

            //da nhap dung password
            bus.deleteMatch(ID);

            GlobalItem.IDPlayer1  = match.player1;
            GlobalItem.IDPlayer2  = match.player2;
            GlobalItem.time1      = match.time1;
            GlobalItem.time2      = match.time2;
            GlobalItem.turn       = match.turn;
            GlobalItem.chessboard = match.chessboard;
            GlobalItem.check      = match.check;

            //cap nhat cac quan co da an
            GlobalItem.numOfWhitePawn   = match.ate[0] - '0';
            GlobalItem.numOfBlackPawn   = match.ate[1] - '0';
            GlobalItem.numOfWhiteBishop = match.ate[2] - '0';
            GlobalItem.numOfBlackBishop = match.ate[3] - '0';
            GlobalItem.numOfWhiteKnight = match.ate[4] - '0';
            GlobalItem.numOfBlackKnight = match.ate[5] - '0';
            GlobalItem.numOfWhiteCastle = match.ate[6] - '0';
            GlobalItem.numOfBlackCastle = match.ate[7] - '0';
            GlobalItem.numOfWhiteQueen  = match.ate[8] - '0';
            GlobalItem.numOfBlackQueen  = match.ate[9] - '0';
            GlobalItem.numOfWhiteKing   = match.ate[10] - '0';
            GlobalItem.numOfBlackKing   = match.ate[11] - '0';


            GlobalItem.main.UCPlayground.Visibility = Visibility.Visible;
            GlobalItem.main.UCPlayground.loadMatch();// Hàm tái khởi tạo CinemaSeats
            // GlobalItem.main.UCPlayground.itPlayTime(); // Bắt đầu thời gian đếm ngược
            // man hình load sẽ tắt -> màn hình này cũng tắt
            this.Owner.Close();
        }
        private void loadLoadScreen()
        {
            MatchBUS        bus     = new MatchBUS();
            List <Matches>  list    = new List <Matches>();
            List <MatchDTO> matches = bus.loadAllSavedMatch();

            for (int i = 0; i < matches.Count(); i++)
            {
                list.Add(new Matches()
                {
                    stt = i + 1, id = matches[i].id
                });
            }
            lstMatch.ItemsSource = list;
        }