Ejemplo n.º 1
0
    public void updateProductPrice(ProductInBag Product)
    {
        OleDbConnection myConn = new OleDbConnection(Connstring.getConnectionString());
        OleDbCommand myCmd;
        OleDbDataAdapter myDataAdapter = new OleDbDataAdapter();
        try
        {
            myCmd = new OleDbCommand("UpdateUnitPrice", myConn);
            myCmd.CommandType = CommandType.StoredProcedure;
            OleDbParameter objParam;

            objParam = myCmd.Parameters.Add("@UnitPrice", OleDbType.Decimal);
            objParam.Direction = ParameterDirection.Input;
            objParam.Value = Product.Price;

            objParam = myCmd.Parameters.Add("@ProductID", OleDbType.Integer);
            objParam.Direction = ParameterDirection.Input;
            objParam.Value = Product.ProdID;

            myConn.Open();
            myCmd.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            myConn.Close();
        }
    }
Ejemplo n.º 2
0
        public ProductInBag(ProductInBag product)
        {
            this.mPrice = product.Price;
            this.mProdID = product.ProdID;
            this.mProdName = product.ProdName;
            //this.ProductIndex = p.ProductIndex;
            this.mQuantity = product.Quantity;
		}
Ejemplo n.º 3
0
 public void DeleteProduct(ProductInBag inProduct)
 {
     //מבטל מוצר מהסל
     int index = SearchProduct(inProduct.ProdID);
     if (index != -1)
     {
         mProducts.RemoveAt(index);
     }
 }
Ejemplo n.º 4
0
    public void UpdateProduct(ProductInBag inProduct)
    {
        //מעדכן כמות של מוצר בסל
        int index = SearchProduct(inProduct.ProdID);
        if (index != -1)
        {

            ((ProductInBag)mProducts[index]).Quantity = inProduct.Quantity;
        }
    }
Ejemplo n.º 5
0
 protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     mShoppingBag = (ShoppingBag)Session["mShoppingBag"];
     ProductInBag product = new ProductInBag();
     GridViewRow row = GridView2.Rows[e.RowIndex];
     product.ProdID = int.Parse(row.Cells[0].Text);
     mShoppingBag.DeleteProduct(product);
     Session["mShoppingBag"] = mShoppingBag;
     GridView2.EditIndex = -1;
     populate_GridView2();
 }
Ejemplo n.º 6
0
 protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     mShoppingBag = (ShoppingBag)Session["mShoppingBag"];
     ProductInBag product = new ProductInBag();
     GridViewRow row = GridView2.Rows[e.RowIndex];
     product.ProdID = int.Parse(row.Cells[0].Text);
     product.Quantity = short.Parse(((TextBox)row.Cells[2].Controls[0]).Text);
     mShoppingBag.UpdateProduct(product);
     Session["mShoppingBag"] = mShoppingBag;
     GridView2.EditIndex = -1;
     populate_GridView2();
 }
Ejemplo n.º 7
0
 // Adds a product to the products list.
 // returns the result of the inserting action (true - everything was alright).
 public void AddProduct(ProductInBag inProduct)
 {
     //מוסיף מוצר לסל .אם קיים כבר בסל מעלה את הכמות ב1  
     int index = SearchProduct(inProduct.ProdID);
     if (index == -1)
     {
         mProducts.Add(inProduct);
     }
     else
     {
         ((ProductInBag)mProducts[index]).Quantity++;
     }
 }
Ejemplo n.º 8
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "AddProduct")
        {
            int index = Convert.ToInt32(e.CommandArgument);
            GridViewRow row = GridView1.Rows[index];

            string productID = row.Cells[0].Text;
            string prodactName = row.Cells[1].Text;
            string price = row.Cells[2].Text;
            ProductInBag newProduct = new ProductInBag(int.Parse(productID), prodactName, decimal.Parse(price), 1);
            mShoppingBag.AddProduct(newProduct);
            Button1.Visible = true;
            Page.Session["mShoppingBag"] = mShoppingBag;
            populate_GridView2();
        }
    }
Ejemplo n.º 9
0
 public void updateProductPrice(ProductInBag Product)
 {
     ProductService product = new ProductService();
     product.updateProductPrice(Product);
     
 }