private void btnsave_Int1_Click(object sender, EventArgs e) { if (validateInvAdd()) { try { Buisness_Logic.inventory inv = new Buisness_Logic.inventory(); if (radio_nonRep.Checked) { Buisness_Logic.nonRepairable_Item nr = new Buisness_Logic.nonRepairable_Item(); //initialize image MemoryStream memt1p1 = new MemoryStream(); pictureBox_i2.Image.Save(memt1p1, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] photo_inv = memt1p1.ToArray(); nr.name = txtI1_iname.Text; nr.make = txtI1_imake.Text; nr.model = txtI1_imodel.Text; nr.price = double.Parse(txtI1_iprice.Text); nr.qty = int.Parse(txtInv_1qty.Text); nr.weight = double.Parse(txtInv1Weight.Text); nr.photo = photo_inv; Buisness_Logic.nonRepairableItem_repository nrir = new Buisness_Logic.nonRepairableItem_repository(); if (nrir.addNonRepairabItems(nr)) { MessageBox.Show("Success", "Data Insertion", MessageBoxButtons.OK, MessageBoxIcon.Information); txtI1_icode.Text = nr.invID.ToString(); } else { MessageBox.Show("Data insertion failed.", "Data Insertion", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (radio_repItems.Checked) { Buisness_Logic.repairablerable_Items repi = new Buisness_Logic.repairablerable_Items(); MemoryStream memt1p1 = new MemoryStream(); pictureBox_i2.Image.Save(memt1p1, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] photo_inv = memt1p1.ToArray(); repi.name = txtI1_iname.Text; repi.make = txtI1_imake.Text; repi.model = txtI1_imodel.Text; repi.price = double.Parse(txtI1_iprice.Text); repi.photo = photo_inv; Buisness_Logic.repairableItem_repository repirep = new Buisness_Logic.repairableItem_repository(); if (repirep.addRepItems(repi)) { MessageBox.Show("Success", "Data Insertion", MessageBoxButtons.OK, MessageBoxIcon.Information); txtI1_icode.Text = repi.invID.ToString(); } else { MessageBox.Show("Data insertion failed.", "Data Insertion", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Select either Repair or non Repair button.", "Caution", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception EX) { MessageBox.Show(EX.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } } }