protected void rptHampers_ItemCommand(object source, RepeaterCommandEventArgs e) { proxy = new ServiceReference1.ServiceClient(); if (e.CommandName == "UpdateQuantityHamper") { int uID = Convert.ToInt32(Session["UserID"]); int hID = Convert.ToInt32(e.CommandArgument); // Tıkladığımız satırdaki ürünün hamperid'sini çekiyor line = (e.Item.ItemIndex); //Tıkladığımız satırı çekiyoruz. count = Convert.ToInt32(((rptHampers.Items[line].FindControl("txtAdet")) as TextBox).Text); //Tıkladığımız satırdaki ürünün adet sayısını çekiyor int count2 = Convert.ToInt32(((rptHampers.Items[line].FindControl("txtAdetOrj")) as TextBox).Text); //Tıkladığımız satırdaki ürünün adet sayısını çekiyor if (count2 != count) { bool check = proxy.UpdateQuantityHampers(hID, count); var hmp = proxy.GetHampers(uID); rptHampers.DataSource = hmp.ToList(); rptHampers.DataBind(); int countNew = Convert.ToInt32(((rptHampers.Items[line].FindControl("txtAdet")) as TextBox).Text); // Yeni adedi çekiyor //Değişimi kıyaslayıp Bootstrap - Modal Yapısını kullanıyoruz. if (check == true) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", $"alert('Seçtiğiniz ürünün adet sayısı {countNew} olarak güncellendi.')", true); proxy.WriteDebugLogInfo(DateTime.Now.ToString() + " userid = " + Session["UserID"].ToString() + " , hID =" + Convert.ToInt32(e.CommandArgument) + " ürünün adedini " + countNew + " güncelledi."); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Ürünümüzden istediğiniz miktarda bulunmamaktadır. Adet sayısını tekrar giriniz.')", true); } lblTotalPrice.Text = hmp.Sum(x => x.tprice).ToString(); } } if (e.CommandName == "DeleteHamper") //Silme işlemi { int uID = Convert.ToInt32(Session["UserID"]); int hID = Convert.ToInt32(e.CommandArgument); // Tıkladığımız satırdaki ürünün hamperid'sini çekiyor line = (e.Item.ItemIndex); //Tıkladığımız satırı çekiyoruz. count = Convert.ToInt32(((rptHampers.Items[line].FindControl("txtAdet")) as TextBox).Text); //Tıkladığımız satırdaki ürünün adet sayısını çekiyor bool check = proxy.DeleteHampers(hID, uID); //Fonksiyon çalışıyor var hmp = proxy.GetHampers(uID); //Fonksiyon çalışıyor rptHampers.DataSource = hmp.ToList(); rptHampers.DataBind(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Seçtiğiniz ürün sepetinizden çıkarılmıştır.')", true); proxy.WriteDebugLogInfo(DateTime.Now.ToString() + " userid = " + Session["UserID"].ToString() + " , hID =" + Convert.ToInt32(e.CommandArgument) + " ürünü sepetinden çıkardı."); lblTotalPrice.Text = hmp.Sum(x => x.tprice).ToString(); // Yukarıdaki satırda: Modal Yapısının gerçekleşmesini sağlayan Script fonksiyonuna değişken yolluyoruz. } }
protected void cksYap_ServerClick(object sender, EventArgs e) { proxy = new ServiceReference1.ServiceClient(); proxy.WriteDebugLogInfo(DateTime.Now.ToString() + " userid = " + Session["UserID"].ToString() + " , oturumunu sonlandırdı."); Session.Abandon(); Response.Redirect("Login.aspx"); }
protected void btnLogin_Click(object sender, EventArgs e) { // KULLANICI KAYDINI SORGULUYOR try { proxy = new ServiceReference1.ServiceClient(); users currentuser = proxy.Login(TextBox1.Text, TextBox2.Text); if (currentuser == null) // KULLANICI YOKSA UYARI VERİYOR. { lblResult.Text = "Kullanıcı adı veya şifre hatalı.Lütfen tekrar deneyiniz."; ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "MyopenModal", "openModal();", true); proxy.WriteDebugLogError(DateTime.Now.ToString() + " " + TextBox1.Text + " mail adresi ile hatalı giriş yapılmıştır"); } else if (currentuser.roleid == 1 || currentuser.roleid == 2 || currentuser.roleid == 3) // KAYIT OLURKEN roleid GİRİLMİŞ Mİ DİYE KONTROL EDİYOR. { Session["UserID"] = currentuser.userid; Session["User"] = currentuser.name.ToString() + " " + currentuser.surname.ToString(); if (currentuser.roleid == 1) { Session["Role"] = "Admin"; Session["RoleID"] = 1; } else if (currentuser.roleid == 2) { Session["Role"] = "Müşteri"; Session["RoleID"] = 2; } else { Session["Role"] = "Satıcı"; Session["RoleID"] = 3; } proxy.WriteDebugLogInfo(DateTime.Now.ToString() + " userid = " + Session["UserID"].ToString() + " , oturum açtı."); if (Session["referer"] != null) { Response.Redirect(Session["referer"].ToString()); } Response.Redirect("HomePage.aspx"); } else { Session["UserID"] = currentuser.userid; proxy.WriteDebugLogError(DateTime.Now.ToString() + " userid = " + Session["UserID"].ToString() + " , rol atanmamıştır."); } } catch (Exception) { // throw ex; } }
protected void rptProduct_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "AddHamper") // Ekleme işlemi { try { proxy = new ServiceReference1.ServiceClient(); int line = (e.Item.ItemIndex); // Tıkladığımız satırı çekiyoruz. int count = Convert.ToInt32(((rptProduct.Items[line].FindControl("txtAdet")) as TextBox).Text); // Kullanıcın seçtiği adeti algılıyoruz. if (count < 1 || count == 0) { count = 1; } // Eğer kişi kendi isteğiyle ürün adedini 1'in altında seçmesi durumunda; seçilen ürün adedi otomatik olarak 1 algılanır. ServiceReference1.hampers objcust = new ServiceReference1.hampers() { userid = Convert.ToInt32(Session["UserID"]), productid = Convert.ToInt32(e.CommandArgument), quantity = count, date = DateTime.Now }; Boolean control = proxy.UpdateHampers(objcust); var result = proxy.GetProduct(); rptProduct.DataSource = result.Where(x => x.stoch > 0).ToList(); rptProduct.DataBind(); //Pop-Up if (control == true) { // olumlu sonuç ürünün stoklarımızda mevcut olduğunu ve seçimin onaylandığını gösteriyor. ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", $"alert('Sepete {count} adet ürün eklendi.')", true); proxy.WriteDebugLogInfo(DateTime.Now.ToString() + " userid = " + Session["UserID"].ToString() + " , pid =" + Convert.ToInt32(e.CommandArgument) + " üründen " + count + " adet sepete ekledi."); } else // stoklar yetersiz { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('İsteğinizi şuanda gerçekleştiremiyoruz.Lütfen seçtiğiniz ürünün adedini düşürünüz.')", true); } } catch (Exception) { Response.Write("Sepete Eklenemedi"); } } }