예제 #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            List <string[]> path     = bd.selectPathToPicturesByComplexityOrder(comboBox2.SelectedItem.ToString());
            List <string>   id_piece = new List <string>();

            if (listView1.SelectedIndices.Count != 0)
            {
                int    t          = listView1.SelectedIndices[0];
                string id_picture = bd.selectIdByPathPicture(path[t][0]);
                string id_puzzle  = bd.selectPuzzleByIdPuzzleByIdPicture(id_picture);
                id_piece = bd.selectIdPiece(id_puzzle);
                //удалить сначала сейвы с этой картинкой

                bd.deleteSaveByIdPuzzle(id_puzzle);
                bd.deleteGameByIdPuzzle(id_puzzle);
                //bd.deletePuzzle(id_puzzle);
                for (int i = 0; i < id_piece.Count; i++)
                {
                    bd.deletePiecePuzzleByIdPuzzleAndOrIdPuzzle(id_puzzle, id_piece[i]);
                }

                // bd.deletePiecePuzzleByIdPuzzleAndOrIdPicture("", bd.selectIdByPathPicture(path[t][0]));
                //удалить геймы с этой картинкой
                bd.deletePictures(path[t][0]);
                updateListView();
            }
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string formOfPuzzle = "";
            string width        = "";
            string height       = "";
            string complexity   = "";
            string pictureID    = "";
            string pictureID1   = "";

            if (!((radio_triangle.Checked) | (radio_square.Checked)))
            {
                MessageBox.Show("Выберите форму пазла");
            }
            else
            {
                if (radio_square.Checked)
                {
                    formOfPuzzle = "прямоугольник";
                }
                else
                {
                    formOfPuzzle = "треугольник";
                }

                height = numeric_height.Value.ToString();
                width  = numeric_width.Value.ToString();

                if (!((radio_level3.Checked) | (radio_level2.Checked) | (radio_level1.Checked)))
                {
                    MessageBox.Show("Выберите сложность пазла");
                }
                else
                {
                    if (radio_level3.Checked)
                    {
                        complexity = "3";
                    }
                    else if (radio_level2.Checked)
                    {
                        complexity = "2";
                    }
                    else
                    {
                        complexity = "1";
                    }

                    if (text_picture_id.Text.Equals(""))
                    {
                        MessageBox.Show("Выберите картинку");
                    }
                    else
                    {
                        ConnDatabase bd = new ConnDatabase();
                        pictureID  = bd.selectIdByPathPicture(text_picture_id.Text);
                        pictureID1 = bd.cutExcessSpace(pictureID);
                        string puzzleID = bd.insertInPuzzle(complexity, formOfPuzzle, pictureID1, height, width);
                        if (puzzleID.Equals(""))
                        {
                            MessageBox.Show("Не удалось создать такой пазл!");
                        }
                        else
                        {
                            MessageBox.Show("Пазл успешно создан!");
                            numeric_height.Value   = 3;
                            numeric_width.Value    = 3;
                            radio_level1.Checked   = true;
                            radio_level2.Checked   = false;
                            radio_level3.Checked   = false;
                            radio_triangle.Checked = false;
                            radio_square.Checked   = true;
                            text_picture_id.Text   = "";
                            picture_pazzle.Image   = null;
                        }
                    }
                }
            }
        }