コード例 #1
0
        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>();

            }
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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");
        }