コード例 #1
0
        public JsonResult Autocomplete(string Prefix)
        {
            ProductDAL _product = new ProductDAL();
            var        EmpDet   = _product.GetItemList(Prefix).Select(s => new { Name = s.Text, Id = s.Value });

            return(Json(EmpDet, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "OrderDetailID,OrderID,ProductID,ProductName,ProductCode,UnitPrice,Quantity,PromotionPrice,CreateDate,CreateUser,ModifiedDate,ModifiedUser,IsActive")] OrderDetail orderDetail)
        {
            var UserSession = (UserLogin)Session[TechDeviShopVs002.Common.CommonConstants.USER_SESSION];

            if (ModelState.IsValid)
            {
                var _dal = new OrderDetailsDAL();

                orderDetail.CreateUser = UserSession.UserID;
                var pd = new ProductDAL().ViewDetail(orderDetail.ProductID);
                orderDetail.ProductName    = pd.ProductName;
                orderDetail.ProductCode    = pd.ProductCode;
                orderDetail.UnitPrice      = pd.Price;
                orderDetail.PromotionPrice = pd.PromotionPrice;

                int id = _dal.Insert(orderDetail);
                if (id > 0)
                {
                    return(RedirectToAction("Index", "OrderDetails"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm Chi tiết hóa đơn ko thành công");
                }
            }
            ViewBag.OrderID   = new SelectList(db.Orders, "OrderID", "OrderID", orderDetail.OrderID);
            ViewBag.ProductID = new SelectList(db.Products, "ProductID", "ProductName", orderDetail.ProductID);
            //ViewBag.ProductName = new SelectList(db.Products, "ProductName", "ProductName", orderDetail.ProductName);
            //ViewBag.ProductCode = new SelectList(db.Products, "ProductCode", "ProductCode", orderDetail.ProductCode);
            //ViewBag.UnitPrice = new SelectList(db.Products, "UnitPrice", "Price", orderDetail.UnitPrice);
            //ViewBag.PromotionPrice = new SelectList(db.Products, "PromotionPrice", "PromotionPrice", orderDetail.PromotionPrice);
            return(View(orderDetail));
        }
コード例 #3
0
        // GET: Home
        public ActionResult Index()
        {
            ViewBag.TitlePage = "Online Shopping | Home";
            ViewBag.Page      = "Home";

            HomeProductsModel homeProduct = new HomeProductsModel();
            ProductDAL        productDal  = new ProductDAL();

            List <Product> products = productDal.getTopNewProduct();

            homeProduct.NewProducts = products;

            products = productDal.getTopTrending();
            homeProduct.TrendingProducts = products;

            products = productDal.getTopBestSeller();
            homeProduct.BestSellerProducts = products;

            CatalogueDAL     catalogueDal = new CatalogueDAL();
            List <Catalogue> catalogues   = catalogueDal.getAllCatalogues();

            homeProduct.Catalogues = catalogues;

            return(View(homeProduct));
        }
コード例 #4
0
        public IActionResult Add(ProductsDTO productsDTO)
        {
            ProductDAL ProductDAL = new ProductDAL();

            ProductDAL.SaveProduct(productsDTO);
            return(RedirectToAction("ProductListing"));
        }
コード例 #5
0
        public ActionResult SubmitProductsValues(ProductModel productModel)
        {
            //! Pulling DATA from db using DbContext
            var proDAL = new ProductDAL();

            //! Loop through model.ProductsCollection
            foreach (var p in productModel.ProductsCollection)
            {
                //! Matching the current product
                var query = proDAL.Products.FirstOrDefault(q => q.Id == p.Id);

                if (query != null)
                {
                    if (p.pExist != true)
                    {
                        /*
                         * pExist it's an Indicator about the product lifetime.
                         * */
                        query.Quantity = p.Quantity;
                        proDAL.SaveChanges();
                    }
                    else
                    {
                        //! pExist True; means it was mark to be removed
                        query.pExist = false;
                        proDAL.Products.Remove(query);
                        proDAL.SaveChanges();
                    }
                }
            }
            //! All-set redirecting view.
            return(View("SubmitProductsValues"));
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: ACGDev/ACGConsole
        private static void AddAmazonASIN()
        {
            /* All qualified records are inserted in temporary table Channel_Sales_Helper_Details
             * If the previous set of update was not complete, it does not allow the update to go forward
             * This allow for updates in several stages.
             * only first 100 records are used every time.
             * */

            KeyValuePair <string, string> type = new KeyValuePair <string, string>("Product", "_POST_PRODUCT_DATA_");

            int nTotalAsins = 0;

            while (true)
            {
                Console.WriteLine("\n\n** New Cycle: Collecting data for Feed at {0}", DateTime.Now);
                var liObj = ProductDAL.GetASINForAmazonFeed(ConfigurationHelper.ConnectionString, type.Key, ref nTotalAsins);
                if (liObj.Count == 0)
                {
                    ProductDAL.UpdateProductAfterAmazonFeed(ConfigurationHelper.ConnectionString, liObj, type.Key);
                    break;
                }

                Console.WriteLine("\n\nSending feed for {0} ASINs out of total {1}", liObj.Count, nTotalAsins);

                SendAmazonFeed(type, liObj);

                if (nTotalAsins <= liObj.Count)
                {
                    ProductDAL.UpdateProductAfterAmazonFeed(ConfigurationHelper.ConnectionString, liObj, type.Key, nTotalAsins);
                    break;
                }
                Console.WriteLine("Going to sleep for 1 min at {0}", DateTime.Now);
                Thread.Sleep(60000);
            }
        }
コード例 #7
0
        protected void Output1_Click(object sender, EventArgs e)
        {
            ProductDAL product = new ProductDAL();

            product.Name      = TextBoxForProc.Text;
            LabelForProc.Text = product.ForProc();
        }
コード例 #8
0
        public static bool Insert(Product product)
        {
            bool status = false;

            status = ProductDAL.Insert(product);
            return(status);
        }
コード例 #9
0
        public static bool Updatequant(Product Prodfound)
        {
            bool status = false;

            status = ProductDAL.Updatequant(Prodfound);
            return(status);
        }
コード例 #10
0
ファイル: ProductTest.cs プロジェクト: wenfeifei/WinForm-
        public void UpdataTest()
        {
            Product p = new Product();

            p.ProductID     = "4";
            p.ProductName   = "苹";
            p.SpellingCode  = "4234";
            p.Barcode       = "4234";
            p.Unit          = "斤";
            p.Origin        = "4214";
            p.Special       = "45646";
            p.CategoryID    = "1";
            p.PurchasePrice = 20.00;
            p.SalePrice     = 49.00;
            p.Quantity      = 1;


            ProductDAL target = new ProductDAL();


            bool atual    = target.Update(p);         //实际的结果
            bool expected = true;                     //预期的结果

            Assert.AreEqual(expected, atual);         //断言判等
        }
コード例 #11
0
        public static List <Product> GetAllProduct()
        {
            List <Product> Product = new List <Product>();

            Product = ProductDAL.GetAll();
            return(Product);
        }
コード例 #12
0
ファイル: OrderDAL.cs プロジェクト: sorrymeika/Gllo
        public JsonArray GetOrderDetails(int orderId, int userId)
        {
            using (helper = new SqlHelper())
            {
                helper.AddIntParameter("@OrderID", orderId);
                helper.AddIntParameter("@UserID", userId);

                int regionID = helper.GetIntValue("select RegionID from Orders where OrderID=@OrderID", CommandType.Text);

                string sql = "select DetailID,a.OrderID,a.ProductID,a.Discount,OrignalPrice,a.Quantity,b.Name,b.Code,Url,Points,Express.ExpressID,ExpressName,b.Freight,b.Freight1 from OrderDetails a inner join Products b on a.ProductID=b.ProductID inner join Orders c on a.OrderID=c.OrderID left join (select PictureDesc,Url,a.ProductID as PID from ProductPictures b inner join (select ProductID,min(PictureID) as PictureID from ProductPictures group by ProductID) a on a.PictureID=b.PictureID) d on PID=a.ProductID left join Express on Express.ExpressID=c.ExpressID where UserID=@UserID and a.OrderID=@OrderID";

                var        details = helper.GetJsonArray(sql, CommandType.Text);
                ProductDAL productDAL = new ProductDAL();
                int        productID, qty;
                foreach (var detail in details)
                {
                    productID = (int)detail["ProductID"];
                    qty       = (int)detail["Quantity"];
                    var freight = productDAL.GetProductFreight(productID, regionID);
                    detail["Freight"]  = freight[0];
                    detail["Freight1"] = freight[1];
                }

                return(details);
            }
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: ACGDev/ACGConsole
        private async Task CreateOrders(ConfigurationData configData, List <customers> customers, List <products> products)
        {
            List <string> dealers = ProductDAL.GetDistinctDealerItem(configData.ConnectionString);
            List <orders> orders  = OrderDAL.FetchOrders(configData.ConnectionString,
                                                         order => order.orderdate >= DateTime.Parse("12/11/2017"));

            foreach (var o in orders)
            {
                if (!string.IsNullOrEmpty(o.orderno))
                {
                    var customer = customers.FirstOrDefault(I => I.customer_id == o.customerid);
                    if (customer != null && customer.qb_customer_id.HasValue)
                    {
                        string response = await CreateInvoice(quickbooksURL, o, customer.qb_customer_id.Value.ToString(),
                                                              customer.non_taxable, products, (dealers.Contains(customer.billing_firstname)));

                        if (!response.StartsWith("error"))
                        {
                            //JToken outer = JToken.Parse(response);
                            //var pId = outer["Invoice"]["Id"].Value<int>();
                            //o.qb_product_id = pId;
                            //ProductDAL.UpdateProduct(configData, pId, prod.SKU);
                        }
                    }
                }
            }
        }
コード例 #14
0
        private void btnAddCrudShop_Click(object sender, EventArgs e)
        {
            ProductDAL productDAL = new ProductDAL();
            UserDAL    userDAL    = new UserDAL();

            if (cmbCategoryCrudShop.Text != "" && txbCountCrudShop.Text != "" && txbPriceCrudShop.Text != "")
            {
                Product product = new Product()
                {
                    Name       = this.txbNameCrudShop.Text,
                    CategoryId = Convert.ToInt32(this.cmbCategoryCrudShop.Text.Split('-')[0]),
                    Count      = Convert.ToInt32(this.txbCountCrudShop.Text),
                    Price      = Convert.ToDouble(this.txbPriceCrudShop.Text),
                    UserId     = CurrentUser.Id,
                    Status     = (int)ProductStatusEnum.Active,
                };
                bool isValid = ValidationOperation <Product> .ValidateOperation(product);

                if (CurrentUser.Type == 2)
                {
                    product.UserId = userDAL.GetByFilter(x => x.Email == this.cmbUserCrudProducts.Text.Split('-')[0]).Id;
                }
                if (isValid)
                {
                    productDAL.Add(product);
                    MessageBox.Show("Successfully Added!");
                    productDAL.GetGridData(dgvShop);
                }
            }
            else
            {
                MessageBox.Show("The field is required");
            }
        }
コード例 #15
0
 public void DeleteProductPriceMapping(int productPriceMappingId)
 {
     using (ProductDAL productDal = new ProductDAL())
     {
         productDal.DeleteProductPriceMapping(productPriceMappingId);
     }
 }
コード例 #16
0
        private void dgvProduct_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataTable data = ProductDAL.GetAllProduct();

            if (dgvProduct.Columns[e.ColumnIndex].Name.Equals("Edit"))
            {
                this.Visible = false;
                Product x = new Product(data.Rows[e.RowIndex]["ProductId"].ToString(),
                                        data.Rows[e.RowIndex]["ProductName"].ToString(),
                                        data.Rows[e.RowIndex]["CategoryId"].ToString(),
                                        data.Rows[e.RowIndex]["Unit"].ToString(),
                                        int.Parse(data.Rows[e.RowIndex]["Price"].ToString()),
                                        int.Parse(data.Rows[e.RowIndex]["Quantity"].ToString()),
                                        bool.Parse(data.Rows[e.RowIndex]["Discontinued"].ToString()),
                                        DateTime.Parse(data.Rows[e.RowIndex]["CreateDate"].ToString()));

                this.Visible = false;
                EditProductGUI editProductGUI = new EditProductGUI(x);
                editProductGUI.ShowDialog();
                RefreshProduct();
                this.Visible = true;
            }
            if (dgvProduct.Columns[e.ColumnIndex].Name.Equals("Delete"))
            {
                if (MessageBox.Show("Do you want delete the this row?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    ProductDAL.DeleteProduct(data.Rows[e.RowIndex]["ProductId"].ToString());
                    RefreshProduct();
                }
                else
                {
                    MessageBox.Show("Delete false.");
                }
            }
        }
コード例 #17
0
ファイル: Program.cs プロジェクト: ACGDev/ACGConsole
        private static void UpdateAmazonPricingData()
        {
            /* Change in logic - All qualified records are inserted in temporary table Channel_Sales_Helper_Details
             * If the previous set of update was not complete, it does not allow the update to go forward
             * This allow for updates in several stages.
             * */

            int nTotalAsins = 0;
            KeyValuePair <string, string> type =
                new KeyValuePair <string, string>("Price", "_POST_PRODUCT_PRICING_DATA_");

            while (true)
            {
                Console.WriteLine("\n\n** New Cycle: Collecting data for Feed at {0}", DateTime.Now);
                var liObj = ProductDAL.GetASINForAmazonFeed(ConfigurationHelper.ConnectionString, type.Key, ref nTotalAsins);
                if (liObj.Count == 0)
                {
                    ProductDAL.UpdateProductAfterAmazonFeed(ConfigurationHelper.ConnectionString, liObj, type.Key, nTotalAsins);
                    break;
                }
                Console.WriteLine("\n\nSending feed for {0} ASINs out of total {1}", liObj.Count, nTotalAsins);

                SendAmazonFeed(type, liObj);
                if (nTotalAsins <= liObj.Count)
                {
                    ProductDAL.UpdateProductAfterAmazonFeed(ConfigurationHelper.ConnectionString, liObj, type.Key, nTotalAsins);
                    break;
                }
                Console.WriteLine("Going to sleep for 30 sec at {0}", DateTime.Now);
                Thread.Sleep(30000);
            }

            // Need to set the flags to 0 and update channel_sales_helper table as well as CK_ASINS table
        }
コード例 #18
0
        //public List<object> GetResult(string str1)
        public string GetResult(string str1)
        {
            ProductDAL productDAL = new ProductDAL();

            //List<object> productDAL = new List<object>();
            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                SqlCommand command = new SqlCommand(str1, connection);
                connection.Open();

                SqlDataReader reader = command.ExecuteReader();
                reader.Read();
                //productDAL.Add[] = reader["Name"].ToString();

                productDAL.Name = reader["Name"].ToString();

                //while (reader.Read())
                //{
                //    //productDAL.Name = reader["Name"].ToString();
                //    //str[i] = productDAL.Name;
                //    productDAL.Add(reader["Name"]);
                //    productDAL.Add(reader["ID"]);
                //    productDAL.Add(reader["Location"]);
                //}
            }
            return(productDAL.Name);
        }
コード例 #19
0
        protected void Button4_Click(object sender, EventArgs e)
        {
            ProductDAL product = new ProductDAL();

            product.Name = TextBoxForSelect.Text;
            Output.Text  = product.SelectStat().ToString();
        }
コード例 #20
0
        public static List <Product> LayDSThietBi()
        {
            List <Product> _ds;

            _ds = ProductDAL.LayDSThietBi();
            return(_ds);
        }
コード例 #21
0
        public void BindGridView()
        {
            ProductDAL product = new ProductDAL();

            GridView2.DataSource = product.GetProducts();
            GridView2.DataBind();
        }
コード例 #22
0
        public static List <Product> LayDSThietBiTheoMaLoai(string maLoai)
        {
            List <Product> _ds;

            _ds = ProductDAL.LayDSThietBiTheoMaLoai(maLoai);
            return(_ds);
        }
コード例 #23
0
        public bool Delete(string productId)
        {
            ProductDAL ProductDAL = new ProductDAL();

            ProductDAL.DeleteProduct(productId);
            return(true);
        }
コード例 #24
0
 public int ManageProduct(ProductVM product)
 {
     using (ProductDAL productDal = new ProductDAL())
     {
         return(productDal.ManageProduct(product));
     }
 }
コード例 #25
0
        // GET: Product
        public ActionResult ProductDetails(string productIDStr)
        {
            int id = 1;

            if (int.TryParse(productIDStr, out id))
            {
                id = int.Parse(productIDStr);
            }

            ProductDAL   productDal   = new ProductDAL();
            Product      product      = productDal.getProductById(id);
            CatalogueDAL catalogueDal = new CatalogueDAL();
            Catalogue    catalogue    = catalogueDal.getCatalogueById(product.Catalogue_ID);

            catalogueDal.getAllProductsByCatalogue(catalogue);
            List <Catalogue> catalogues = catalogueDal.getAllCatalogues();

            ProductDetailsModel productDetails = new ProductDetailsModel
            {
                ProductCatalogue = catalogue,
                ProductDetails   = product,
                Catalogues       = catalogues,
            };

            return(View(productDetails));
        }
コード例 #26
0
 public int ManageProductPriceMap(ProductPriceVM productPrice)
 {
     using (ProductDAL productDal = new ProductDAL())
     {
         return(productDal.ManageProductPriceMap(productPrice));
     }
 }
コード例 #27
0
        public List <Order> getAllOrdersbyCust(int id)
        {
            IOrderDAL    _order    = new OrderDAL();
            IProductDAL  _product  = new ProductDAL();
            List <Order> allOrders = _order.getAllOrdersbyCust(id);
            List <Order> list      = new List <Order>();

            foreach (var item in allOrders)
            {
                List <OrderLine> orderlineslist = new List <OrderLine>();
                List <OrderLine> OLlist         = _order.getAllOrderLinesOfOrder(item.id);
                foreach (var OrderLineItems in OLlist)
                {
                    orderlineslist.Add(new OrderLine()
                    {
                        id        = OrderLineItems.id,
                        productid = OrderLineItems.productid,
                        quantity  = OrderLineItems.quantity,
                        product   = _product.findProduct(OrderLineItems.productid),
                        orderid   = OrderLineItems.orderid
                    });
                }
                list.Add(new Order()
                {
                    id         = item.id,
                    orderdate  = item.orderdate,
                    customerid = item.customerid,
                    customer   = _customer.getCustomer(item.customerid),
                    orderLine  = orderlineslist
                });
            }
            return(list);
        }
コード例 #28
0
 public List <ProductVM> GetProducts()
 {
     using (ProductDAL productDal = new ProductDAL())
     {
         return(productDal.GetProducts());
     }
 }
コード例 #29
0
 protected void rpProductList_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Footer)
     {
         ProductDAL dal      = new ProductDAL();
         var        products = dal.GetProductSummaryByProductCode(Code,
                                                                  Name,
                                                                  HuangCode,
                                                                  JiaCode,
                                                                  PianCode,
                                                                  Location,
                                                                  Color,
                                                                  Texure,
                                                                  Supplier,
                                                                  Long,
                                                                  Width,
                                                                  Deep,
                                                                  PriceM,
                                                                  PriceM2
                                                                  );
         var qty            = products.Sum(q => q.QuantityM2).Value;
         var amount         = products.Sum(a => a.PriceM2 * a.QuantityM2).Value;
         var lblTotalSquare = e.Item.FindControl("lblTotalSquare") as Label;
         var lblTotalAmount = e.Item.FindControl("lblTotalAmount") as Label;
         lblTotalSquare.Text = Utility.Round(qty).ToString();
         lblTotalAmount.Text = Utility.Round(amount).ToString();
     }
 }
コード例 #30
0
        public ActionResult Edit(int id)
        {
            Product product = new ProductDAL().GetProductList().Where(p => p.ProductID == id).FirstOrDefault();

            product.ImagePath = "/Images/2" + product.ImagePath.Split('/').Last();
            return(View(product));
        }