protected void orderGridView_RowUpdating(object sender, GridViewUpdateEventArgs e) { if (ViewState["listOrder_Received"] != null) { listOrder_Received = (List <Order_Received>)ViewState["listOrder_Received"]; } Order_Received order = listOrder_Received.ElementAt(e.RowIndex); //Response.Write(e.NewValues["Quantity"]); order.Quantity = Convert.ToInt32(e.NewValues["Quantity"]); order.SubTotal = order.Quantity * order.Price; orderGridView.EditIndex = -1; this.BindGrid(); }
private void Image_Click(object sender, ImageClickEventArgs e) { if (ViewState["listOrder_Received"] != null) { listOrder_Received = (List <Order_Received>)ViewState["listOrder_Received"]; } POSDBDataContext DB = new POSDBDataContext(Cache["ConnectionString"].ToString()); ImageButton image = sender as ImageButton; int productID = int.Parse(image.ID); bool flag = false; if (listOrder_Received.Count > 0) { foreach (var item in listOrder_Received) { if (item.Product_ID == productID) { item.Quantity++; item.SubTotal = item.Quantity * item.Price; // flag = true; break; } } } if (flag == false) { var product = (from ee in DB.Products where ee.Status.Equals(true) && ee.ID == productID select ee).FirstOrDefault(); //Order_Detail orderDetails = new Order_Detail() { Product = product, Quantity =1 }; int serial = (int)ViewState["orderSerial"]; ViewState["orderSerial"] = ++serial; Order_Received obj = new Order_Received() { Price = (double)product.Sale_Price, Product_ID = product.ID, Name = product.Name, SL = serial, Quantity = 1, SubTotal = (double)product.Sale_Price }; listOrder_Received.Add(obj); } //Response.Write(listOrder_Received.Count); ViewState["listOrder_Received"] = listOrder_Received; BindGrid(); }