Пример #1
0
        private static Product DBMapping(DBProduct dbItem)
        {
            if (dbItem == null)
                return null;

            Product item = new Product();
            item.ProductID = dbItem.ProductID;
            item.Name = dbItem.Name;
            item.ShortDescription = dbItem.ShortDescription;
            item.FullDescription = dbItem.FullDescription;
            item.AdminComment = dbItem.AdminComment;
            item.ProductTypeID = dbItem.ProductTypeID;
            item.TemplateID = dbItem.TemplateID;
            item.ShowOnHomePage = dbItem.ShowOnHomePage;
            item.MetaKeywords = dbItem.MetaKeywords;
            item.MetaDescription = dbItem.MetaDescription;
            item.MetaTitle = dbItem.MetaTitle;
            item.SEName = dbItem.SEName;
            item.AllowCustomerReviews = dbItem.AllowCustomerReviews;
            item.AllowCustomerRatings = dbItem.AllowCustomerRatings;
            item.RatingSum = dbItem.RatingSum;
            item.TotalRatingVotes = dbItem.TotalRatingVotes;
            item.Published = dbItem.Published;
            item.Deleted = dbItem.Deleted;
            item.CreatedOn = dbItem.CreatedOn;
            item.UpdatedOn = dbItem.UpdatedOn;

            return item;
        }
Пример #2
0
        internal void AddNewCable(CableVO p)
        {
            int ID = new DBProduct().AddNewProduct(p);

            DA.InsertCommand.Parameters.Clear();
            DA.InsertCommand.Parameters.AddWithValue("ID", ID);
            DA.InsertCommand.Parameters.AddWithValue("CABLENAME", p.WPName);
            DA.InsertCommand.Parameters.AddWithValue("IDCATEGORY", p.IDCat);
            DA.InsertCommand.Parameters.AddWithValue("IDSUBCAT", p.IDSubCat);
            DA.InsertCommand.Parameters.AddWithValue("DECNUM", p.DecNum);
            DA.InsertCommand.Parameters.AddWithValue("DIMENSIONALDRAWING", ((object)p.DIMENDRAWING) ?? DBNull.Value);
            DA.InsertCommand.Parameters.AddWithValue("MECHPARTS", ((object)p.MECHPARTS) ?? DBNull.Value);
            DA.InsertCommand.Parameters.AddWithValue("CLENGTH", p.CLENGTH);
            DA.InsertCommand.Parameters.AddWithValue("CONNECTORS", p.CONECTORS);
            DA.InsertCommand.Parameters.AddWithValue("NOTE", p.NOTE);
            DA.InsertCommand.Parameters.AddWithValue("CREATED", DateTime.Now);

            //wp.ZHGUTS = new DBZhgutList().GetPackageForVO(wp.ID);
            /////////////////////////////////////////////////////////////////////////////////    ЗАПРЕЩЕНО НАПОЛНЯТЬ ЖГУТЫ КОГДА СОЗДАЁШЬ ИЗДЕЛИЕ!!!!!!!!!!!!!!!!!
            //wp.CABLES = new DBCableList().GetPackageForVO(wp.ID);

            DA.InsertCommand.CommandText = "insert into " + Base.BaseName + "..CABLELIST " +
                                           " (ID,CABLENAME,IDCATEGORY,IDSUBCAT,DECNUM,DIMENSIONALDRAWING,MECHPARTS,CLENGTH,CONNECTORS, " +
                                           " NOTE,CREATED)      " +
                                           " values (@ID,@CABLENAME,@IDCATEGORY,@IDSUBCAT,@DECNUM,@DIMENSIONALDRAWING,@MECHPARTS,@CLENGTH,@CONNECTORS, " +
                                           " @NOTE,@CREATED)      ";
            DA.InsertCommand.Connection.Open();
            DA.InsertCommand.ExecuteNonQuery();
            DA.InsertCommand.Connection.Close();
        }
 private DBProduct GetProductFromReader(IDataReader dataReader)
 {
     DBProduct product = new DBProduct();
     product.ProductID = NopSqlDataHelper.GetInt(dataReader, "ProductID");
     product.Name = NopSqlDataHelper.GetString(dataReader, "Name");
     product.ShortDescription = NopSqlDataHelper.GetString(dataReader, "ShortDescription");
     product.FullDescription = NopSqlDataHelper.GetString(dataReader, "FullDescription");
     product.AdminComment = NopSqlDataHelper.GetString(dataReader, "AdminComment");
     product.ProductTypeID = NopSqlDataHelper.GetInt(dataReader, "ProductTypeID");
     product.TemplateID = NopSqlDataHelper.GetInt(dataReader, "TemplateID");
     product.ShowOnHomePage = NopSqlDataHelper.GetBoolean(dataReader, "ShowOnHomePage");
     product.MetaKeywords = NopSqlDataHelper.GetString(dataReader, "MetaKeywords");
     product.MetaDescription = NopSqlDataHelper.GetString(dataReader, "MetaDescription");
     product.MetaTitle = NopSqlDataHelper.GetString(dataReader, "MetaTitle");
     product.SEName = NopSqlDataHelper.GetString(dataReader, "SEName");
     product.AllowCustomerReviews = NopSqlDataHelper.GetBoolean(dataReader, "AllowCustomerReviews");
     product.AllowCustomerRatings = NopSqlDataHelper.GetBoolean(dataReader, "AllowCustomerRatings");
     product.RatingSum = NopSqlDataHelper.GetInt(dataReader, "RatingSum");
     product.TotalRatingVotes = NopSqlDataHelper.GetInt(dataReader, "TotalRatingVotes");
     product.Published = NopSqlDataHelper.GetBoolean(dataReader, "Published");
     product.Deleted = NopSqlDataHelper.GetBoolean(dataReader, "Deleted");
     product.CreatedOn = NopSqlDataHelper.GetUtcDateTime(dataReader, "CreatedOn");
     product.UpdatedOn = NopSqlDataHelper.GetUtcDateTime(dataReader, "UpdatedOn");
     return product;
 }
