protected void btnSave_Click(object sender, EventArgs e) { Order o = new Order(); o.OrderNo = CreateOrderNo();// rastgele oluştur o.UserId = new Guid(Membership.GetUser().ProviderUserKey.ToString()); o.Date = DateTime.Now; OrderBLL ob = new OrderBLL(); ob.Add(o); ProductBLL pb = new ProductBLL(); foreach (var p in Helper.Sepet) { OrderDetail od = new OrderDetail(); od.OrderId = o.Id; od.ProductId = p.Id; od.Quantity = p.Quantity; OrderDetailBLL obll = new OrderDetailBLL(); obll.Add(od); Product pr = pb.Get(x => x.Id == p.Id).FirstOrDefault(); pr.Stock -= p.Quantity; pb.Update(pr); Helper.Sepet = new List<ProductDTO>(); } }
private void Fill() { ProductBLL pb = new ProductBLL(); rptProducts.DataSource = pb.Get(x => x.IsActive == true).ToList(); rptProducts.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { Helper.Sayfalar = new List<string>() { "Ürünler", "Tüm Ürünler" }; ProductBLL pb = new ProductBLL(); rptProducts.DataSource = pb.Get(x => x.IsActive == true).ToList(); rptProducts.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { ProductBLL pb = new ProductBLL(); if (Request.QueryString["categoryId"] == null) { rptProducts.DataSource = pb.Get(x => x.IsActive == true).ToArray(); rptProducts.DataBind(); } else if (Request.QueryString["categoryId"] != null) { int id = Convert.ToInt32(Request.QueryString["categoryId"]); rptProducts.DataSource = pb.Get(x => x.CategoryId == id & x.IsActive == true).ToArray(); rptProducts.DataBind(); } }
protected void rptProducts_ItemCommand(object source, RepeaterCommandEventArgs e) { int id = Convert.ToInt32(e.CommandArgument); ProductBLL pb = new ProductBLL(); Product p = pb.Get(x => x.Id == id).FirstOrDefault(); p.IsActive = false; pb.Update(p); Fill(); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["productId"] == null) { Response.Redirect("default.aspx"); } int id = Convert.ToInt32(Request.QueryString["productId"]); ProductBLL pb = new ProductBLL(); product = pb.Get(x => x.Id == id).FirstOrDefault(); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["logout"] == "true") { FormsAuthentication.SignOut(); Session.Abandon(); Response.Redirect("default.aspx"); } ProductBLL pb = new ProductBLL(); rptProducts.DataSource = pb.Get(x => x.IsActive == true).OrderByDescending(x => x.Date).Take(2).ToArray(); rptProducts.DataBind(); }
protected void btnSave_Click(object sender, EventArgs e) { int catId =Convert.ToInt32(ddlCategories.SelectedValue); if (Request.QueryString["productId"]==null) { ProductBLL pb = new ProductBLL(); Product p = new Product(); p.CategoryId = catId; p.Name = txtName.Text; p.Price = Convert.ToDecimal(txtPrice.Text); p.Stock = Convert.ToByte(txtStock.Text); p.Date = DateTime.Now; p.IsActive = true; p.Detail = txtDetail.Text; string fileName = Guid.NewGuid().ToString().Replace("-", ""); string ext = Path.GetExtension(fl.FileName); fileName += ext; fl.SaveAs(MapPath("~/ProductImages/" + fileName)); p.Image = fileName; pb.Add(p); } else { int id = Convert.ToInt32(Request.QueryString["productId"]); ProductBLL pb = new ProductBLL(); Product p = pb.Get(x => x.Id == id).FirstOrDefault(); p.Name = txtName.Text; p.Price = Convert.ToDecimal(txtPrice.Text); p.Stock = Convert.ToByte(txtStock.Text); p.Date = DateTime.Now; p.IsActive = true; p.Detail = txtDetail.Text; string fileName = Guid.NewGuid().ToString().Replace("-", ""); string ext = Path.GetExtension(fl.FileName); fileName += ext; fl.SaveAs(MapPath("~/ProductImages/" + fileName)); p.Image = fileName; pb.Update(p); } Response.Redirect("Products.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; CategoryBLL cb = new CategoryBLL(); ddlCategories.DataTextField = "Name"; ddlCategories.DataValueField = "Id"; ddlCategories.DataSource = cb.Get(x => x.IsActive == true).ToList(); ddlCategories.DataBind(); if (Request.QueryString["productId"]!=null) { int id = Convert.ToInt32(Request.QueryString["productId"]); ProductBLL pb = new ProductBLL(); Product p = pb.Get(x => x.Id == id).FirstOrDefault(); txtName.Text = p.Name; txtPrice.Text = p.Price.ToString(); txtStock.Text = p.Stock.ToString(); txtDetail.Text = p.Detail; } }
private void SayfaKaydiniGetir() { ProductBLL pb = new ProductBLL(); if (Request.QueryString["catId"] == null) { SayfadakiVeri = new PagedDataSource() { DataSource = pb.Get(x => x.IsActive == true).ToList(), AllowPaging = true, PageSize = 4, CurrentPageIndex = SayfaNumarasi }; } else { int id = Convert.ToInt32(Request.QueryString["catId"]); SayfadakiVeri = new PagedDataSource() { DataSource = pb.Get(x => x.IsActive == true & x.Id == id).ToList(), AllowPaging = true, PageSize = 4, CurrentPageIndex = SayfaNumarasi }; } // rptProducts.DataSource = SayfadakiVeri; rptProducts.DataBind(); SayfaAdedi = SayfadakiVeri.PageCount - 1; // lbSayfaBilgi.Text = "Sayfa " + (SayfadakiVeri.CurrentPageIndex + 1) + "/" + SayfadakiVeri.PageCount + " - Kayıt Sayısı " + (SayfadakiVeri.DataSourceCount); // btnGeri.Enabled = !SayfadakiVeri.IsFirstPage; btnIleri.Enabled = !SayfadakiVeri.IsLastPage; }