private void GetComputerInfo(string s) { try { var name = tName.Text.Trim(); var price = int.Parse(tPrice.Text.Trim()); var piece = int.Parse(tPiece.Text.Trim()); var date = tDate.Text.Trim(); var brand = tBrand.Text.Trim(); var gpu = tGPU.Text.Trim(); var cpu = tCPU.Text.Trim(); var ram = int.Parse(tRAM.Text.Trim()); var ss = float.Parse(tSS.Text.Trim()); var os = tOS.Text.Trim(); var fs = new FileStream(imgLoc, FileMode.Open, FileAccess.Read); var br = new BinaryReader(fs); img = br.ReadBytes((int)fs.Length); switch (s) { case "add": { var result = _comp.GetByName(name, "Computers"); if (result.Rows.Count > 0) { lberror.ForeColor = Color.Red; lberror.Text = CommonFunctions.ReturnString("exist"); } else { _comp.Add(name, gpu, price, piece, date, brand, cpu, ram, ss, os); _product.AddImage(int.Parse(_product.GetByName(name, "Computers").Rows[0][0].ToString()), img, "Computers"); lberror.ForeColor = Color.Green; lberror.Text = CommonFunctions.ReturnString("success"); } break; } case "update": { var id = int.Parse(tID.Text.Trim()); _comp.Update(id, name, gpu, price, piece, date, brand, cpu, ram, ss, os); _comp.AddImage(id, img, "Computers"); break; } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }