예제 #1
0
    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        kullaniciid = Convert.ToInt16(Session["ID"]);
        int urunid = Convert.ToInt16(e.CommandArgument);
        pcompone_1453Entities3 db = new pcompone_1453Entities3();

        //int urunid = Convert.ToInt32(((LinkButton)e.Item.FindControl("lnkislem")).CommandName);

        if (e.CommandName.ToString() == "btnislem")
        {
            FavoriUrunler fav = (from i in db.FavoriUrunler
                                 where (i.urunID == urunid) && (i.kullaniciID == kullaniciid)
                                 select i).FirstOrDefault <FavoriUrunler>();

            db.FavoriUrunler.DeleteObject(fav);

            db.SaveChanges();
            doldur();
            //Response.Write("satinalinan.aspx?kullaniciid=" + kullaniciid + "");
        }
    }
예제 #2
0
    protected void btn_begen_Click(object sender, EventArgs e)
    {
        kullaniciid = Convert.ToInt16(Session["ID"]);

        UrunID = Convert.ToInt32(Request.QueryString["urunid"]);
        pcompone_1453Entities3 db = new pcompone_1453Entities3();
        Urunler urun = (from i in db.Urunler
                        where (i.urun_id == UrunID)
                        select i).FirstOrDefault <Urunler>();


        var sorgu = from a in db.Kullanici
                    where (a.kullanici_id == kullaniciid)
                    select a;

        if (sorgu.Count() != 0)
        {
            int ht    = Convert.ToInt32(urun.hit);
            int sonuc = ht + 1;
            urun.hit = sonuc;
            db.SaveChanges();


            pcompone_1453Entities3 aa      = new pcompone_1453Entities3();
            FavoriUrunler          favurun = new FavoriUrunler();
            favurun.urunID      = UrunID;
            favurun.kullaniciID = kullaniciid;
            favurun.datetime    = DateTime.Now;
            aa.FavoriUrunler.AddObject(favurun);
            aa.SaveChanges();

            Response.Redirect("urundetay.aspx?urunid=" + urun.urun_id + "");
        }

        else if (sorgu.Count() == 0)
        {
            Response.Write("<script lang='JavaScript'> alert ('Lütfen giriş yapın veya üye olun');</script>");
        }
    }