Пример #4
0
        // POST <controller>
        public int Post([FromBody] DBProduct value)
        {
            db.Products.Add(value);
            db.SaveChanges();

            return(value.Id);
        }
 public static bool UpdateQuantity(string idProduct, string quantity)
 {
     try
     {
         string[] product = new string[] { idProduct, quantity };
         if (ValidateData.VerifyFields(product))
         {
             ProductModel productModel = new ProductModel()
             {
                 IdProduct        = int.Parse(idProduct),
                 variableQuantity = int.Parse(quantity)
             };
             return(DBProduct.UpdateQuantity(productModel));
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         //Log4Net
         return(false);
     }
 }
Пример #6
0
 public static List <Product> GetByOrder(
     int siteId,
     int orderId,
     int languageId = -1)
 {
     return(LoadListFromReader(DBProduct.GetByOrder(siteId, orderId, languageId)));
 }
Пример #7
0
 public void initial()
 {
     DBProduct.getInstance().init();
     DBProduct.getInstance().init();
     store = new Store("store1", "games store");
     cart  = new ShoppingCart(store.getStoreID());
 }
Пример #8
0
        private bool Create()
        {
            int newID = 0;

            productGuid = Guid.NewGuid();
            createdUtc  = DateTime.UtcNow;

            newID = DBProduct.Create(
                this.siteID,
                this.zoneID,
                this.title,
                this.subTitle,
                this.url,
                this.code,
                this.briefContent,
                this.fullContent,
                this.productType,
                this.openInNewWindow,
                this.position,
                this.showOption,
                this.isPublished,
                this.startDate,
                this.endDate,
                this.displayOrder,
                this.price,
                this.oldPrice,
                this.specialPrice,
                this.specialPriceStartDate,
                this.specialPriceEndDate,
                this.viewCount,
                this.commentCount,
                this.metaTitle,
                this.metaKeywords,
                this.metaDescription,
                this.additionalMetaTags,
                this.compiledMeta,
                this.manufacturerID,
                this.stockQuantity,
                this.disableBuyButton,
                this.fileAttachment,
                this.productGuid,
                this.userGuid,
                this.createdUtc,
                this.lastModUtc,
                this.lastModUserGuid,
                this.isDeleted);

            this.productID = newID;

            bool result = (newID > 0);

            //IndexHelper.IndexItem(this);
            if (result)
            {
                ContentChangedEventArgs e = new ContentChangedEventArgs();
                OnContentChanged(e);
            }

            return(result);
        }
        public JsonResult getResults(string term)
        {
            var db = new DBProduct();
            List<string> foundProducts = db.getAutoComplete(term);

            return Json(foundProducts, JsonRequestBehavior.AllowGet);
        }
Пример #10
0
 public static List <Product> GetByShoppingCart(
     int siteId,
     Guid cartGuid,
     int languageId = -1)
 {
     return(LoadListFromReader(DBProduct.GetByShoppingCart(siteId, cartGuid, languageId)));
 }
Пример #11
0
        internal void AddNewZhgut(ZhgutVO p)
        {
            int ID = new DBProduct().AddNewProduct(p);

            DA.InsertCommand.Parameters.Clear();
            DA.InsertCommand.Parameters.AddWithValue("ID", ID);
            DA.InsertCommand.Parameters.AddWithValue("ZHGUTNAME", p.WPName);
            DA.InsertCommand.Parameters.AddWithValue("IDCATEGORY", p.IDCat);
            DA.InsertCommand.Parameters.AddWithValue("IDSUBCAT", p.IDSubCat);
            DA.InsertCommand.Parameters.AddWithValue("DECNUM", p.DecNum);
            DA.InsertCommand.Parameters.AddWithValue("ZHGUTPATH", ((object)p.ZHGUTPATH) ?? DBNull.Value);
            DA.InsertCommand.Parameters.AddWithValue("NOTE", p.NOTE);
            DA.InsertCommand.Parameters.AddWithValue("CREATED", DateTime.Now);

            //wp.ZHGUTS = new DBZhgutList().GetPackageForVO(wp.ID);
            /////////////////////////////////////////////////////////////////////////////////    ЗАПРЕЩЕНО НАПОЛНЯТЬ ЖГУТЫ КОГДА СОЗДАЁШЬ ИЗДЕЛИЕ!!!!!!!!!!!!!!!!!
            //wp.CABLES = new DBCableList().GetPackageForVO(wp.ID);

            DA.InsertCommand.CommandText = "insert into " + Base.BaseName + "..ZHGUTLIST " +
                                           " (ID,ZHGUTNAME,IDCATEGORY,IDSUBCAT,DECNUM,ZHGUTPATH, " +
                                           " NOTE,CREATED)      " +
                                           " values (@ID,@ZHGUTNAME,@IDCATEGORY,@IDSUBCAT,@DECNUM,@ZHGUTPATH, " +
                                           " @NOTE,@CREATED)      ";
            DA.InsertCommand.Connection.Open();
            DA.InsertCommand.ExecuteNonQuery();
            DA.InsertCommand.Connection.Close();
        }
Пример #12
0
        public JsonResult getResults(string term)
        {
            var           db            = new DBProduct();
            List <string> foundProducts = db.getAutoComplete(term);

            return(Json(foundProducts, JsonRequestBehavior.AllowGet));
        }
Пример #13
0
        public ActionResult viewProduct(int id)
        {
            var     db = new DBProduct();
            Product p  = db.get(id);

            return(View(p));
        }
Пример #14
0
 public static DataTable GetListForPageOfOffers(
     Guid storeGuid,
     int pageNumber,
     int pageSize)
 {
     return(DBProduct.GetListForPageOfOffers(storeGuid, pageNumber, pageSize));
 }
Пример #15
0
        internal Cart Map(DBCart dbCart)
        {
            DBProduct prod = db.Products.Find(dbCart.ProductId);

            if (prod == null)
            {
                return(null);
            }

            DBCategory c = db.Categories.Find(prod.CategoryId);

            if (dbCart == null)
            {
                return(null);
            }

            return(new Cart()
            {
                Product = new Product
                {
                    Id = prod.Id,
                    Name = prod.Name,
                    Price = prod.Price,
                    Category = new Category {
                        Id = c.Id, Name = c.Name
                    },
                    Image = prod.Image,
                    Description = prod.Description
                },
                Quantity = dbCart.Quantity
            });
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="idProduct"></param>
 /// <param name="code"></param>
 /// <param name="style"></param>
 /// <param name="idBrand"></param>
 /// <param name="description"></param>
 /// <param name="idCategory"></param>
 /// <param name="idSubCategory"></param>
 /// <param name="normalPrice"></param>
 /// <param name="lowerPrice"></param>
 /// <param name="estableQuantity"></param>
 /// <param name="variableQuantity"></param>
 /// <param name="image"></param>
 /// <param name="ivi"></param>
 /// <param name="existingInvoice"></param>
 /// <param name="size"></param>
 /// <returns></returns>
 public static bool UpdateProductById(
     string idProduct,
     string code, string style,
     string idBrand,
     string description,
     string idSubCategory,
     string normalPrice,
     string lowerPrice,
     string estableQuantity,
     string variableQuantity,
     byte[] image,
     bool ivi,
     bool existingInvoice
     )
 {
     try
     {
         string[] product = new string[] {
             idProduct,
             code, style,
             idBrand,
             description,
             idSubCategory,
             normalPrice,
             lowerPrice,
             estableQuantity,
             variableQuantity
         };
         if (ValidateData.VerifyFields(product))
         {
             ProductModel productModel = new ProductModel()
             {
                 IdProduct        = int.Parse(idProduct),
                 Code             = code,
                 Style            = style,
                 IdBrand          = int.Parse(idBrand),
                 Description      = description,
                 IdSubCategory    = int.Parse(idSubCategory),
                 NormalPrice      = decimal.Parse(normalPrice),
                 LowerPrice       = decimal.Parse(lowerPrice),
                 EstableQuantity  = int.Parse(estableQuantity),
                 VariableQuantity = int.Parse(variableQuantity),
                 Ivi             = ivi,
                 ExistingInvoice = existingInvoice,
                 Image           = image
             };
             return(DBProduct.UpdateProduct(productModel));
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         //Log4Net
         return(false);
     }
 }
Пример #17
0
        public static Product GetOneByZone(int zoneId, int languageId)
        {
            Product news = new Product();

            PopulateProduct(news, DBProduct.GetOne(zoneId, DateTime.UtcNow, languageId));

            return(news);
        }
Пример #18
0
 public static List <Product> GetByGuids(
     int siteId,
     string productGuids,
     int publishStatus = -1,
     int languageId    = -1)
 {
     return(LoadListFromReader(DBProduct.GetByGuids(siteId, productGuids, publishStatus, languageId)));
 }
Пример #19
0
 public static List <Product> GetByTag(
     int siteId,
     int tagId,
     int publishStatus = -1,
     int languageId    = -1)
 {
     return(LoadListFromReader(DBProduct.GetByTag(siteId, tagId, publishStatus, languageId)));
 }
Пример #20
0
 public static int GetCount(
     int siteId,
     int zoneId,
     int languageId,
     int position)
 {
     return(DBProduct.GetCount(siteId, zoneId, DateTime.UtcNow, languageId, position));
 }
Пример #21
0
 public static DataTable GetPageForAdminList(
     Guid storeGuid,
     int pageNumber,
     int pageSize,
     out int totalPages)
 {
     return(DBProduct.GetPageForAdminList(storeGuid, pageNumber, pageSize, out totalPages));
 }
Пример #22
0
 public static int GetCountByListZone(
     int siteId,
     string listZoneId,
     int languageId,
     int position)
 {
     return(DBProduct.GetCountByListZone(siteId, listZoneId, languageId, position));
 }
Пример #23
0
        private bool Update()
        {
            Product product = new Product(this.guid);

            DBProduct.AddHistory(
                Guid.NewGuid(),
                product.Guid,
                product.StoreGuid,
                product.TaxClassGuid,
                string.Empty,
                ConvertProductStatusToByte(product.Status),
                ConvertFulfillmentTypeToByte(product.FulfillmentType),
                product.Weight,
                product.QuantityOnHand,
                product.ImageFileName,
                product.ImageFileBytes,
                product.Created,
                product.CreatedBy,
                product.LastModified,
                product.LastModifedBy,
                DateTime.UtcNow,
                product.shippingAmount);

            bool result = DBProduct.Update(
                this.guid,
                this.taxClassGuid,
                this.modelNumber,
                this.status,
                this.fulfillmentType,
                this.weight,
                this.quantityOnHand,
                this.imageFileName,
                this.imageFileBytes,
                this.lastModified,
                this.lastModifedBy,
                this.url,
                this.name,
                this.description,
                this.teaser,
                this.showInProductList,
                this.enableRating,
                this.metaDescription,
                this.metaKeywords,
                this.sortRank1,
                this.sortRank2,
                this.teaserFile,
                this.teaserFileLink,
                this.compiledMeta,
                this.shippingAmount);

            if (result)
            {
                ContentChangedEventArgs e = new ContentChangedEventArgs();
                OnContentChanged(e);
            }

            return(result);
        }
Пример #24
0
 public void TestInitialize()
 {
     DBProduct.getInstance().initDB();
     p  = new Product("pizza", "food", 40, 0, 10, s);
     p1 = new Product("fries", "food", 20, 2, 10, s);
     p2 = new Product("coca cola", "drinks", 8, 2, 10, s);
     p3 = new Product("ketchup", "sauces", 2, 0, 10, s);
     p4 = new Product("coca cola zero", "drinks", 8, 4, 10, s);
 }
Пример #25
0
        public void addProductSuccTest()
        {
            Assert.AreEqual("", sr1.addProduct(p));

            Product returnP = DBProduct.getInstance().getProductByID(p.getProductID());

            Assert.AreEqual(returnP, p);
            Assert.AreEqual(store.getProductList().Contains(p), true);
        }
Пример #26
0
 /// <summary>
 /// Gets a related product collection by product identifier
 /// </summary>
 /// <param name="productGuid">The first product identifier</param>
 /// <param name="showHidden">A value indicating whether to show hidden records</param>
 /// <param name="twoWayRelated">two-way relationship</param>
 /// <returns>Related product collection</returns>
 public static List <Product> GetRelatedProducts(
     int siteId,
     Guid productGuid,
     bool showHidden    = false,
     bool twoWayRelated = false,
     int languageId     = -1)
 {
     return(LoadListFromReader(DBProduct.GetRelatedProducts(siteId, productGuid, showHidden, twoWayRelated, languageId)));
 }
Пример #27
0
        public static DataTable GetBySitePage(int siteId, int pageId)
        {
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("ModuleID", typeof(int));
            dataTable.Columns.Add("ModuleTitle", typeof(string));
            dataTable.Columns.Add("Guid", typeof(Guid));
            dataTable.Columns.Add("ModelNumber", typeof(string));
            dataTable.Columns.Add("Url", typeof(string));
            dataTable.Columns.Add("Name", typeof(string));
            dataTable.Columns.Add("Abstract", typeof(string));
            dataTable.Columns.Add("Description", typeof(string));
            dataTable.Columns.Add("MetaDescription", typeof(string));
            dataTable.Columns.Add("MetaKeywords", typeof(string));
            dataTable.Columns.Add("ViewRoles", typeof(string));

            dataTable.Columns.Add("Created", typeof(DateTime));
            dataTable.Columns.Add("LastModified", typeof(DateTime));
            dataTable.Columns.Add("ShippingAmount", typeof(Decimal));

            using (IDataReader reader = DBProduct.GetProductByPage(siteId, pageId))
            {
                while (reader.Read())
                {
                    DataRow row = dataTable.NewRow();


                    row["ModuleID"]        = reader["ModuleID"];
                    row["ModuleTitle"]     = reader["ModuleTitle"];
                    row["Guid"]            = new Guid(reader["Guid"].ToString());
                    row["ModelNumber"]     = reader["ModelNumber"];
                    row["Url"]             = reader["Url"];
                    row["Name"]            = reader["Name"];
                    row["Abstract"]        = reader["Abstract"];
                    row["Description"]     = reader["Description"];
                    row["MetaDescription"] = reader["MetaDescription"];
                    row["MetaKeywords"]    = reader["MetaKeywords"];
                    row["ViewRoles"]       = reader["ViewRoles"];

                    row["Created"]      = Convert.ToDateTime(reader["Created"]);
                    row["LastModified"] = Convert.ToDateTime(reader["LastModified"]);
                    if (reader["ShippingAmount"] != DBNull.Value)
                    {
                        row["ShippingAmount"] = Convert.ToDecimal(reader["ShippingAmount"]);
                    }
                    else
                    {
                        row["ShippingAmount"] = 0;
                    }

                    dataTable.Rows.Add(row);
                }
            }

            return(dataTable);
        }
Пример #28
0
 public static List <Product> GetPageByListZone(
     int siteId,
     string listZoneId,
     int languageId,
     int position,
     int pageNumber,
     int pageSize)
 {
     return(LoadListFromReader(DBProduct.GetPageByListZone(siteId, listZoneId, languageId, position, pageNumber, pageSize)));
 }
Пример #29
0
 private Product Map(DBProduct product)
 {
     return(new Product
     {
         Id = product.Id,
         Name = product.Name,
         Price = product.Price,
         Category = (ProductCategory)product.Category
     });
 }
Пример #30
0
        public void removeProductSuccTest()
        {
            sr.addProduct(p);
            Assert.AreEqual("", sr1.removeProduct(p));

            Product returnP = DBProduct.getInstance().getProductByID(p.getProductID());

            Assert.AreEqual(returnP, null);
            Assert.AreEqual(store.getProductList().Contains(p), false);
        }
Пример #31
0
 public static List <Product> GetPageProductOther(
     int zoneId,
     int productId,
     int languageId,
     int pageNumber,
     int pageSize,
     out int totalPages)
 {
     return(LoadListFromReader(DBProduct.GetPageProductOther(zoneId, productId, DateTime.UtcNow, languageId, pageNumber, pageSize, out totalPages)));
 }
Пример #32
0
 public ActionResult Edit(DBProduct product)
 {
     if (this.Authorizer.IsLogedIn(this.Session, this.Request) && this.ModelState.IsValid)
     {
         this.Authorizer.ReauthorizeLogin(this.Session);
         new DBProductRepository(this.DatabaseContext).Update(product, true);
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("Index", "Login"));
 }
Пример #33
0
 public static List <Product> GetPage(
     int siteId,
     int zoneId,
     int languageId,
     int position,
     int pageNumber,
     int pageSize)
 {
     return(LoadListFromReader(DBProduct.GetPage(siteId, zoneId, DateTime.UtcNow, languageId, position, pageNumber, pageSize)));
 }
        public ActionResult addToCart(int quantity, int itemnumber)
        {
            var db = new DBProduct();
            Product p = db.get(itemnumber);
            ShoppingCart cart = getCart();
            if (cart == null)
                return Json(false);  
            ShoppingCartItem item = new ShoppingCartItem(p, quantity);
            List<ShoppingCartItem> list = cart.shoppingCartItems;
            cart.sum += p.price * quantity;
            list.Add(item);

            return RedirectToAction("viewShoppingCart");
        }
 public ActionResult Search(string searchString)
 {
     var db = new DBProduct();
     List<Product> listOfProducts;
     
     if(!String.IsNullOrEmpty(searchString))
     {
         listOfProducts = db.getResult(searchString);
         return View(listOfProducts);
     }
     else
     {
         listOfProducts = db.getResult("Tomt");
         return View(listOfProducts);
     }
 }
 public ActionResult ListProducts(int? id, string sc, int? sort)
 {
     var db = new DBProduct();
     List<Product> listOfProducts;
     if(sc != null && sc.Equals("yes"))
       {
         listOfProducts = db.getAll(id,sc,sort);
       }
     else
      {
         
         listOfProducts = db.getAll(id,sort);
      }
     
     return View(listOfProducts);
 }
Пример #37
0
		/// <summary>
		/// 获取连接字符串
		/// </summary>
		public static string GetConnectionString(DBProduct p, string Server, int Port, string Uid, string Pwd, string dbName = "master", string Option = "")
		{
			string str = string.Empty;
			switch (p)
			{
				case DBProduct.MySql:
					str = MySql.MySqlConnection.GetConnectionString(Server, Port, Uid, Pwd, dbName);
					break;

				case DBProduct.MsSql:
				default:
					str = SQLServer.SqlConnection.GetConnectionString(Server, Port, Uid, Pwd, dbName);
					break;
			}

			if (!string.IsNullOrEmpty(Option))
			{
				str += Option;
			}
			return str;
		}
 public ActionResult viewProduct(int id)
 {
     var db = new DBProduct();
     Product p = db.get(id);
     return View(p);
 }