public ArrayList searchProduct(ProductEN p) { ArrayList a = new ArrayList(); string s = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ToString(); SqlConnection c = new SqlConnection(s); try { c.Open(); SqlCommand com = new SqlCommand("Select * from Product where Id = " + p.Id, c); SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) { a.Add(dr["Id"].ToString()); } dr.Close(); } catch (Exception ex) { ex.ToString(); Console.WriteLine("ERROR: Show Product"); } finally { c.Close(); } return(a); }
public void deleteProduct(ProductEN p) { string s = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ToString(); SqlConnection c = new SqlConnection(s); try { c.Open(); SqlCommand com = new SqlCommand("Delete From Product Where Id = " + p.Id, c); com.ExecuteNonQuery(); } catch (Exception exc) { exc.ToString(); Console.WriteLine("ERROR: Delete Product"); } finally { c.Close(); } }
public void updateProduct(ProductEN p) { string s = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ToString(); SqlConnection c = new SqlConnection(s); try { c.Open(); SqlCommand com = new SqlCommand("Update Product Set Price = '" + p.Price + "', Company = '" + p.Company + "', Extras ='" + p.Extras + "' Where Id = " + p.Id, c); com.ExecuteNonQuery(); } catch (Exception exc) { exc.ToString(); Console.WriteLine("ERROR: Update Product"); } finally { c.Close(); } }
public void addProduct(ProductEN p) { string s = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ToString(); SqlConnection c = new SqlConnection(s); try { c.Open(); SqlCommand com = new SqlCommand("Insert Into Product (Id,Price,Company,Extras) VALUES ('" + p.Id + "','" + p.Price + "','" + p.Company + "','" + p.Extras + "')", c); com.ExecuteNonQuery(); } catch (Exception exc) { exc.ToString(); Console.WriteLine("ERROR: Add Product"); } finally { c.Close(); } }