public static void Begen(string urunid, string uyeid) { ModalDataContext data = new ModalDataContext(); try { int urun_id = Int32.Parse(urunid), uye_id = Int32.Parse(uyeid); UrunPuan urunPuan = data.UrunPuans.FirstOrDefault(up => up.UyeID == uye_id && up.UrunID == urun_id); if (urunPuan != null) { urunPuan.Begeni = true; data.SubmitChanges(); } else { urunPuan = new UrunPuan(); urunPuan.UrunID = urun_id; urunPuan.UyeID = uye_id; urunPuan.Begeni = true; urunPuan.FiyatPuani = -1; urunPuan.DegerPuani = -1; urunPuan.KalitePuani = -1; urunPuan.Yorum = ""; urunPuan.Baslik = ""; data.UrunPuans.InsertOnSubmit(urunPuan); data.SubmitChanges(); } } catch { } }
private void Button_send_comment_ServerClick(object sender, EventArgs e) { ModalDataContext data = new ModalDataContext(); int blog_id = -1; if (Request.QueryString["BlogId"] != null) { string blog_id_str = Request.QueryString["BlogId"].ToString(); if (Int32.TryParse(blog_id_str, out blog_id)) { if (Session["UyeID"] != null) { string uyeid_str = Session["UyeID"].ToString(); int uyeid = -1; if (Int32.TryParse(uyeid_str, out uyeid)) { Uye uye = data.Uyes.FirstOrDefault(u => u.UyeID == uyeid); if (uye != null) { BlogYorum by = new BlogYorum(); by.UyeID = uye.UyeID; by.Onaylanma = false; by.BlogID = blog_id; by.Tarih = DateTime.Now; by.Yorum = txtComment.Text; data.BlogYorums.InsertOnSubmit(by); data.SubmitChanges(); } } } } } }
protected void btnSil_Click(object sender, EventArgs e) { string _id = ""; if (Request.QueryString["UrunID"] != null) { _id = Request.QueryString["UrunID"].ToString(); int id = -1; if (Int32.TryParse(_id, out id)) { ModalDataContext data = new ModalDataContext(); Urun urun = data.Uruns.FirstOrDefault(u => u.UrunID == id); if (urun != null) { int faturalar = data.FaturaDetays.Where(fd => fd.UrunId == id).Count(); if (faturalar == 0) { data.UrunGorselis.DeleteAllOnSubmit(data.UrunGorselis.Where(ug => ug.UrunID == id)); data.UrunPuans.DeleteAllOnSubmit(data.UrunPuans.Where(up => up.UrunID == id)); data.RenkvsUruns.DeleteAllOnSubmit(data.RenkvsUruns.Where(ru => ru.UrunID == id)); data.UrunTags.DeleteAllOnSubmit(data.UrunTags.Where(ut => ut.UrunID == id)); data.BedenvsUruns.DeleteAllOnSubmit(data.BedenvsUruns.Where(bu => bu.UrunID == id)); data.OneCikanUrunlers.DeleteAllOnSubmit(data.OneCikanUrunlers.Where(ocu => ocu.UrunID == id)); data.Uruns.DeleteOnSubmit(urun); data.SubmitChanges(); } else { lblError.Text = "Faturalandırılmış bir ürünü silemezsiniz"; } } } } }
public static void AdresDegistir(string uyeid, string yeniadres) { ModalDataContext data = new ModalDataContext(); int uye_id = -1; if (Int32.TryParse(uyeid, out uye_id)) { Musteri musteri = data.Musteris.FirstOrDefault(m => m.TcKimlik == data.Uyes.FirstOrDefault(u => u.UyeID == uye_id).TcKimlik); musteri.Adres = yeniadres; data.SubmitChanges(); } }
protected void btnFaturaKaydet_Click(object sender, EventArgs e) { ModalDataContext data = new ModalDataContext(); try { string uye_id = (Session["UyeID"] == null ? null : Session["UyeID"].ToString()); string tc_kimlik = null; if (uye_id != null) // Kayıtlı üye olarak { Uye kayitli_uye = data.Uyes.FirstOrDefault(u => u.UyeID.ToString() == uye_id); if (kayitli_uye != null) { string ad_soyad = kayitli_uye.AdSoyad; string[] ad__soyad = ad_soyad.Split(' '); string soyad = ad__soyad[ad__soyad.Length - 1]; txtLastName.Text = soyad; txtLastName.ReadOnly = true; txtFirstName.Text = ad_soyad.Replace(" " + soyad, ""); txtFirstName.ReadOnly = true; txtEmailBilling.Text = kayitli_uye.Mail; txtTCKimlik.Text = kayitli_uye.TcKimlik; txtTCKimlik.ReadOnly = true; tc_kimlik = kayitli_uye.TcKimlik; } else { Response.Write("<script>Oturumunuzun açık olduğundan emin olun</script>"); return; } } else // Misafir Olarak { tc_kimlik = txtTCKimlik.Text; Musteri misafir_musteri = data.Musteris.FirstOrDefault(m => m.TcKimlik == tc_kimlik); if (misafir_musteri != null) { Uye misafir_uye = data.Uyes.FirstOrDefault(u => u.TcKimlik == tc_kimlik); if (misafir_uye == null) { Response.Write("<script>Misafir üye bilgisi bulunamadı</script>"); return; } else { if (!misafir_uye.KullaniciAdi.Contains("_misafir")) { Response.Write("<script>Girilen tc kimlik numarası kayıtlıdır</script>"); return; } } } else { misafir_musteri = new Musteri(); misafir_musteri.Adres = txtAddress1.Text + " " + txtAddress2.Text; misafir_musteri.Telefon = txtTelephone.Text; misafir_musteri.TcKimlik = tc_kimlik; misafir_musteri.AdSoyad = txtFirstName.Text + " " + txtLastName.Text; misafir_musteri.Kurum = txtCompany.Text; misafir_musteri.Email = txtEmailBilling.Text; data.Musteris.InsertOnSubmit(misafir_musteri); Uye misafir_uye = new Uye(); misafir_uye.TcKimlik = tc_kimlik; misafir_uye.AdSoyad = txtFirstName.Text + " " + txtLastName.Text; misafir_uye.KullaniciAdi = "_misafir" + misafir_musteri.TcKimlik; misafir_uye.Mail = txtEmailBilling.Text; data.Uyes.InsertOnSubmit(misafir_uye); } } DataTable sepet = new DataTable(); sepet = (DataTable)HttpContext.Current.Session["sepet"]; if (sepet != null) { Fatura yeniFatura = new Fatura(); yeniFatura.TcKimlik = tc_kimlik; yeniFatura.KargoID = int.Parse(ddlKargo.SelectedValue); yeniFatura.Tarih = DateTime.Now; yeniFatura.OdemeSekli = "Kredi Kartı"; yeniFatura.KdvOrani = 0.08f; data.Faturas.InsertOnSubmit(yeniFatura); data.SubmitChanges(); for (int i = 0; i < sepet.Rows.Count; i++) { FaturaDetay yeniDetay = new FaturaDetay(); yeniDetay.FaturaID = yeniFatura.FaturaID; yeniDetay.UrunId = Convert.ToInt32(sepet.Rows[i]["UrunID"]); yeniDetay.Miktar = Convert.ToInt32(sepet.Rows[i]["Miktar"]); data.FaturaDetays.InsertOnSubmit(yeniDetay); } data.SubmitChanges(); HttpContext.Current.Session["sepet"] = null; } else { Response.Write("<script>Sepetiniz boş</script>"); return; } } catch { Response.Write("<script>Bir hata oluştu</script>"); return; } Response.Redirect("Checkout.aspx"); }
protected void btnKaydet_Click(object sender, EventArgs e) { try { ModalDataContext data = new ModalDataContext(); Urun yeniUrun = new Urun(); yeniUrun.UrunAdi = txtUrunAdi.Text; yeniUrun.Aciklama = txtAciklama.Text; yeniUrun.BirimFiyat = Convert.ToDecimal(txtFiyat.Text); yeniUrun.DepoyaGirenMiktar = Convert.ToInt32(txtMiktar.Text); yeniUrun.KullanilanMiktar = 0; yeniUrun.BitisSuresi = cldBitisTarihi.SelectedDate; yeniUrun.Begeniler = 0; yeniUrun.GoruntulenmeSayisi = 0; yeniUrun.MarkaID = Convert.ToInt32(ddlMarkalar.SelectedValue); yeniUrun.GrupID = Convert.ToInt32(ddlUrunGrubu.SelectedValue); yeniUrun.Tarih = DateTime.Now; data.Uruns.InsertOnSubmit(yeniUrun); data.SubmitChanges(); List <RenkvsUrun> yeniUrunRenkleri = new List <RenkvsUrun>(); int i = 0, c = blRenkler.Items.Count; while (i < c) { RenkvsUrun yeniUrunRenk = new RenkvsUrun(); yeniUrunRenk.RenkID = Convert.ToInt32(blRenkler.Items[i].Value); yeniUrunRenk.UrunID = yeniUrun.UrunID; yeniUrunRenkleri.Add(yeniUrunRenk); i++; } var recUR = (from ur in yeniUrunRenkleri select ur); data.RenkvsUruns.InsertAllOnSubmit(yeniUrunRenkleri); List <BedenvsUrun> yeniUrunBedenleri = new List <BedenvsUrun>(); i = 0; c = blBedenler.Items.Count; while (i < c) { BedenvsUrun yeniUrunBeden = new BedenvsUrun(); yeniUrunBeden.BedenID = Convert.ToInt32(blBedenler.Items[i].Value); yeniUrunBeden.UrunID = yeniUrun.UrunID; yeniUrunBedenleri.Add(yeniUrunBeden); i++; } var recUB = (from ub in yeniUrunBedenleri select ub); data.BedenvsUruns.InsertAllOnSubmit(recUB); DataTable dtG = new DataTable(); if (Session["YuklenenGorseller"] == null) { dtG = new DataTable(); dtG.Columns.Add("GorselAdres"); } else { dtG = (DataTable)Session["YuklenenGorseller"]; } List <UrunGorseli> yeniUrunGorselleri = new List <UrunGorseli>(); i = 0; c = dtG.Rows.Count; while (i < c) { UrunGorseli yeniUrunGorseli = new UrunGorseli(); yeniUrunGorseli.GorselAdres = dtG.Rows[i]["GorselAdres"].ToString(); yeniUrunGorseli.UrunID = yeniUrun.UrunID; yeniUrunGorselleri.Add(yeniUrunGorseli); i++; } var recUG = (from ug in yeniUrunGorselleri select ug); data.UrunGorselis.InsertAllOnSubmit(recUG); data.SubmitChanges(); Session["YuklenenGorseller"] = null; blBedenler.Items.Clear(); blRenkler.Items.Clear(); txtAciklama.Text = ""; txtFiyat.Text = ""; txtMiktar.Text = ""; txtUrunAdi.Text = ""; } catch { lblError.Text = "Bir hata oluştu"; } }
protected void btnKaydet_Click(object sender, EventArgs e) { try { string _id = ""; if (Request.QueryString["UrunID"] != null) { _id = Request.QueryString["UrunID"].ToString(); int id = -1; if (Int32.TryParse(_id, out id)) { ModalDataContext data = new ModalDataContext(); Urun yeniUrun = data.Uruns.FirstOrDefault(u => u.UrunID == id); if (yeniUrun != null) { yeniUrun.UrunAdi = txtUrunAdi.Text; yeniUrun.Aciklama = txtAciklama.Text; yeniUrun.BirimFiyat = Convert.ToDecimal(txtFiyat.Text); yeniUrun.DepoyaGirenMiktar = Convert.ToInt32(txtMiktar.Text); yeniUrun.KullanilanMiktar = 0; yeniUrun.BitisSuresi = cldBitisTarihi.SelectedDate; yeniUrun.MarkaID = Convert.ToInt32(ddlMarkalar.SelectedValue); yeniUrun.GrupID = Convert.ToInt32(ddlUrunGrubu.SelectedValue); data.SubmitChanges(); data.RenkvsUruns.DeleteAllOnSubmit(data.RenkvsUruns.Where(ru => ru.UrunID == id)); List <RenkvsUrun> yeniUrunRenkleri = new List <RenkvsUrun>(); int i = 0, c = blRenkler.Items.Count; while (i < c) { RenkvsUrun yeniUrunRenk = new RenkvsUrun(); yeniUrunRenk.RenkID = Convert.ToInt32(blRenkler.Items[i].Value); yeniUrunRenk.UrunID = id; yeniUrunRenkleri.Add(yeniUrunRenk); i++; } var recUR = (from ur in yeniUrunRenkleri select ur); data.RenkvsUruns.InsertAllOnSubmit(yeniUrunRenkleri); data.BedenvsUruns.DeleteAllOnSubmit(data.BedenvsUruns.Where(bu => bu.UrunID == id)); List <BedenvsUrun> yeniUrunBedenleri = new List <BedenvsUrun>(); i = 0; c = blBedenler.Items.Count; while (i < c) { BedenvsUrun yeniUrunBeden = new BedenvsUrun(); yeniUrunBeden.BedenID = Convert.ToInt32(blBedenler.Items[i].Value); yeniUrunBeden.UrunID = id; yeniUrunBedenleri.Add(yeniUrunBeden); i++; } var recUB = (from ub in yeniUrunBedenleri select ub); data.BedenvsUruns.InsertAllOnSubmit(recUB); DataTable dtG = new DataTable(); if (Session["MevcutGorseller"] == null) { dtG = new DataTable(); dtG.Columns.Add("GorselAdres"); } else { dtG = (DataTable)Session["MevcutGorseller"]; } data.UrunGorselis.DeleteAllOnSubmit(data.UrunGorselis.Where(ug => ug.UrunID == id)); List <UrunGorseli> yeniUrunGorselleri = new List <UrunGorseli>(); i = 0; c = dtG.Rows.Count; while (i < c) { UrunGorseli yeniUrunGorseli = new UrunGorseli(); yeniUrunGorseli.GorselAdres = dtG.Rows[i]["GorselAdres"].ToString(); yeniUrunGorseli.UrunID = yeniUrun.UrunID; yeniUrunGorselleri.Add(yeniUrunGorseli); i++; } var recUG = (from ug in yeniUrunGorselleri select ug); data.UrunGorselis.InsertAllOnSubmit(recUG); data.SubmitChanges(); Response.Redirect(Request.Url.AbsolutePath + "?UrunId=" + id.ToString()); } } } } catch { lblError.Text = "Bir hata oluştu"; } }
protected void Page_Load(object sender, EventArgs e) { search_text.ServerClick += search_text_ServerClick; search_price.ServerClick += search_price_ServerClick; ModalDataContext data = new ModalDataContext(); #region Filtreleme UlFilters.InnerHtml = ""; int[] page_array = new int[9] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; int _page = 1; string[] filters = new string[8] { "ctgr", "grp", "clr", "mrk", "srch", "prc", "sz", "page" }; int i = 0, c = filters.Length; List <Urun> urunler = data.Uruns.ToList(); while (i < c) { try { string filter = filters[i]; if (Request.QueryString[filter] != null) { if (i == 0) // Kategori Sorgulama { int id = 0; if (Int32.TryParse(Request.QueryString[filter], out id)) { urunler = urunler.Where(u => data.UrunGrubus.Where(ug => ug.KategoriID == id).Contains(u.UrunGrubu)).ToList(); string kategori_adi = data.Kategoris.FirstOrDefault(k => k.KategoriID == id).KategoriAdi; h2KategoriGrup.InnerText = kategori_adi; HtmlGenericControl li = new HtmlGenericControl("li"); Button button = new Button(); button.CssClass = "btn-link"; button.Text = " Kategori: " + kategori_adi; button.ID = "filter_ctgr"; button.Click += button_Click; HtmlGenericControl i_ = new HtmlGenericControl("i"); i_.Attributes.Add("class", "fa fa-remove"); button.Controls.Add(i_); li.Controls.Add(button); UlFilters.Controls.Add(li); } else { i++; continue; } } else if (i == 1) // UrunGrubu Sorgulama { string _ids = Request.QueryString[filter]; string[] ids = _ids.Split('+', ' '); int _i = 0, _c = ids.Length; List <int> idList = new List <int>(); int id = 0; while (_i < _c) { if (Int32.TryParse(ids[_i], out id)) { idList.Add(id); } else { _i++; continue; } _i++; } if (idList.Count > 0) { urunler = (from u in urunler where (idList.Contains((int)u.GrupID)) select u).ToList(); HtmlGenericControl li = new HtmlGenericControl("li"); Button button = new Button(); button.CssClass = "btn-link"; button.Text = " Ürün Grubu: " + string.Join("+", data.UrunGrubus.Where(ug => idList.Contains(ug.GrupID)).Select(ug => ug.GrupAdi).ToArray()); button.ID = "filter_grp"; button.Click += button_Click; HtmlGenericControl i_ = new HtmlGenericControl("i"); i_.Attributes.Add("class", "fa fa-remove"); button.Controls.Add(i_); li.Controls.Add(button); UlFilters.Controls.Add(li); } else { i++; continue; } } else if (i == 2) // Renk Sorgulama { string _ids = Request.QueryString[filter]; string[] ids = _ids.Split('+', ' '); int _i = 0, _c = ids.Length; List <int> idList = new List <int>(); int id = 0; while (_i < _c) { if (Int32.TryParse(ids[_i], out id)) { idList.Add(id); } else { _i++; continue; } _i++; } if (idList.Count > 0) { urunler = (from u in urunler where (from ru in data.RenkvsUruns where (idList.Contains((int)ru.RenkID)) select ru.UrunID).Contains(u.UrunID) select u).ToList(); HtmlGenericControl li = new HtmlGenericControl("li"); Button button = new Button(); button.CssClass = "btn-link"; button.Text = " Renk: " + string.Join("+", data.Renks.Where(r => idList.Contains(r.RenkID)).Select(r => r.RenkAdi).ToArray()); button.ID = "filter_clr"; button.Click += button_Click; HtmlGenericControl i_ = new HtmlGenericControl("i"); i_.Attributes.Add("class", "fa fa-remove"); button.Controls.Add(i_); li.Controls.Add(button); UlFilters.Controls.Add(li); } else { i++; continue; } } else if (i == 3) // Marka Sorgulama { string _ids = Request.QueryString[filter]; string[] ids = _ids.Split('+', ' '); int _i = 0, _c = ids.Length; List <int> idList = new List <int>(); int id = 0; while (_i < _c) { if (Int32.TryParse(ids[_i], out id)) { idList.Add(id); } else { _i++; continue; } _i++; } if (idList.Count > 0) { urunler = (from u in urunler where (idList.Contains((int)u.MarkaID)) select u).ToList(); HtmlGenericControl li = new HtmlGenericControl("li"); Button button = new Button(); button.CssClass = "btn-link"; button.Text = " Marka: " + string.Join("+", data.Markas.Where(m => idList.Contains(m.MarkaID)).Select(m => m.MarkaAdi).ToArray()); button.ID = "filter_mrk"; button.Click += button_Click; HtmlGenericControl i_ = new HtmlGenericControl("i"); i_.Attributes.Add("class", "fa fa-remove"); button.Controls.Add(i_); li.Controls.Add(button); UlFilters.Controls.Add(li); } else { i++; continue; } } else if (i == 4) // İsim Sorgulama { string text = Request.QueryString[filter]; if (text.Length > 0) { string[] tags = text.Split('+', ' '); urunler = (from u in urunler where (from tag in tags select u.UrunAdi.ToUpper().Contains(tag.ToUpper())).Any(b => b) select u).ToList(); List <string[]> tagList = (from t in tags select new string[2] { t, data.Tags.Select(tg => tg.TagAdi.ToUpper()).Contains(t.ToUpper()) ? data.Tags.FirstOrDefault(tg => tg.TagAdi.ToUpper() == t.ToUpper()).TagID.ToString() : "-1" }).ToList(); foreach (string[] tag in tagList) { int tag_id = -1; Int32.TryParse(tag[1], out tag_id); if (tag_id == -1) { Tag yeniTag = new Tag(); yeniTag.TagAdi = tag[0]; yeniTag.TagAramaSayisi = 0; data.Tags.InsertOnSubmit(yeniTag); data.SubmitChanges(); } else { Tag mevcutTag = data.Tags.FirstOrDefault(tg => tg.TagID == tag_id); mevcutTag.TagAramaSayisi += 1; data.SubmitChanges(); } } HtmlGenericControl li = new HtmlGenericControl("li"); Button button = new Button(); button.CssClass = "btn-link"; button.Text = " İsim: " + string.Join("+", tags); button.ID = "filter_srch"; button.Click += button_Click; HtmlGenericControl i_ = new HtmlGenericControl("i"); i_.Attributes.Add("class", "fa fa-remove"); button.Controls.Add(i_); li.Controls.Add(button); UlFilters.Controls.Add(li); } else { i++; continue; } } else if (i == 5) // Fiyat Aralığı Sorgulama { string values = Request.QueryString[filter]; string[] two_values = values.Split('+', ' '); if (two_values.Length == 2) { decimal taban, tavan; if (Decimal.TryParse(two_values[0], out taban) && Decimal.TryParse(two_values[1], out tavan)) { urunler = urunler.Where(u => u.BirimFiyat <= tavan && u.BirimFiyat >= taban).ToList(); HtmlGenericControl li = new HtmlGenericControl("li"); Button button = new Button(); button.CssClass = "btn-link"; button.Text = " Fiyat: " + string.Join("-", two_values); button.ID = "filter_prc"; button.Click += button_Click; HtmlGenericControl i_ = new HtmlGenericControl("i"); i_.Attributes.Add("class", "fa fa-remove"); button.Controls.Add(i_); li.Controls.Add(button); UlFilters.Controls.Add(li); } } else { i++; continue; } } else if (i == 6) // Beden Sorgulama { string _ids = Request.QueryString[filter]; string[] ids = _ids.Split('+', ' '); int _i = 0, _c = ids.Length; List <int> idList = new List <int>(); int id = 0; while (_i < _c) { if (Int32.TryParse(ids[_i], out id)) { idList.Add(id); } else { _i++; continue; } _i++; } if (idList.Count > 0) { urunler = (from u in urunler where (from bu in data.BedenvsUruns where (idList.Contains((int)bu.BedenID)) select bu.UrunID).Contains(u.UrunID) select u).ToList(); HtmlGenericControl li = new HtmlGenericControl("li"); Button button = new Button(); button.CssClass = "btn-link"; button.Text = " Beden: " + string.Join("+", data.Bedens.Where(b => idList.Contains(b.BedenID)).Select(b => b.BedenBoyu).ToArray()); button.ID = "filter_sz"; button.Click += button_Click; HtmlGenericControl i_ = new HtmlGenericControl("i"); i_.Attributes.Add("class", "fa fa-remove"); button.Controls.Add(i_); li.Controls.Add(button); UlFilters.Controls.Add(li); } else { i++; continue; } } else if (i == 7) { _page = 1; if (!Int32.TryParse(Request.QueryString[filter], out _page)) { int k = 0, f = page_array.Length; while (k < f) { page_array[k] += _page > 3 ? (_page - 3) : 0; k++; } } else { i++; continue; } } } } catch { i++; continue; } i++; } #endregion #region Sıralama Sayfalama // Sıralama if (IsPostBack) { Session["Siralama"] = ddlSort.SelectedValue; Session["SayfaUrunSayisi"] = ddlNumberOfPage.SelectedValue; Session.Timeout = 40; } string siralama = "sortByDate"; if (Session["Siralama"] != null) { siralama = Session["Siralama"].ToString(); } if (siralama == "sortByDate") { urunler = urunler.OrderByDescending(u => u.Tarih).ToList(); ddlSort.SelectedIndex = 0; } else if (siralama == "sortByName") { urunler = urunler.OrderBy(u => u.UrunAdi).ToList(); ddlSort.SelectedIndex = 1; } else if (siralama == "sortByPrice") { urunler = urunler.OrderBy(u => u.BirimFiyat).ToList(); ddlSort.SelectedIndex = 2; } else if (siralama == "sortByQuantity") { urunler = urunler.OrderByDescending(u => u.NetMiktar).ToList(); ddlSort.SelectedIndex = 3; } else if (siralama == "sortByLiked") { urunler = urunler.OrderByDescending(u => u.Begeniler).ToList(); ddlSort.SelectedIndex = 4; } else { urunler = urunler.OrderByDescending(u => u.Tarih).ToList(); } // Sayfalama int _pageCount = 12; string sayfalama = "twelve"; if (Session["SayfaUrunSayisi"] != null) { sayfalama = Session["SayfaUrunSayisi"].ToString(); } if (sayfalama == "twelve") { _pageCount = 12; ddlNumberOfPage.SelectedIndex = 0; } else if (sayfalama == "eighteen") { _pageCount = 18; ddlNumberOfPage.SelectedIndex = 1; } else if (sayfalama == "twentyfour") { _pageCount = 24; ddlNumberOfPage.SelectedIndex = 2; } int urun_count = urunler.Count; int total_pages = (urun_count - (urun_count % _pageCount)) / _pageCount + (urun_count % _pageCount == 0 ? 0 : 1); urunler = urunler.Skip((_page - 1) * _pageCount).Take(_pageCount).ToList(); grid_row.InnerHtml = GridUrun(urunler, data); list_div.InnerHtml = ListUrun(urunler, data); if (_page != 1) { HtmlGenericControl li = new HtmlGenericControl("li"); LinkButton pageLink = new LinkButton(); HtmlGenericControl i_ctrl = new HtmlGenericControl("i"); i_ctrl.Attributes.Add("class", "fa fa-caret-left"); pageLink.ID = "pagePrev"; pageLink.Controls.Add(i_ctrl); pageLink.Click += pageLink_Click; li.Controls.Add(pageLink); pagination_pages.Controls.Add(li); } i = 0; c = page_array.Length; while (i < c) { int __page = page_array[i]; if (__page <= total_pages) { HtmlGenericControl li = new HtmlGenericControl("li"); if (__page == _page) { li.Attributes.Add("class", "current"); } LinkButton pageLink = new LinkButton(); pageLink.Text = __page.ToString(); pageLink.ID = "page" + __page; pageLink.Click += pageLink_Click; li.Controls.Add(pageLink); pagination_pages.Controls.Add(li); } i++; } if (_page != total_pages) { HtmlGenericControl li = new HtmlGenericControl("li"); LinkButton pageLink = new LinkButton(); HtmlGenericControl i_ctrl = new HtmlGenericControl("i"); i_ctrl.Attributes.Add("class", "fa fa-caret-right"); pageLink.ID = "pageNext"; pageLink.Controls.Add(i_ctrl); pageLink.Click += pageLink_Click; li.Controls.Add(pageLink); pagination_pages.Controls.Add(li); } quickview_wrapper.InnerHtml = QuickViewUrun(urunler, data); #endregion #region Kategori Seçenekleri UlKategoriGrup.InnerHtml = ""; if (Request.QueryString["ctgr"] == null) { h2KategoriGrup.InnerText = "Kategori"; foreach (Kategori k in data.Kategoris) { LinkButton btnKategori = new LinkButton(); btnKategori.Text = k.KategoriAdi; btnKategori.Click += btnKategori_Click; btnKategori.ID = "kategori" + k.KategoriID; HtmlGenericControl li = new HtmlGenericControl("li"); li.Controls.Add(btnKategori); UlKategoriGrup.Controls.Add(li); } } else { List <UrunGrubu> gruplar = UrunGruplari(urunler, data); foreach (UrunGrubu ug in gruplar) { LinkButton btnGrup = new LinkButton(); btnGrup.Text = ug.GrupAdi + " (" + ug.Uruns.Count + ")"; btnGrup.Click += btnGrup_Click; btnGrup.ID = "grup" + ug.GrupID; HtmlGenericControl li = new HtmlGenericControl("li"); li.Controls.Add(btnGrup); UlKategoriGrup.Controls.Add(li); } } List <Marka> markalar = UrunMarkalari(urunler, data); foreach (Marka m in markalar) { LinkButton btnMarka = new LinkButton(); btnMarka.Text = m.MarkaAdi + " (" + m.Uruns.Count + ")"; btnMarka.Click += btnMarka_Click; btnMarka.ID = "marka" + m.MarkaID; HtmlGenericControl li = new HtmlGenericControl("li"); li.Controls.Add(btnMarka); UlMarka.Controls.Add(li); } List <Renk> renkler = UrunRenkleri(urunler, data); foreach (Renk r in renkler) { LinkButton btnRenk = new LinkButton(); btnRenk.Text = r.RenkAdi; btnRenk.Click += btnRenk_Click; btnRenk.ID = "renk" + r.RenkID; HtmlGenericControl li = new HtmlGenericControl("li"); li.Controls.Add(btnRenk); UlRenk.Controls.Add(li); } List <Beden> bedenler = UrunBedenleri(urunler, data); foreach (Beden b in bedenler) { LinkButton btnBeden = new LinkButton(); btnBeden.Text = b.BedenBoyu; btnBeden.Click += btnBeden_Click; btnBeden.ID = "beden" + b.BedenID; HtmlGenericControl li = new HtmlGenericControl("li"); li.Controls.Add(btnBeden); UlBeden.Controls.Add(li); } #endregion }
protected void btnGonder_Click(object sender, EventArgs e) { ModalDataContext data = new ModalDataContext(); try { bool oturum = Session["UyeID"] != null; if (oturum) { string baslik = txtBaslik.Text, yorum = txtYorum.Text; double _fiyatPuan = -1, _urunPuan = -1, _kalitePuan = -1; if (FiyatPuan5.Checked) { _fiyatPuan = 5.0; } else if (FiyatPuan4.Checked) { _fiyatPuan = 4.0; } else if (FiyatPuan3.Checked) { _fiyatPuan = 3.0; } else if (FiyatPuan2.Checked) { _fiyatPuan = 2.0; } else if (FiyatPuan1.Checked) { _fiyatPuan = 1.0; } if (UrunPuan5.Checked) { _urunPuan = 5.0; } else if (UrunPuan4.Checked) { _urunPuan = 4.0; } else if (UrunPuan3.Checked) { _urunPuan = 3.0; } else if (UrunPuan2.Checked) { _urunPuan = 2.0; } else if (UrunPuan1.Checked) { _urunPuan = 1.0; } if (KalitePuan5.Checked) { _kalitePuan = 5.0; } else if (KalitePuan4.Checked) { _kalitePuan = 4.0; } else if (KalitePuan3.Checked) { _kalitePuan = 3.0; } else if (KalitePuan2.Checked) { _kalitePuan = 2.0; } else if (KalitePuan1.Checked) { _kalitePuan = 1.0; } int urunID = Convert.ToInt32(Request.QueryString["UrunId"]), uyeID = Convert.ToInt32(Session["UyeID"].ToString()); UrunPuan urunPuan = data.UrunPuans.FirstOrDefault(up => up.UrunID == urunID && up.UyeID == uyeID); if (urunPuan != null) { urunPuan.Yorum = yorum; urunPuan.Baslik = baslik; urunPuan.Tarih = DateTime.Now; urunPuan.FiyatPuani = _fiyatPuan; urunPuan.DegerPuani = _urunPuan; urunPuan.KalitePuani = _kalitePuan; } else { urunPuan = new UrunPuan(); urunPuan.UrunID = urunID; urunPuan.UyeID = uyeID; urunPuan.Yorum = yorum; urunPuan.Baslik = baslik; urunPuan.Tarih = DateTime.Now; urunPuan.FiyatPuani = _fiyatPuan; urunPuan.DegerPuani = _urunPuan; urunPuan.KalitePuani = _kalitePuan; urunPuan.Begeni = false; data.UrunPuans.InsertOnSubmit(urunPuan); } data.SubmitChanges(); } else { Response.Redirect("Login.aspx"); } } catch (Exception) { Response.Redirect("NotFound404.aspx"); } }