Пример #1
0
        public List <Products> GetProductList(string categoryid, string prodiverid, string beginprice, string endprice, string keyWords, string orderby, bool isasc, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string clientID)
        {
            var     dal = new ProductsDAL();
            DataSet ds  = dal.GetProductList(categoryid, prodiverid, beginprice, endprice, keyWords, orderby, isasc ? 1 : 0, pageSize, pageIndex, ref totalCount, ref pageCount, clientID);

            List <Products> list = new List <Products>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Products model = new Products();
                model.FillData(dr);
                if (!string.IsNullOrEmpty(model.CategoryID))
                {
                    model.CategoryName = GetCategoryByID(model.CategoryID).CategoryName;
                }

                if (!string.IsNullOrEmpty(model.UnitID))
                {
                    model.UnitName = GetUnitByID(model.UnitID).UnitName;
                }

                model.IsPublicStr = CommonBusiness.GetEnumDesc((EnumProductPublicStatus)model.IsPublic);

                list.Add(model);
            }
            return(list);
        }
Пример #2
0
 public bool ProductExists(int id)
 {
     using (ProductsDAL dal = new ProductsDAL())
     {
         return(dal.ProductExists(id));
     }
 }
Пример #3
0
 public async Task <Product> GetProduct(int id)
 {
     using (ProductsDAL dal = new ProductsDAL())
     {
         return(await dal.GetProduct(id));
     }
 }
Пример #4
0
 public IQueryable <Product> GetProducts()
 {
     using (ProductsDAL dal = new ProductsDAL())
     {
         return(dal.GetProducts());
     }
 }
Пример #5
0
        public Products GetProductByID(string productid, string clientid)
        {
            var     dal = new ProductsDAL();
            DataSet ds  = dal.GetProductByID(productid);

            Products model = new Products();

            if (ds.Tables.Contains("Product") && ds.Tables["Product"].Rows.Count > 0)
            {
                model.FillData(ds.Tables["Product"].Rows[0]);
                model.Category  = GetCategoryByID(model.CategoryID);
                model.SmallUnit = GetUnitByID(model.UnitID);

                if (!string.IsNullOrEmpty(model.ProviderID))
                {
                    model.Providers = ProvidersBusiness.BaseBusiness.GetProviderByID(model.ProviderID);
                }

                model.ProductDetails = new List <ProductDetail>();
                foreach (DataRow item in ds.Tables["Details"].Rows)
                {
                    //子产品
                    ProductDetail detail = new ProductDetail();
                    detail.FillData(item);

                    model.ProductDetails.Add(detail);
                }
            }

            return(model);
        }
Пример #6
0
        public List <ProductAttr> GetAttrs(string clientid)
        {
            if (ClientAttrs.ContainsKey(clientid))
            {
                return(ClientAttrs[clientid]);
            }

            List <ProductAttr> list = new List <ProductAttr>();
            DataSet            ds   = new ProductsDAL().GetAttrs(clientid);

            foreach (DataRow dr in ds.Tables["Attrs"].Rows)
            {
                ProductAttr model = new ProductAttr();
                model.FillData(dr);
                model.AttrValues = new List <AttrValue>();
                foreach (DataRow item in ds.Tables["Values"].Rows)
                {
                    AttrValue attrValue = new AttrValue();
                    attrValue.FillData(item);
                    model.AttrValues.Add(attrValue);
                }
            }
            ClientAttrs.Add(clientid, list);

            return(list);
        }
Пример #7
0
 public Product GetProductByProductID(Guid ProductID)
 {
     using (ProductsDAL productsDAL = new ProductsDAL())
     {
         return(productsDAL.GetProductByProductID(ProductID));
     }
 }
Пример #8
0
        //可用
        public void GetAllProducts()
        {
            var dal      = new ProductsDAL();
            var userdata = JsonConvert.SerializeObject(dal.getProductsByJson());

            Response.Write(userdata);
        }
Пример #9
0
        private void InsertProduct()
        {
            if (string.IsNullOrEmpty(tbPNameInvoer.Text))
            {
                return;
            }

            Products product = new Products();

            product.productName  = tbPNameInvoer.Text;
            product.discontinued = cbDiscontinued.Checked;
            int productID = ProductsDAL.InsertProduct(product);

            if (productID != 0)
            {
                product.productID = productID;
                ProductIsToegevoegd(EventArgs.Empty);
                string message = string.Format("Product met ID {0} toegevoegd.", product.productID);
                MessageBox.Show(message);
            }
            else
            {
                string message = string.Format("Geen product toegevoegd.");
                MessageBox.Show(message);
            }
        }
