Ejemplo n.º 1
0
 public OrderDetails(Product prod, double unitprice, int quantity, double discount)
 {
     product = prod;
     UnitPrice = unitprice;
     Quantity = quantity;
     Discount = discount;
 }
Ejemplo n.º 2
0
        public ActionResult Detail(int id)
        {
            ProductService _service = new ProductService();

            Entities.Product product = _service.GetById(id);
            ProductModel     model   = new ProductModel();

            model.ListImage = new List <Entities.ProductImage>();
            if (product != null)
            {
                // Lấy thông tin sản phẩm.
                model.MapFrom(product, ref model);

                // Lấy thông tin kiểu nhà.
                var listProductType = _service.ListProductType();
                model.ProductTypeText = (from p in listProductType
                                         where p.Id == model.Product_Type
                                         select p.Text).FirstOrDefault();

                // Lấy thông tin người đăng.
                UserService _userService = new UserService();
                var         user         = _userService.GetById(model.UserId);
                model.Username    = user.UserName;
                model.PhoneNumber = user.Phone;

                // Lấy danh sách ảnh sản phẩm.
                model.ListImage = _service.GetListImage(id);

                // Kiểm tra có phải là người post hay không.
                if (CookieHelper.Get(AdminConfigs.COOKIES_USER_ID) != null)
                {
                    if (CookieHelper.Get(AdminConfigs.COOKIES_USER_ID) == model.UserId.ToString())
                    {
                        model.IsPoster = true;
                    }
                    else
                    {
                        model.IsPoster = false;
                    }
                }

                // Lấy thông tin điều chỉnh giá.
                model.NewCost = _service.GetCostChangeByOwn(id, product.UserId);

                // Lấy danh sách giá đặt mua
                List <Entities.Product_ChangeCost> lstChangeCost = _service.GetListProductChangeCost(id, product.UserId);
                model.ListChangeCost = lstChangeCost;
            }
            else
            {
                model.ListChangeCost = new List <Entities.Product_ChangeCost>();
            }
            return(View(model));
        }
 public void AddItem(Product product, int quantity)
 {
     OrderLineItem orderLineItem = _orderLineItems.FirstOrDefault(x => x.ProductId == product.Id);
     if (orderLineItem == null)
     {
         _orderLineItems.Add(new OrderLineItem(product, quantity));
     }
     else
     {
         orderLineItem.AddQuantity(quantity);
     }
 }
Ejemplo n.º 4
0
        private static void LoadDemoProducts()
        {
            var productLogic = Dependencies.ProductLogic;

            var drill = new Entities.Product("Дрель", 7500);

            productLogic.Add(ref drill);

            var speakers = new Entities.Product("Колонки", 3500);

            productLogic.Add(ref speakers);

            var fireworks = new Entities.Product("Хлопушка", 1000);

            productLogic.Add(ref fireworks);
        }
Ejemplo n.º 5
0
 public void ProductInsert(Product product)
 {
     using (SqlCommand command = new SqlCommand("sp_ProductInsert", GetConnection()))
     {
         command.CommandType = CommandType.StoredProcedure;
         command.Parameters.Add(new SqlParameter("@CategoryID", product.CategoryID));
         command.Parameters.Add(new SqlParameter("@ProductName", product.ProductName));
         command.Parameters.Add(new SqlParameter("@Output", product.Output));
         command.Parameters.Add(new SqlParameter("@MadeGoodsSize", product.MadeGoodsSize));
         command.Parameters.Add(new SqlParameter("@MachineSize", product.MachineSize));
         command.Parameters.Add(new SqlParameter("@Picture", product.Picture));
         command.Parameters.Add(new SqlParameter("@UnitPrice", product.UnitPrice));
         command.Parameters.Add(new SqlParameter("@Weight", product.Weight));
         command.Parameters.Add(new SqlParameter("@ExtraDescription", product.ExtraDescription));
         command.ExecuteNonQuery();
     }
 }
 public void Save(Product product)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 7
0
 public virtual void AddProduct(Product product)
 {
     product.StoresStockedIn.Add(this);
     Products.Add(product);
 }
 public ProductViewModel GetProductViewModel(Product product)
 {
     return Mapper.Map<Product, ProductViewModel>(product);
 }
Ejemplo n.º 9
0
 // Get product's details
 public Product GetDetailProduct(int iProductID)
 {
     try
     {
         Product objProduct = new Product();
         connect = new Connection().Connect;
         connect.Open();
         Command = new SqlCommand("sp_GetDetailProductByProductID", connect);
         Command.CommandType = System.Data.CommandType.StoredProcedure;
         Command.Parameters.AddWithValue("@ProductID", iProductID);
         SqlDataReader dr = Command.ExecuteReader();
         while (dr.Read())
         {
             objProduct.ProductID = dr.GetInt32(0);
             objProduct.ProductName = dr.GetString(2);
             objProduct.Output = dr.GetInt32(3);
             objProduct.MadeGoodsSize = dr.GetDouble(4);
             objProduct.MachineSize = dr.GetString(5);
             objProduct.Weight = dr.GetDouble(6);
             objProduct.Picture = dr.GetString(7);
             objProduct.ExtraDescription = dr.GetString(8);
             objProduct.FrequentlyViewed = dr.GetInt32(9);
             objProduct.UnitPrice = dr.GetDecimal(10);
         }
         connect.Close();
         return objProduct;
     }
     catch (Exception)
     {
         connect.Close();
         return null;
     }
 }
