protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            return;
        }
        dlUrunler.DataSource = GgDbProvider.GetProductList();
        dlUrunler.DataBind();
        if (dlUrunler.Items.Count == 0)
        {
            pnlUrunler.Visible = false;
            pnlBilgi.Visible   = true;
        }
        else
        {
            pnlUrunler.Visible = true;
            pnlBilgi.Visible   = false;
        }

        lblTopFiyat.Text     = "0 TL";
        lblUrunSayisi.Text   = "0 Ürün";
        btnSiparis.CssClass += "btn btn-default butonn disabled";


        ddlFiltering.DataSource = GgDbProvider.GetCategoryList();
        ddlFiltering.DataBind();

        lstDistrict.DataSource = GgDbProvider.GetDistrictList();
        lstDistrict.DataBind();
        lstDistrict.Items.Add(new ListItem()
        {
            Text = "Seçiniz"
        });



        List <double> toplamFiyat = new List <double>();

        if (Session["ToplamFiyat"] != null)
        {
            toplamFiyat = Session["ToplamFiyat"] as List <double>;
            double toplam = ToplamUrunFiyatiniHesapla(toplamFiyat);
            lblTopFiyat.Text = toplam.ToString();

            lblSayi.Text        = Session["ToplamUrunSayisi"].ToString();
            lblUrunSayisi.Text  = Session["ToplamUrunSayisi"].ToString();
            lblUrunSayisi.Text += " " + "Ürün";

            lblTopFiyat.Text    += " " + "TL";
            btnSiparis.CssClass += "btn btn-default butonn";
        }

        else
        {
            lblTopFiyat.Text = "";

            lblSayi.Text       = "0";
            lblUrunSayisi.Text = "Sepetinizde ürün yok.";
        }
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        List <Product> result = new List <Product>();

        if (txtSearchProduct.Text.Trim() != "" && txtSearchSupplier.Text.Trim() != "")
        {
            result = GgDbProvider.GetProductList().Where(i => i.ProductName.ToLower().Contains(txtSearchProduct.Text.Trim().ToLower()) || i.Supplier.CompanyName.ToLower().Contains(txtSearchSupplier.Text.Trim().ToLower())).ToList();
        }
        else if (txtSearchProduct.Text.Trim() != "" && txtSearchSupplier.Text.Trim() == "")
        {
            result = GgDbProvider.GetProductList().Where(i => i.ProductName.ToLower().Contains(txtSearchProduct.Text.Trim().ToLower())).ToList();
        }
        else if (txtSearchProduct.Text.Trim() == "" && txtSearchSupplier.Text.Trim() != "")
        {
            result = GgDbProvider.GetProductList().Where(i => i.Supplier.CompanyName.ToLower().Contains(txtSearchSupplier.Text.Trim().ToLower())).ToList();
        }
        else
        {
            result = GgDbProvider.GetProductList();
        }

        List <Product> result2 = new List <Product>();

        foreach (int item in lstDistrict.GetSelectedIndices())
        {
            result2.AddRange(result.Where(i => i.Supplier.DistrictID == Convert.ToInt32(lstDistrict.Items[item].Value)).ToList());
        }

        dlUrunler.DataSource = result2;
        dlUrunler.DataBind();
        if (dlUrunler.Items.Count == 0)
        {
            pnlUrunler.Visible = false;
            pnlBilgi.Visible   = true;
        }
        else
        {
            pnlUrunler.Visible = true;
            pnlBilgi.Visible   = false;
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         return;
     }
     if (Session["Oturum"] != null)
     {
         User currentUser = Session["Oturum"] as User;
         if (currentUser != default(User))
         {
             rptSupplier.DataSource = GgDbProvider.GetProductList().Where(i => i.SupplierID == currentUser.ObjectID);
             rptSupplier.DataBind();
         }
     }
     else
     {
         Session["URL"] = "gelensiparis";
         Response.Redirect("Login.aspx");
     }
 }
 protected void ddlFiltering_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (ddlFiltering.SelectedValue == "Seçiniz")
     {
         dlUrunler.DataSource = GgDbProvider.GetProductList();
     }
     else
     {
         dlUrunler.DataSource = GgDbProvider.GetProductList().Where(i => i.CategoryID == Convert.ToInt32(ddlFiltering.SelectedValue));
     }
     dlUrunler.DataBind();
     if (dlUrunler.Items.Count == 0)
     {
         pnlUrunler.Visible = false;
         pnlBilgi.Visible   = true;
     }
     else
     {
         pnlUrunler.Visible = true;
         pnlBilgi.Visible   = false;
     }
 }
 protected void ddlSorting_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (ddlSorting.SelectedValue == "artan")
     {
         dlUrunler.DataSource = GgDbProvider.GetProductList().OrderBy(i => i.Price);
         dlUrunler.DataBind();
     }
     else if (ddlSorting.SelectedValue == "azalan")
     {
         dlUrunler.DataSource = GgDbProvider.GetProductList().OrderByDescending(i => i.Price);
         dlUrunler.DataBind();
     }
     if (dlUrunler.Items.Count == 0)
     {
         pnlUrunler.Visible = false;
         pnlBilgi.Visible   = true;
     }
     else
     {
         pnlUrunler.Visible = true;
         pnlBilgi.Visible   = false;
     }
 }