Beispiel #1
0
        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);
        }
Beispiel #2
0
        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();
            }
        }
Beispiel #3
0
        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();
            }
        }
Beispiel #4
0
        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();
            }
        }