示例#1
0
        private void saveGame(string rec)
        {
            ConnDatabase bd       = new ConnDatabase();
            string       id_piece = "";
            int          l        = verticalCountOfPieces * horisontalCountOfPieces;

            if (triangle)
            {
                l *= 2;
            }
            if (rec == "На время")
            {
                TimeSpan ts       = stopWatch.Elapsed.Add(fromSave);
                string   formatts = ts.ToString(@"hh\:mm\:ss");
                bd.insertInGame(id_puzzle, login, game_mode, record, formatts);

                for (int i = 0; i < l; i++)
                {
                    bd.insertInPuzzlePiece(serial_number[i].ToString(), ((Point)((object[])pb[i].Tag)[0]).X.ToString(), ((Point)((object[])pb[i].Tag)[0]).Y.ToString(), id_puzzle);
                    id_piece = bd.selectIDPiece(serial_number[i].ToString(), id_puzzle);
                    if ((game_mode.Equals("На ленте")) && (((char)((object[])pb[i].Tag)[1] == 'n') || ((char)((object[])pb[i].Tag)[1] == 's')))
                    {
                        bd.insertInSave(id_piece, id_puzzle, login, (55).ToString(), (this.Size.Height - h - buttonLeft.Height - 38 + 5).ToString());
                    }
                    else
                    {
                        bd.insertInSave(id_piece, id_puzzle, login, pb[i].Location.X.ToString(), pb[i].Location.Y.ToString());
                    }
                }
                MessageBox.Show("Игра успешно сохранена!");
            }
            else
            {
                bd.insertInGame(id_puzzle, login, game_mode, record, currentmoves.ToString());
                for (int i = 0; i < l; i++)
                {
                    bd.insertInPuzzlePiece(i.ToString(), ((Point)((object[])pb[i].Tag)[1]).X.ToString(), ((Point)((object[])pb[i].Tag)[1]).Y.ToString(), id_puzzle);
                    id_piece = bd.selectIDPiece(i.ToString(), id_puzzle);
                    bd.insertInSave(id_piece, id_puzzle, login, pb[i].Location.X.ToString(), pb[i].Location.Y.ToString());
                }
                MessageBox.Show("Игра успешно сохранена!");
            }
        }