Beispiel #1
0
        private void добавлениеФонаToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form_add_maquette add = new Form_add_maquette();

            add.comboBox1.DataSource = null;
            Diploma.Format        fd = new Diploma.Format();
            List <Diploma.Format> n  = fd.Select_Formats(Program.connection_str);


            // comboBox1.Items.Add(new Diploma.Format(n[0]));
            //  comboBox1.Items.Add(new Diploma.Format(n[1]));
            add.comboBox1.DataSource    = n;
            add.comboBox1.SelectedIndex = 0;
            if (add.ShowDialog() == DialogResult.OK)
            {
                File.Copy(add.label2.Text, "Maquette//" + Path.GetFileName(add.label2.Text), true);
                Diploma.Maquette ma = new Diploma.Maquette();
                int id = (add.comboBox1.Items[add.comboBox1.SelectedIndex] as Diploma.Format).id;
                ma.Add_maquette(add.textBox1.Text, Path.GetFileName(add.label2.Text), add.pictureBox2.BackColor.ToString(), Convert.ToInt32(add.numericUpDown1.Value), Convert.ToInt32(add.numericUpDown2.Value), id, Program.connection_str);
            }
        }
Beispiel #2
0
        private void редактированиеМакетаToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form_add_maquette i = new Form_add_maquette();

            i.comboBox1.DataSource = null;
            Diploma.Format        fd = new Diploma.Format();
            List <Diploma.Format> n  = fd.Select_Formats(Program.connection_str);


            // comboBox1.Items.Add(new Diploma.Format(n[0]));
            //  comboBox1.Items.Add(new Diploma.Format(n[1]));
            i.comboBox1.DataSource    = n;
            i.comboBox1.SelectedIndex = 0;

            Diploma.Maquette f = new Diploma.Maquette();
            int id             = Program.Maquette_id;

            f = f.Select_maquette_id(id, Program.connection_str);
            i.textBox1.Text        = f.Name_maquette;
            i.numericUpDown1.Value = f.Height;
            i.numericUpDown2.Value = f.Width;
            i.label2.Text          = f.Background_image;
            int k = 0;

            for (int j = 0; j < i.comboBox1.Items.Count; j++)
            {
                Diploma.Format fff = i.comboBox1.Items[j] as Diploma.Format;
                if (fff.id == f.id_fk_format)
                {
                    k = j;
                    break;
                }
            }

            i.comboBox1.SelectedIndex = k;

            string          str    = "Color [A=255, R=230, G=200, B=231]";
            MatchCollection p      = Regex.Matches(str, @"(?<=[ARGB]\=)(\d+)");
            Color           color1 = Color.FromArgb(int.Parse(p[0].Value),
                                                    int.Parse(p[1].Value), int.Parse(p[2].Value), int.Parse(p[3].Value));
            Color color2 = Color.FromName(f.Background_color);

            if (color1 != null)
            {
                i.pictureBox2.BackColor = color1;
            }
            else if (color2 != null)
            {
                i.pictureBox2.BackColor = color2;
            }

            // System.Drawing.Color cl = new System.Drawing.Color();

            // i.pictureBox1.BackColor = new System.Drawing.Color();
            i.pictureBox1.Load("Maquette//" + f.Background_image);

            if (i.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    File.Copy(i.label2.Text, "Maquette//" + Path.GetFileName(i.label2.Text));
                }
                catch
                {
                }
                int id_f = (i.comboBox1.Items[i.comboBox1.SelectedIndex] as Diploma.Format).id;
                f.Update_maquette(Program.Maquette_id, i.textBox1.Text, Path.GetFileName(i.label2.Text), i.pictureBox2.BackColor.ToString(),
                                  Convert.ToInt32(i.numericUpDown1.Value), Convert.ToInt32(i.numericUpDown2.Value), id_f, Program.connection_str);

                MessageBox.Show("Редактирование успешно!");
            }

            Program.Maquette_id = id_pic;
            // Diploma.Maquette l = new Diploma.Maquette();
            // Program.Maquette_name = f.dataGridView1[1, tt].Value.ToString();


            Diploma.Maquette m = new Diploma.Maquette();
            m           = m.Select_maquette_id(Program.Maquette_id, Program.connection_str);
            label2.Text = m.Name_maquette;
            pictureBox1.Load("Maquette//" + m.Background_image);
            int k2 = 0;

            for (int i2 = 0; i2 < comboBox1.Items.Count; i2++)
            {
                Diploma.Format fff = comboBox1.Items[i2] as Diploma.Format;
                if (fff.id == m.id_fk_format)
                {
                    k2 = i2;
                    break;
                }
            }
            Load_image_blocks();
            Load_text_blocks();
            comboBox1.SelectedIndex = k2;
        }