private void btnEqui_update_Click(object sender, EventArgs e) { if (validateInvUpdate_Equipment()) { Buisness_Logic.repairableItem_repository rirepo = new Buisness_Logic.repairableItem_repository(); Buisness_Logic.repairablerable_Items prd = new Buisness_Logic.repairablerable_Items(); prd.name = txtEqui_name.Text; prd.make = txtEqui_make.Text; prd.model = txtEqui_Model.Text; prd.price = double.Parse(txtEqui_price.Text); prd.invID = int.Parse(txtEqui_code.Text); MemoryStream ms = new MemoryStream(); pictureBoxEqui.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] photo_prod = ms.ToArray(); prd.photo = photo_prod; if (rirepo.update_Equipments(prd)) { MessageBox.Show("Record update succesfull.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void btnEqui_search_Click(object sender, EventArgs e) { if (validateRepItem_search()) { Buisness_Logic.repairablerable_Items prd = new Buisness_Logic.repairablerable_Items(); Buisness_Logic.repairableItem_repository rirep = new Buisness_Logic.repairableItem_repository(); bool x = rirep.searchEqui_Items((string.IsNullOrEmpty(txtEqui_code.Text) ? 0 : int.Parse(txtEqui_code.Text)), txtEqui_name.Text.ToString(), prd); if (x) { MessageBox.Show("Record found.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); txtEqui_name.Text = prd.name; txtEqui_price.Text = prd.price.ToString(); txtEqui_make.Text = prd.make.ToString(); txtEqui_Model.Text = prd.model; txtEqui_code.Text = prd.invID.ToString(); pictureBoxEqui.SizeMode = PictureBoxSizeMode.StretchImage; MemoryStream ms = new MemoryStream(prd.photo); ms.Read(prd.photo, 0, prd.photo.Length); pictureBoxEqui.Image = Image.FromStream(ms); } else { MessageBox.Show("No record found.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public bool searchEqui_Items(int id, string pname, Buisness_Logic.repairablerable_Items prd) { // Buisness_Logic.product prd = new Buisness_Logic.product(); bool temp = false; DataLayer.dbConnect con = new DataLayer.dbConnect(); con.openConnection(); try { string qr = "select * from view_repairItemsSet where inventoryID=@id or name=@name"; SqlCommand cmd = new SqlCommand(qr, con.getConnection()); cmd.Parameters.AddWithValue("@id", id); cmd.Parameters.AddWithValue("@name", pname); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { prd.invID = (int)dt.Rows[0]["inventoryID"]; prd.name = dt.Rows[0]["name"].ToString(); prd.make = dt.Rows[0]["make"].ToString(); prd.price = (double)dt.Rows[0]["price"]; prd.model = dt.Rows[0]["model"].ToString(); prd.photo = (byte[])dt.Rows[0]["photo"]; temp = true; } } catch (Exception pt) { throw; } if (temp == true) { return(true); } else { return(false); } }
public bool update_Equipments(Buisness_Logic.repairablerable_Items prd) { DataLayer.dbConnect con = new DataLayer.dbConnect(); con.openConnection(); bool temp = false; try { string qry1 = "update tbl_inventory set name=@name,make=@make,model=@model,price=@price,photo=@photo where invID=@id"; SqlCommand cmd = new SqlCommand(qry1, con.getConnection()); cmd.Parameters.AddWithValue("@name", prd.name); cmd.Parameters.AddWithValue("@make", prd.make); cmd.Parameters.AddWithValue("@model", prd.model); cmd.Parameters.AddWithValue("@price", prd.price); cmd.Parameters.AddWithValue("@photo", prd.photo); cmd.Parameters.AddWithValue("@id", prd.invID); cmd.ExecuteNonQuery(); temp = true; con.closeConnection(); } catch (Exception dsa) { throw; } if (temp == true) { return(true); } else { return(false); } }
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; } } }