public void add_image_blocks() { Add_image_blоcks f = new Add_image_blоcks(); if (f.ShowDialog() == DialogResult.OK) { File.Copy(f.label2.Text, "Image_blocks//" + Path.GetFileName(f.label2.Text), true); Diploma.Image_blocks i = new Diploma.Image_blocks(); i.Add_image_blocks(f.textBox1.Text, Path.GetFileName(f.label2.Text), Convert.ToInt32(f.numericUpDown1.Value), Convert.ToInt32(f.numericUpDown2.Value), Convert.ToInt32(f.numericUpDown3.Value), Convert.ToInt32(f.numericUpDown4.Value), Program.Maquette_id, Program.connection_str); MessageBox.Show("Успешно добавлен!"); } Load_image_blocks(); }
private void button_update2_Click(object sender, EventArgs e) { if (dataGridView2.SelectedRows != null) { Add_image_blоcks i = new Add_image_blоcks(); int tt = Convert.ToInt32(dataGridView2.SelectedCells[0].RowIndex); Diploma.Image_blocks f = new Diploma.Image_blocks(); int id = Convert.ToInt32(dataGridView2[0, tt].Value); f = f.Select_image_blocks_id(id, Program.connection_str); i.textBox1.Text = f.Name_blocks; i.numericUpDown1.Value = f.X; i.numericUpDown2.Value = f.Y; i.numericUpDown3.Value = f.Height; i.numericUpDown4.Value = f.Width; i.label2.Text = f.Image_content; i.pictureBox1.Load("Image_blocks//" + f.Image_content); if (i.ShowDialog() == DialogResult.OK) { try { File.Copy(i.label2.Text, "Image_blocks//" + Path.GetFileName(i.label2.Text)); } catch { } f.Update_image_blocks(f.id, i.textBox1.Text, Path.GetFileName(i.label2.Text), Convert.ToInt32(i.numericUpDown1.Value), Convert.ToInt32(i.numericUpDown2.Value), Convert.ToInt32(i.numericUpDown3.Value), Convert.ToInt32(i.numericUpDown4.Value), Program.connection_str); MessageBox.Show("Редактирование успешно!"); } Load_image_blocks(); } }