private void добавитьНовыйФорматToolStripMenuItem_Click(object sender, EventArgs e) { Insert_format fo = new Insert_format(); if (fo.ShowDialog() == DialogResult.OK) { Diploma.Format f = new Diploma.Format(); bool s = f.Add_format(fo.textBox1.Text, Convert.ToInt32(fo.numericUpDown1.Value), Convert.ToInt32(fo.numericUpDown2.Value), Program.connection_str); if (s) { MessageBox.Show("Формат успешно добавлен!"); Load_format(); } else { int k = f.Select_format(Convert.ToInt32(fo.numericUpDown1.Value), Convert.ToInt32(fo.numericUpDown2.Value), Program.connection_str); string d = f.Select_name_format(k, Program.connection_str); MessageBox.Show("Данный формат уже существует под именем " + d); } } }
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; } }
public void Load_format() { comboBox1.DataSource = null; Diploma.Format f = new Diploma.Format(); List <Diploma.Format> n = f.Select_Formats(Program.connection_str); // comboBox1.Items.Add(new Diploma.Format(n[0])); // comboBox1.Items.Add(new Diploma.Format(n[1])); comboBox1.DataSource = n; comboBox1.SelectedIndex = 0; }
private void button1_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows != null) { int tt = Convert.ToInt32(dataGridView1.SelectedCells[0].RowIndex); Diploma.Format f = new Diploma.Format(); int id = Convert.ToInt32(dataGridView1[3, tt].Value); f.Delete_Format(id, Program.connection_str); MessageBox.Show("Удаление успешно!"); Load_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); }
public void Load_Format() { Diploma.Format f = new Diploma.Format(); List <Diploma.Format> n = f.Select_Formats(Program.connection_str); dataGridView1.RowCount = n.Count; for (int i = 0; i < n.Count; i++) { dataGridView1[0, i].Value = n[i].Name_format; dataGridView1[1, i].Value = n[i].Width; dataGridView1[2, i].Value = n[i].Height; dataGridView1[3, i].Value = n[i].id; } }
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 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); } }
private void button2_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows != null) { Insert_format i = new Insert_format(); int tt = Convert.ToInt32(dataGridView1.SelectedCells[0].RowIndex); Diploma.Format f = new Diploma.Format(); int id = Convert.ToInt32(dataGridView1[3, tt].Value); f = f.Select_format_id(id, Program.connection_str); i.textBox1.Text = f.Name_format; i.numericUpDown1.Value = f.Width; i.numericUpDown2.Value = f.Height; if (i.ShowDialog() == DialogResult.OK) { f.Update_format(f.id, i.textBox1.Text, Convert.ToInt32(i.numericUpDown2.Value), Convert.ToInt32(i.numericUpDown1.Value), Program.connection_str); MessageBox.Show("Редактирование успешно!"); } Load_Format(); } }
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; }