Example #1
0
    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");
    }
Example #2
0
    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");
    }
Example #3
0
 private void attach_korpas(korpa entity)
 {
     this.SendPropertyChanging();
     entity.proizvod = this;
 }
Example #4
0
 private void detach_korpas(korpa entity)
 {
     this.SendPropertyChanging();
     entity.proizvod = null;
 }
Example #5
0
 partial void Deletekorpa(korpa instance);
Example #6
0
 partial void Updatekorpa(korpa instance);
Example #7
0
 partial void Insertkorpa(korpa instance);
Example #8
0
 private void detach_korpas(korpa entity)
 {
     this.SendPropertyChanging();
     entity.korisnik = null;
 }
Example #9
0
 private void attach_korpas(korpa entity)
 {
     this.SendPropertyChanging();
     entity.korisnik = this;
 }