private void button1_Click(object sender, EventArgs e) { AddItemForm frm = new AddItemForm(); int iID = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString()); Entity.Item item1 = services.GetItemByID(iID); frm.typecombo.Text = item1.getType(); frm.dateTime.Value = item1.getDate(); frm.locationtext.Text = item1.getLocation(); frm.descriptiontext.Text = item1.getDescription(); /*MemoryStream ms = new MemoryStream(item1.getImage()); * frm.pictureBox.Image = Image.FromStream(ms);*/ frm.browsebutton.Enabled = false; frm.addbutton.Enabled = false; frm.ShowDialog(); }
public void AddItem(Entity.Item item1) { try { cmd = new SqlCommand( "insert into Masro2.dbo.Item (UserName,Type,Location,Date,Image,Description) values ('" + Program.username + "','" + item1.getType() + "','" + item1.getLocation() + "','" + item1.getDate() + "','" + item1.getImage() + "','" + item1.getDescription() + "')", cn); cn.Open(); cmd.ExecuteNonQuery(); } catch (SqlException ex) { // } finally { cn.Close(); } }