private void выборМакетаToolStripMenuItem_Click(object sender, EventArgs e) { Select_maquette f = new Select_maquette(); if (f.ShowDialog() == DialogResult.OK) { int tt = Convert.ToInt32(f.dataGridView1.SelectedCells[0].RowIndex); int id = Convert.ToInt32(f.dataGridView1[0, tt].Value); Program.Maquette_id = id; Program.Maquette_name = f.dataGridView1[1, tt].Value.ToString(); label2.Text = Program.Maquette_name.ToString(); Diploma.Maquette m = new Diploma.Maquette(); m = m.Select_maquette_id(Program.Maquette_id, Program.connection_str); pictureBox1.Load("Maquette//" + m.Background_image); int k = 0; for (int i = 0; i < comboBox1.Items.Count; i++) { Diploma.Format fff = comboBox1.Items[i] as Diploma.Format; if (fff.id == m.id_fk_format) { k = i; break; } } Load_image_blocks(); Load_text_blocks(); comboBox1.SelectedIndex = k; // comboBox1.SelectedValue = m.id_fk_format; } }
private void выборФонаToolStripMenuItem_Click(object sender, EventArgs e) { Form_maquette_gallery ga = new Form_maquette_gallery(); if (ga.ShowDialog() == DialogResult.OK) { if (ga.radioButton1.Checked) { id_pic = Convert.ToInt32(ga.radioButton1.Text); // pictureBox1.Image = (ga.pictureBox1.Image); } else if (ga.radioButton2.Checked) { id_pic = Convert.ToInt32(ga.radioButton2.Text); // pictureBox1.Image = (ga.pictureBox2.Image); } else if (ga.radioButton3.Checked) { id_pic = Convert.ToInt32(ga.radioButton3.Text); // pictureBox1.Image = (ga.pictureBox3.Image); } 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 k = 0; for (int i = 0; i < comboBox1.Items.Count; i++) { Diploma.Format fff = comboBox1.Items[i] as Diploma.Format; if (fff.id == m.id_fk_format) { k = i; break; } } Load_image_blocks(); Load_text_blocks(); comboBox1.SelectedIndex = k; } // Select_maquette f = new Select_maquette(); // if (f.ShowDialog() == DialogResult.OK) // int tt = Convert.ToInt32(f.dataGridView1.SelectedCells[0].RowIndex); // int id = Convert.ToInt32(f.dataGridView1[0, tt].Value); }
private void Form1_Load(object sender, EventArgs e) { Load_format(); StreamReader f = new StreamReader("Maquette_id.txt"); int a = Convert.ToInt32(f.ReadLine()); Program.Maquette_id = a; // 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 k = 0; for (int i = 0; i < comboBox1.Items.Count; i++) { Diploma.Format fff = comboBox1.Items[i] as Diploma.Format; if (fff.id == m.id_fk_format) { k = i; break; } } Load_image_blocks(); Load_text_blocks(); comboBox1.SelectedIndex = k; if (Program.Maquette_id == 0) { label2.Text = "Макет не выбран!"; } else { label2.Text = m.Name_maquette; } // comboBox1.DisplayMember = "Name_format"; // comboBox1.ValueMember = "id"; //дописать отображение данных в комбобокс }
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; }