Пример #10
0
        /// <summary>
        /// 获取属性列表(包括属性值列表)
        /// </summary>
        public List <ProductAttr> GetAttrList(string categoryid, string keyWords, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string agentid, string clientid)
        {
            var     dal = new ProductsDAL();
            DataSet ds  = dal.GetAttrList(categoryid, keyWords, pageSize, pageIndex, ref totalCount, ref pageCount, clientid);

            List <ProductAttr> list = new List <ProductAttr>();

            if (ds.Tables.Contains("Attrs"))
            {
                foreach (DataRow dr in ds.Tables["Attrs"].Rows)
                {
                    ProductAttr model = new ProductAttr();
                    model.FillData(dr);
                    model.CreateUser = OrganizationBusiness.GetUserByUserID(model.CreateUserID, agentid);

                    List <AttrValue> valueList = new List <AttrValue>();
                    foreach (DataRow drValue in ds.Tables["Values"].Select("AttrID='" + model.AttrID + "'"))
                    {
                        AttrValue valueModel = new AttrValue();
                        valueModel.FillData(drValue);
                        valueList.Add(valueModel);
                    }
                    model.AttrValues = valueList;

                    list.Add(model);
                }
            }
            return(list);
        }
Пример #11
0
 public (bool, Guid) AddProduct(Product product)
 {
     using (ProductsDAL productsDAL = new ProductsDAL())
     {
         return(productsDAL.AddProduct(product));
     }
 }
Пример #12
0
        public List <ProductDTO> GetProducts()
        {
            ProductsDAL       getProducts = new ProductsDAL();
            List <ProductDTO> allProducts = getProducts.GetAllProducts();

            return(allProducts);
        }
Пример #13
0
        public List <Products> GetFilterProducts(string categoryid, List <FilterAttr> Attrs, int doctype, string beginprice, string endprice, string keyWords, string orderby, bool isasc, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string clientID)
        {
            var           dal       = new ProductsDAL();
            StringBuilder attrbuild = new StringBuilder();
            StringBuilder salebuild = new StringBuilder();

            foreach (var attr in Attrs)
            {
                if (attr.Type == EnumAttrType.Parameter)
                {
                    attrbuild.Append(" and p.ValueList like '%" + attr.ValueID + "%'");
                }
                else if (attr.Type == EnumAttrType.Specification)
                {
                    salebuild.Append(" and AttrValue like '%" + attr.ValueID + "%'");
                }
            }

            DataSet ds = dal.GetFilterProducts(categoryid, attrbuild.ToString(), salebuild.ToString(), doctype, beginprice, endprice, keyWords, orderby, isasc ? 1 : 0, pageSize, pageIndex, ref totalCount, ref pageCount, clientID);

            List <Products> list = new List <Products>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Products model = new Products();
                model.FillData(dr);
                list.Add(model);
            }
            return(list);
        }
Пример #14
0
        public void Update(BaseDTO dtoName)
        {
            Type currentType = dtoName.GetType();

            if (currentType.Name.Equals("ProductDTO"))
            {
                ProductsDAL updateProduct = new ProductsDAL();
                updateProduct.UpdateProduct((dtoName as ProductDTO).ProductOldName,
                                            (dtoName as ProductDTO).ProductNewName,
                                            (dtoName as ProductDTO).CategoryName,
                                            (dtoName as ProductDTO).VendorName,
                                            (dtoName as ProductDTO).ProductPrice,
                                            (dtoName as ProductDTO).Quantity,
                                            (dtoName as ProductDTO).StoreName,
                                            (dtoName as ProductDTO).TownName);
                resultMessage = updateProduct.GetCRUDResult();
            }
            if (currentType.Name.Equals("VendorDTO"))
            {
                VendorsDAL updateVendor = new VendorsDAL();
                updateVendor.UpdateVendor((dtoName as VendorDTO).VendorOldName, (dtoName as VendorDTO).VendorName);
                resultMessage = updateVendor.GetCRUDResult();
            }
            if (currentType.Name.Equals("CategoryDTO"))
            {
                CategoriesDAL updateCategory = new CategoriesDAL();
                updateCategory.UpdateCategory((dtoName as CategoryDTO).CategoryOldName, (dtoName as CategoryDTO).CategoryName);
                resultMessage = updateCategory.GetCRUDResult();
            }
            else
            {
                //MessageBox.Show("Pone stigna do tuk v update seckciqta");
            }
        }
