コード例 #1
0
        // Add item in purchase item into card .
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Add")
            {
                int rowIndex=Convert.ToInt32(e.CommandArgument);
                int id = Convert.ToInt32(((Label)GridView1.Rows[rowIndex].FindControl("lblid")).Text.Trim());

                var Row = GridView1.Rows[rowIndex];

                Label lblId = (Label)Row.FindControl("lblid");
                Label lblStockId = (Label)Row.FindControl("lblStock");

                ItemCollection itmcol = context.ItemCollections.Where(i => i.Id == id).FirstOrDefault();
                itmcol.Stock = itmcol.Stock - 1;
                context.SaveChanges();

                ItemPurchased itmPur = new ItemPurchased();

                string Cardnumber = Session["CardNumber"].ToString();
                itmPur.CustomerCardId = context.CustomerCards.Where(c => c.CardNumber == Cardnumber).FirstOrDefault().Id;
                itmPur.ItemId = id;

                context.ItemPurchaseds.AddObject(itmPur);
                context.SaveChanges();

                // call the CallUpdate method with parameter lable id and current stock status.
                UpdaterHub.CallUpdate(lblStockId.ClientID, itmcol.Stock.ToString());

                TestServertoClient.DataBind();
                GridView1.DataBind();
            }
        }
コード例 #2
0
 /// <summary>
 /// Create a new ItemPurchased object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="itemId">Initial value of the ItemId property.</param>
 public static ItemPurchased CreateItemPurchased(global::System.Int32 id, global::System.Int32 itemId)
 {
     ItemPurchased itemPurchased = new ItemPurchased();
     itemPurchased.Id = id;
     itemPurchased.ItemId = itemId;
     return itemPurchased;
 }
コード例 #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ItemPurchaseds EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToItemPurchaseds(ItemPurchased itemPurchased)
 {
     base.AddObject("ItemPurchaseds", itemPurchased);
 }