Exemplo n.º 1
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;
                        }
                    }
                }
            }
        }