Пример #15
0
        public void Delete(BaseDTO dtoName)
        {
            Type currentType = dtoName.GetType();

            if (currentType.Name.Equals("ProductDTO"))
            {
                ProductsDAL deleteProduct = new ProductsDAL();
                deleteProduct.DeleteProduct((dtoName as ProductDTO).ProductNewName);
                resultMessage = deleteProduct.GetCRUDResult();
            }
            if (currentType.Name.Equals("VendorDTO"))
            {
                VendorsDAL deleteVendor = new VendorsDAL();
                deleteVendor.DeleteVendor((dtoName as VendorDTO).VendorName);
                resultMessage = deleteVendor.GetCRUDResult();
            }
            if (currentType.Name.Equals("CategoryDTO"))
            {
                CategoriesDAL deleteCategory = new CategoriesDAL();
                deleteCategory.DeleteCategory((dtoName as CategoryDTO).CategoryName);
                resultMessage = deleteCategory.GetCRUDResult();
            }
            else
            {
                //MessageBox.Show("Pone stigna do tuk v update seckciqta");
            }
        }
Пример #16
0
        public string AddProductDetails(string productid, string productCode, string shapeCode, string attrlist, string valuelist, string attrvaluelist, decimal price, decimal weight, decimal bigprice, string productImg, string description, string operateid, string clientid)
        {
            lock (SingleLock)
            {
                if (!string.IsNullOrEmpty(productImg))
                {
                    if (productImg.IndexOf("?") > 0)
                    {
                        productImg = productImg.Substring(0, productImg.IndexOf("?"));
                    }
                    FileInfo file = new FileInfo(HttpContext.Current.Server.MapPath(productImg));
                    productImg = FILEPATH + file.Name;
                    if (file.Exists)
                    {
                        file.MoveTo(HttpContext.Current.Server.MapPath(productImg));
                    }
                }
                else
                {
                    productImg = FILEPATH + DateTime.Now.ToString("yyyyMMddHHmmssms") + new Random().Next(1000, 9999).ToString() + ".png";
                }

                var dal = new ProductsDAL();
                return(dal.AddProductDetails(productid, productCode, shapeCode, attrlist, valuelist, attrvaluelist, price, weight, bigprice, productImg, description, operateid, clientid));
            }
        }
Пример #17
0
 public bool DeleteProduct(Product product)
 {
     using (ProductsDAL productsDAL = new ProductsDAL())
     {
         return(productsDAL.DeleteProduct(product));
     }
 }
Пример #18
0
 public bool UpdateProduct(Product product)
 {
     using (ProductsDAL productsDAL = new ProductsDAL())
     {
         return(productsDAL.UpdateProduct(product));
     }
 }
Пример #19
0
        public string AddProductAttr(string attrName, string description, string categoryID, int type, string operateid, string clientid)
        {
            var attrID = Guid.NewGuid().ToString().ToLower();
            var dal    = new ProductsDAL();

            if (dal.AddProductAttr(attrID, attrName, description, categoryID, type, operateid, clientid))
            {
                if (ClientAttrs.ContainsKey(clientid))
                {
                    ClientAttrs[clientid].Add(new ProductAttr()
                    {
                        AttrID       = attrID,
                        AttrName     = attrName,
                        Description  = description,
                        CategoryID   = categoryID,
                        ClientID     = clientid,
                        CreateTime   = DateTime.Now,
                        CreateUserID = operateid,
                        Status       = 1,
                        AttrValues   = new List <AttrValue>()
                    });
                }
                return(attrID);
            }
            return(string.Empty);
        }
Пример #20
0
        public ProductAttr GetProductAttrByID(string attrid, string clientid)
        {
            var list = GetAttrs(clientid);

            if (list.Where(m => m.AttrID == attrid).Count() > 0)
            {
                return(list.Where(m => m.AttrID == attrid).FirstOrDefault());
            }
            var     dal = new ProductsDAL();
            DataSet ds  = dal.GetProductAttrByID(attrid);

            ProductAttr model = new ProductAttr();

            if (ds.Tables.Contains("Attrs") && ds.Tables["Attrs"].Rows.Count > 0)
            {
                model.FillData(ds.Tables["Attrs"].Rows[0]);
                model.AttrValues = new List <AttrValue>();
                foreach (DataRow item in ds.Tables["Values"].Rows)
                {
                    AttrValue attrValue = new AttrValue();
                    attrValue.FillData(item);
                    model.AttrValues.Add(attrValue);
                }
            }

            ClientAttrs[clientid].Add(model);

            return(model);
        }