Ejemplo n.º 10
0
 // Get products which are most viewed
 public List<Product> GetProductByMostFrequentlyViewed()
 {
     try
     {
         List<Product> ListOfProduct = new List<Product>();
         connect = new Connection().Connect;
         connect.Open();
         Command = new SqlCommand("sp_GetProductByFrequentlyViewed", connect);
         Command.CommandType = System.Data.CommandType.StoredProcedure;
         SqlDataReader dr = Command.ExecuteReader();
         while (dr.Read())
         {
             Product objProduct = new Product();
             objProduct.ProductName = dr.GetString(0);
             objProduct.Output = dr.GetInt32(1);
             objProduct.MadeGoodsSize = dr.GetDouble(2);
             objProduct.MachineSize = dr.GetString(3);
             objProduct.Weight = dr.GetDouble(4);
             objProduct.UnitPrice = dr.GetDecimal(5);
             objProduct.Picture = dr.GetString(6);
             objProduct.FrequentlyViewed = dr.GetInt32(7);
             objProduct.ProductID = dr.GetInt32(8);
             objProduct.ExtraDescription = dr.GetString(9);
             ListOfProduct.Add(objProduct);
         }
         connect.Close();
         return ListOfProduct;
     }
     catch (Exception)
     {
         connect.Close();
         return null;
     }
 }
Ejemplo n.º 11
0
 // Get products with certain category
 public List<Product> GetProductByCategory(int iCategoryID)
 {
     try
     {
         List<Product> ListOfProductByCategory = new List<Product>();
         connect = new Connection().Connect;
         connect.Open();
         Command = new SqlCommand("sp_GetProductByCategory", connect);
         Command.CommandType = System.Data.CommandType.StoredProcedure;
         Command.Parameters.AddWithValue("@CategoryID", iCategoryID);
         SqlDataReader dr = Command.ExecuteReader();
         while (dr.Read())
         {
             Product objProduct = new Product();
             objProduct.ProductName = dr.GetString(0);
             objProduct.UnitPrice = dr.GetDecimal(1);
             objProduct.Picture = dr.GetString(2);
             objProduct.ProductID = dr.GetInt32(3);
             ListOfProductByCategory.Add(objProduct);
         }
         connect.Close();
         return ListOfProductByCategory;
     }
     catch (Exception)
     {
         connect.Close();
         return null;
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ProductSet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProductSet(Product product)
 {
     base.AddObject("ProductSet", product);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Create a new Product object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="brandName">Initial value of the BrandName property.</param>
 public static Product CreateProduct(global::System.Int32 id, global::System.String name, global::System.String brandName)
 {
     Product product = new Product();
     product.Id = id;
     product.Name = name;
     product.BrandName = brandName;
     return product;
 }
Ejemplo n.º 14
0
        protected void lbtn_update_Click(object sender, EventArgs e)
        {
            lbl_catch.Text = "";
            int n = 0;
            float m = 0;
            // valid data
            if (txt_ProductName.Text.Equals(""))
            {
                lbl_catch.Text += "Enter product name \n";
            }
            if (img_upload.ImageUrl.Equals(""))
            {
                lbl_catch.Text += "Choose a picture \n";
            }

            if (!int.TryParse(txt_Output.Text, out n))
            {
                lbl_catch.Text += "Output has to numberic type \n";
            }
            if (!float.TryParse(txt_MadeGoods.Text, out m))
            {
                lbl_catch.Text += "MadeGoodsSize has to float type \n";
            }
            if (!float.TryParse(txt_Weight.Text, out m))
            {
                lbl_catch.Text += "Weight has to float type \n";
            }
            if (!float.TryParse(txt_UnitPrice.Text, out m))
            {
                lbl_catch.Text += "UnitPrice has to float type \n";
            }
            // pass valid
            if (lbl_catch.Text == "")
            {
                Entities.Product product = new Entities.Product();

                product.CategoryID = int.Parse(ddl_Category.SelectedValue.ToString());
                product.ProductName = txt_ProductName.Text;
                product.Output = int.Parse(txt_Output.Text);
                product.MadeGoodsSize = double.Parse(txt_MadeGoods.Text);
                product.MachineSize = txt_MachineSize.Text;
                product.Weight = double.Parse(txt_Weight.Text);
                product.Picture = imageurl;
                product.UnitPrice = decimal.Parse(txt_UnitPrice.Text);
                product.ExtraDescription = txt_ExtraDescription.Text;
                if (check_insert)
                {
                    products_bl.ProductInsert(product);
                }
                else
                {
                    product.ProductID = int.Parse(lbl_ProductId.Text.Trim());
                    products_bl.ProductUpdate(product);
                }
                BindingGrid();
                pnlShow.Visible = true;
                pnlUpdate.Visible = false;

            }
        }