protected void rptOrder_ItemCommand(object source, RepeaterCommandEventArgs e) { Label lb = (Label)e.Item.FindControl("lbMaSP"); AccountProduct ac = db.AccountProducts.SingleOrDefault(f => f.AcountName == Session["TaiKhoan"].ToString() && f.ProductID == long.Parse(lb.Text)); db.AccountProducts.DeleteOnSubmit(ac); db.SubmitChanges(); Response.Redirect("/GioHang.aspx"); }
public void GetIdempotentKey_TwoSimilarInstances_ReturnsSameHashCode() { var product1 = new AccountProduct { ProfileNo = 1 }; var product2 = new AccountProduct { ProfileNo = 1 }; Assert.Equal(product1.GetIdempotentKey(), product2.GetIdempotentKey()); }
public void GetIdempotentKey_TwoUnlikeInstances_ReturnsDifferentHashCode() { var product1 = new AccountProduct { ProfileNo = 1 }; var product2 = new AccountProduct { ProfileNo = 2 }; Assert.NotEqual(product1.GetIdempotentKey(), product2.GetIdempotentKey()); }
protected void btnThanhToan_Click(object sender, EventArgs e) { for (int i = 0; i < rptOrder.Items.Count; i++) { TextBox txt = (TextBox)rptOrder.Items[i].FindControl("txtSoLuong"); Label lb = (Label)rptOrder.Items[i].FindControl("lbGiaTien"); Label lbtt = (Label)rptOrder.Items[i].FindControl("lbThanhTien"); if (txt != null) { string thanhtien = (double.Parse(txt.Text.ToString()) * double.Parse(lb.Text.ToString())).ToString(); //string[] mang = { mahang, tenhang, lb.Text, txt.Text.ToString(), thanhtien }; //Label4.Text = tbMatHang.Rows.Count.ToString(); var v = from j in db.AccountProducts select j; bool kt = false; foreach (var item in v) { if (item.AcountName == Session["TaiKhoan"].ToString() && item.ProductID == long.Parse(Request.QueryString["MaHang"].ToString())) { kt = true; break; } } if (kt == true) { AccountProduct ac = db.AccountProducts.SingleOrDefault(s => s.ProductID == long.Parse(Request.QueryString["MaHang"].ToString()) && s.AcountName == Session["TaiKhoan"].ToString()); ac.Date = DateTime.Now; ac.Status = false; ac.Number = int.Parse(txt.Text); db.SubmitChanges(); } else { AccountProduct ac = new AccountProduct(); ac.AcountName = Session["TaiKhoan"].ToString(); //Label3.Text = masp; ac.ProductID = long.Parse(Request.QueryString["MaHang"].ToString()); ac.Date = DateTime.Now; ac.Status = false; ac.Number = int.Parse(txt.Text); db.AccountProducts.InsertOnSubmit(ac); db.SubmitChanges(); } } break; } Response.Redirect("/GioHang.aspx"); }