Пример #21
0
        public IEnumerable <ProductModel> GetProductsByList(int id)
        {
            ProductsDAL dal      = new ProductsDAL();
            var         products = dal.GetAllProductsForList(id);

            return(products);
        }
Пример #22
0
        /// <summary>
        /// 添加产品
        /// </summary>
        /// <param name="productCode">产品编码</param>
        /// <param name="productName">产品名称</param>
        /// <param name="generalName">常用名</param>
        /// <param name="iscombineproduct">是否组合产品</param>
        /// <param name="brandid">品牌ID</param>
        /// <param name="bigunitid">大单位</param>
        /// <param name="smallunitid">小单位</param>
        /// <param name="bigSmallMultiple">大小单位比例</param>
        /// <param name="categoryid">分类ID</param>
        /// <param name="status">状态</param>
        /// <param name="attrlist">属性列表</param>
        /// <param name="valuelist">值列表</param>
        /// <param name="attrvaluelist">属性值键值对</param>
        /// <param name="commonprice">原价</param>
        /// <param name="price">优惠价</param>
        /// <param name="weight">重量</param>
        /// <param name="isnew">是否新品</param>
        /// <param name="isRecommend">是否推荐</param>
        /// <param name="effectiveDays">有效期天数</param>
        /// <param name="discountValue">折扣</param>
        /// <param name="productImg">产品图片</param>
        /// <param name="description">描述</param>
        /// <param name="operateid">操作人</param>
        /// <param name="clientid">客户端ID</param>
        /// <returns></returns>
        public string AddProduct(string productCode, string productName, string generalName, bool iscombineproduct, string brandid, string bigunitid, string smallunitid, int bigSmallMultiple,
                                 string categoryid, int status, string attrlist, string valuelist, string attrvaluelist, decimal commonprice, decimal price, decimal weight, bool isnew,
                                 bool isRecommend, int effectiveDays, decimal discountValue, string productImg, string shapeCode, string description, string operateid, string clientid)
        {
            lock (SingleLock)
            {
                if (!string.IsNullOrEmpty(productImg))
                {
                    if (productImg.IndexOf("?") > 0)
                    {
                        productImg = productImg.Substring(0, productImg.IndexOf("?"));
                    }
                    FileInfo file = new FileInfo(HttpContext.Current.Server.MapPath(productImg));
                    productImg = FILEPATH + file.Name;
                    if (file.Exists)
                    {
                        file.MoveTo(HttpContext.Current.Server.MapPath(productImg));
                    }
                }
                else
                {
                    productImg = FILEPATH + DateTime.Now.ToString("yyyyMMddHHmmssms") + new Random().Next(1000, 9999).ToString() + ".png";
                }

                var dal = new ProductsDAL();
                return(dal.AddProduct(productCode, productName, generalName, iscombineproduct, brandid, bigunitid, smallunitid, bigSmallMultiple, categoryid, status, attrlist,
                                      valuelist, attrvaluelist, commonprice, price, weight, isnew, isRecommend, effectiveDays, discountValue, productImg, shapeCode, description, operateid, clientid));
            }
        }
Пример #23
0
 public List <Product> GetProducts()
 {
     using (ProductsDAL productsDAL = new ProductsDAL())
     {
         return(productsDAL.GetProducts());
     }
 }
Пример #24
0
 public bool UpdateProductDetails(string detailid, string productid, string productCode, string shapeCode, string attrlist, string valuelist, string attrvaluelist, decimal price, decimal weight, string description, string remark, string productImg, string operateid, string clientid)
 {
     lock (SingleLock)
     {
         var dal = new ProductsDAL();
         return(dal.UpdateProductDetails(detailid, productid, productCode, shapeCode, attrlist, valuelist, attrvaluelist, price, weight, description, remark, productImg));
     }
 }
Пример #25
0
        private void PrePopolateWithAllProducts()
        {
            ProductsDAL products = new ProductsDAL();
            DataSet     ds       = products.GetAllProducts();

            gvProductsDisplay.DataSource = ds;
            gvProductsDisplay.DataBind();
        }
