protected void btnUpdateCart_OnClick(object sender, EventArgs e) { foreach (RepeaterItem rptCartDetShpItem in rptCartDetShp.Items) { Repeater rptCartDetCart = (Repeater)rptCartDetShpItem.FindControl("rptCartDetCart"); foreach (RepeaterItem rptCartDetItem in rptCartDetCart.Items) { HiddenField hdfPrimaryKeys = (HiddenField)rptCartDetItem.FindControl("hdfPrimaryKeys"); string[] key = hdfPrimaryKeys.Value.Split(','); CartDet obj = MyLibrary.CartDet_BUS.GetAll().FirstOrDefault(m => m.CartId + "" == key[0] && m.ShpId + "" == key[1] && m.ProId + "" == key[2] && m.ColorId + "" == key[3] && m.SizeId + "" == key[4] ); TextBox qty = (TextBox)rptCartDetItem.FindControl("txtQty"); if (obj != null) { obj.Qty = Convert.ToInt32(qty.Text); MyLibrary.CartDet_BUS.Update(obj); } } } }
protected void btnAddCart_OnClick(object sender, EventArgs e) { int colorId = 0; int sizeId = 0; foreach (RepeaterItem item in rptProColor.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { var rdbColor = (RadioButton)item.FindControl("rdbColor"); if (rdbColor.Checked) { colorId = System.Convert.ToInt32(((HiddenField)item.FindControl("hdfColorId")).Value); } } } foreach (RepeaterItem item in rptProSize.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { var rdbSize = (RadioButton)item.FindControl("rdbSize"); if (rdbSize.Checked) { sizeId = System.Convert.ToInt32(((HiddenField)item.FindControl("hdfSizeId")).Value); } } } _cartDetView = new CartDet() { CartId = MyLibrary.Cart_BUS.GetMyCart().CartId, ShpId = _proDetView.ShpId, ProId = _proDetView.ProId, ColorId = colorId, SizeId = sizeId, Qty = System.Convert.ToInt32(product_quantity.Value) }; if (!MyLibrary.CartDet_BUS.IsExist(_cartDetView)) { MyLibrary.CartDet_BUS.Insert(_cartDetView); Master.LoadCartPreview(); } else { } }