protected void gvCart_RowDeleting(object sender, GridViewDeleteEventArgs e) { string productId = gvCart.DataKeys[e.RowIndex].Values["IDProizvoda"].ToString(); var p = from k in db.korpas where (k.ID_Proizvoda == Int32.Parse(productId) && k.ID_Korisnika == Int32.Parse(Session["id"].ToString())) select k; korpa cart = p.Single(); if (cart.Kolicina > 1) { cart.Kolicina--; } else { db.korpas.DeleteOnSubmit(cart); } db.SubmitChanges(); Response.Redirect("Korpa.aspx"); }
protected void btnAddToCart_Click(object sender, EventArgs e) { korpa cart = new korpa(); var korpe = from korp in DB.korpas where (korp.ID_Proizvoda == k.First().ID&& korp.ID_Korisnika == Int32.Parse(Session["id"].ToString())) select korp; int quantity = 1; if (korpe.Count() != 0) { korpe.First().Kolicina = korpe.First().Kolicina + 1; } else { cart.ID_Proizvoda = k.First().ID; cart.ID_Korisnika = Int32.Parse(Session["id"].ToString()); cart.Kolicina = quantity; DB.korpas.InsertOnSubmit(cart); } DB.SubmitChanges(); Response.Redirect("Default.aspx"); }
private void attach_korpas(korpa entity) { this.SendPropertyChanging(); entity.proizvod = this; }
private void detach_korpas(korpa entity) { this.SendPropertyChanging(); entity.proizvod = null; }
partial void Deletekorpa(korpa instance);
partial void Updatekorpa(korpa instance);
partial void Insertkorpa(korpa instance);
private void detach_korpas(korpa entity) { this.SendPropertyChanging(); entity.korisnik = null; }
private void attach_korpas(korpa entity) { this.SendPropertyChanging(); entity.korisnik = this; }