Пример #26
0
        private void BindProductionByCategory(string category)
        {
            ProductsDAL products = new ProductsDAL();
            DataSet     ds       = products.GetProductByProductCategory(category);

            gvProductsDisplay.DataSource = ds;
            gvProductsDisplay.DataBind();
        }
Пример #27
0
        public void CheckProductsCount()
        {
            string      connStr = "Data Source=COMPUTER-SQLEXPRESS02;Initial Catalog=KursovaPZ;Integrated Security=True";
            ProductsDAL dal     = new ProductsDAL(connStr);
            int         count   = dal.GetAllProducts().Count;

            Assert.AreEqual(count, 3);
        }
Пример #28
0
        /// <summary>
        /// 编辑产品信息
        /// </summary>
        /// <param name="productid">产品ID</param>
        /// <param name="productCode">产品编码</param>
        /// <param name="productName">产品名称</param>
        /// <param name="generalName">常用名</param>
        /// <param name="iscombineproduct">是否组合产品</param>
        /// <param name="brandid">品牌ID</param>
        /// <param name="bigunitid">大单位</param>
        /// <param name="smallunitid">小单位</param>
        /// <param name="bigSmallMultiple">大小单位比例</param>
        /// <param name="status">状态</param>
        /// <param name="attrlist">属性列表</param>
        /// <param name="valuelist">值列表</param>
        /// <param name="attrvaluelist">属性值键值对</param>
        /// <param name="commonprice">原价</param>
        /// <param name="price">优惠价</param>
        /// <param name="weight">重量</param>
        /// <param name="isnew">是否新品</param>
        /// <param name="isRecommend">是否推荐</param>
        /// <param name="effectiveDays">有效期天数</param>
        /// <param name="discountValue">折扣</param>
        /// <param name="description">描述</param>
        /// <param name="operateid">操作人</param>
        /// <param name="clientid">客户端ID</param>
        /// <returns></returns>
        public bool UpdateProduct(string productid, string productCode, string productName, string generalName, bool iscombineproduct, string brandid, string bigunitid, string smallunitid, int bigSmallMultiple,
                                  int status, string categoryid, string attrlist, string valuelist, string attrvaluelist, decimal commonprice, decimal price, decimal weight, bool isnew,
                                  bool isRecommend, int effectiveDays, decimal discountValue, string shapeCode, string description, string operateid, string clientid)
        {
            var dal = new ProductsDAL();

            return(dal.UpdateProduct(productid, productCode, productName, generalName, iscombineproduct, brandid, bigunitid, smallunitid, bigSmallMultiple, status, categoryid, attrlist,
                                     valuelist, attrvaluelist, commonprice, price, weight, isnew, isRecommend, effectiveDays, discountValue, shapeCode, description, operateid, clientid));
        }
Пример #29
0
        public bool UpdateProduct(string productid, string productCode, string productName, string generalName, string prodiverid, string unitid,
                                  int status, int ispublic, string categoryid, string attrlist, string valuelist, string attrvaluelist, decimal commonprice, decimal price, decimal weight,
                                  int isallow, decimal discountValue, string productImg, string shapeCode, string description, string operateid, string clientid, ref int result)
        {
            var dal = new ProductsDAL();

            return(dal.UpdateProduct(productid, productCode, productName, generalName, prodiverid, unitid, status, ispublic, categoryid, attrlist,
                                     valuelist, attrvaluelist, commonprice, price, weight, isallow, discountValue, productImg, shapeCode, description, operateid, clientid, ref result));
        }
Пример #30
0
        public bool UpdateUnit(string unitID, string unitName, string desciption, string operateID)
        {
            var       dal     = new ProductsDAL();
            DataTable dt      = dal.GetUnitByUnitID(unitID);
            string    message = "单位名称“" + dt.Rows[0]["unitName"].ToString() + "”变更为“" + unitName + "”;描述“" + dt.Rows[0]["Description"].ToString() + "”变更为“" + desciption + "”";

            LogBusiness.AddOperateLog(operateID, "ProductsBusiness.UpdateUnit", EnumLogType.Update, EnumLogModules.Stock, EnumLogEntity.ProductUnit, unitID, message, "");
            return(dal.UpdateUnit(unitID, unitName, desciption));
        }