⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 product.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
📖 第 1 页 / 共 3 页
字号:
                            if (productInfo.Stocks < amount)
                            {
                                stocks = productInfo.Stocks;
                            }
                        }
                        else
                        {
                            ProductDataInfo info = ProductData.GetProductDataByPropertyValue(productInfo.ProductId, productInfo.TableName, propertyValue);
                            if (!info.IsNull && (info.Stocks < amount))
                            {
                                stocks = info.Stocks;
                            }
                        }
                    }
                    else if (string.IsNullOrEmpty(propertyValue))
                    {
                        if ((productInfo.Stocks - productInfo.OrderNum) < amount)
                        {
                            stocks = productInfo.Stocks - productInfo.OrderNum;
                        }
                    }
                    else
                    {
                        ProductDataInfo info2 = ProductData.GetProductDataByPropertyValue(productInfo.ProductId, productInfo.TableName, propertyValue);
                        if (!info2.IsNull && ((info2.Stocks - info2.OrderNum) < amount))
                        {
                            stocks = info2.Stocks - info2.OrderNum;
                        }
                    }
                    if (stocks != amount)
                    {
                        str = string.Concat(new object[] { "您订购了", amount, productInfo.Unit, productInfo.ProductName, ",而此商品目前只有", stocks, productInfo.Unit, ",请重新调整您的购物车!" });
                    }
                }
                if ((productInfo.LimitNum > 0) && (stocks > productInfo.LimitNum))
                {
                    str = string.Concat(new object[] { "您订购了", amount, productInfo.Unit, productInfo.ProductName, ",而此商品每人最多限购", productInfo.LimitNum, productInfo.Unit, ",请重新调整您的购物车!" });
                }
            }
            return str;
        }

        public static bool Delete(string generalIdList)
        {
            return (DataValidator.IsValidId(generalIdList) && dal.Delete(generalIdList));
        }

        private static void DoHtmlDecode(ProductInfo info)
        {
            info.Keyword = DataSecurity.HtmlDecode(info.Keyword);
            info.ProducerName = DataSecurity.HtmlDecode(info.ProducerName);
            info.ProductIntro = DataSecurity.HtmlDecode(info.ProductIntro);
            info.ProductName = DataSecurity.HtmlDecode(info.ProductName);
            info.ProductNum = DataSecurity.HtmlDecode(info.ProductNum);
            info.ProductPic = DataSecurity.HtmlDecode(info.ProductPic);
            info.ProductThumb = DataSecurity.HtmlDecode(info.ProductThumb);
            info.Remark = DataSecurity.HtmlDecode(info.Remark);
            info.TrademarkName = DataSecurity.HtmlDecode(info.TrademarkName);
            info.Unit = DataSecurity.HtmlDecode(info.Unit);
            info.BarCode = DataSecurity.HtmlDecode(info.BarCode);
        }

        private static void DoHtmlEncode(ProductInfo info)
        {
            info.Keyword = DataSecurity.HtmlEncode(info.Keyword);
            info.ProducerName = DataSecurity.HtmlEncode(info.ProducerName);
            info.ProductExplain = StringHelper.RemoveXss(info.ProductExplain);
            info.ProductIntro = DataSecurity.HtmlEncode(info.ProductIntro);
            info.ProductName = DataSecurity.HtmlEncode(info.ProductName);
            info.ProductNum = DataSecurity.HtmlEncode(info.ProductNum);
            info.ProductPic = DataSecurity.HtmlEncode(info.ProductPic);
            info.ProductThumb = DataSecurity.HtmlEncode(info.ProductThumb);
            info.Remark = DataSecurity.HtmlEncode(info.Remark);
            info.TrademarkName = DataSecurity.HtmlEncode(info.TrademarkName);
            info.Unit = DataSecurity.HtmlEncode(info.Unit);
            info.BarCode = DataSecurity.HtmlEncode(info.BarCode);
        }

        public static bool ExistsPresent(int presentId)
        {
            return ProductCommon.ExistsPresent(presentId);
        }

        private static DataTable GetDataTableFromModel(int modelId, int specialId, int nodeId)
        {
            DataTable dataTable = new DataTable();
            dataTable.Columns.Add("FieldName");
            dataTable.Columns.Add("FieldValue");
            dataTable.Columns.Add("FieldType");
            dataTable.Columns.Add("FieldLevel");
            foreach (FieldInfo info in Field.GetFieldList(modelId, false))
            {
                if (info.FieldType != FieldType.Property)
                {
                    AddNewRows(dataTable, info.FieldName, string.IsNullOrEmpty(info.DefaultValue) ? "" : info.DefaultValue, info.FieldType, info.FieldLevel);
                }
            }
            AddNewRows(dataTable, "DayHits", "0", FieldType.NumberType, 0);
            AddNewRows(dataTable, "EliteLevel", "0", FieldType.NumberType, 0);
            AddNewRows(dataTable, "Hits", "0", FieldType.NumberType, 0);
            AddNewRows(dataTable, "Priority", "0", FieldType.NumberType, 0);
            AddNewRows(dataTable, "WeekHits", "0", FieldType.NumberType, 0);
            AddNewRows(dataTable, "MonthHits", "0", FieldType.NumberType, 0);
            AddNewRows(dataTable, "UpdateTime", DateTime.Now.ToString(), FieldType.DateTimeType, 0);
            AddNewRows(dataTable, "TemplateFile", "", FieldType.TemplateType, 0);
            AddNewRows(dataTable, "SpecialId", specialId.ToString(), FieldType.SpecialType, 0);
            AddNewRows(dataTable, "InfoId", "", FieldType.InfoType, 0);
            AddNewRows(dataTable, "NodeId", nodeId.ToString(), FieldType.NodeType, 0);
            AddNewRows(dataTable, "Inputer", PEContext.Current.Admin.AdminName, FieldType.TextType, 0);
            AddNewRows(dataTable, "Status", "90", FieldType.StatusType, 0);
            return dataTable;
        }

        public static ArrayList GetExcelFields(string excelSource)
        {
            ArrayList list = new ArrayList();
            list.Add("不导入此项");
            OleDbConnection selectConnection = new OleDbConnection(("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + excelSource + "") + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"");
            OleDbDataAdapter adapter = new OleDbDataAdapter("select * from [sheet1$]", selectConnection);
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet, "ss");
            for (int i = 0; i < dataSet.Tables[0].Columns.Count; i++)
            {
                list.Add(dataSet.Tables[0].Columns[i].ColumnName);
            }
            return list;
        }

        private static string GetExcelFieldValue(DataRow rows, DataTable dtField, string fieldName, string defaultValue)
        {
            string str = defaultValue;
            string strB = "不导入此项";
            DataRow[] rowArray = dtField.Select("FieldName='" + fieldName + "'");
            if (rowArray.Length != 0)
            {
                strB = rowArray[0][0].ToString();
            }
            if (string.Compare("不导入此项", strB) != 0)
            {
                str = rows[strB].ToString();
            }
            return str;
        }

        private static int GetNewProductId()
        {
            return dal.GetNewProductId();
        }

        public void GetProductAllDataById(int generalId)
        {
            PowerEasy.Model.Contents.CommonModelInfo commonModelInfoById = ContentManage.GetCommonModelInfoById(generalId);
            if (!commonModelInfoById.IsNull)
            {
                this.m_CommonModelInfo = commonModelInfoById;
                this.m_ProductInfoData = GetProductById(generalId, commonModelInfoById.ItemId, commonModelInfoById.TableName);
            }
        }

        public void GetProductAllDataById(int productId, string tableName)
        {
            if ((productId > 0) && !string.IsNullOrEmpty(tableName))
            {
                tableName = DataSecurity.FilterBadChar(tableName);
                this.m_ProductInfoData = GetProductById(productId, tableName);
            }
        }

        public static ProductInfo GetProductById(int id)
        {
            return dal.GetProductById(id);
        }

        public static ProductInfo GetProductById(int id, bool doDecode)
        {
            ProductInfo productById = GetProductById(id);
            if (doDecode)
            {
                DoHtmlDecode(productById);
            }
            return productById;
        }

        public static ProductInfo GetProductById(int productId, string tableName)
        {
            if (string.IsNullOrEmpty(tableName))
            {
                return new ProductInfo(true);
            }
            tableName = DataSecurity.FilterBadChar(tableName);
            return dal.GetProductById(productId, tableName);
        }

        private static ProductInfo GetProductById(int generalId, int productId, string tableName)
        {
            return dal.GetProductById(generalId, productId, tableName);
        }

        public static ProductInfo GetProductById(int productId, string tableName, bool doDecode)
        {
            ProductInfo productById = GetProductById(productId, tableName);
            if (doDecode)
            {
                DoHtmlDecode(productById);
            }
            return productById;
        }

        public static IList<ProductInfo> GetProductCommonListByCharacter(ProductCharacter productCharacter)
        {
            return ProductCommon.GetProductCommonListByCharacter(productCharacter);
        }

        public ProductInfo GetProductInfo(bool doDecode)
        {
            if (this.m_ProductInfoData == null)
            {
                this.m_ProductInfoData = new ProductInfo(true);
            }
            if (doDecode)
            {
                DoHtmlDecode(this.m_ProductInfoData);
            }
            return this.m_ProductInfoData;
        }

        public static ProductInfo GetProductInfo(int productId, string tableName, ProductType productType)
        {
            return ProductCommon.GetProductInfoByType(productId, tableName, productType);
        }

        public static IList<ProductInfo> GetProductInfoList(int startRowIndexId, int maxNumberRows, string searchProductName, string productTypeList)
        {
            return GetProductInfoList(0, startRowIndexId, maxNumberRows, searchProductName, productTypeList);
        }

        public static IList<ProductInfo> GetProductInfoList(int modelId, int startRowIndexId, int maxNumberRows, string searchProductName, string productTypeList)
        {
            IList<ProductInfo> list = new List<ProductInfo>();
            string tableName = string.Empty;
            if (modelId > 0)
            {
                ModelInfo modelInfoById = ModelManager.GetModelInfoById(modelId);
                if (modelInfoById.IsNull)
                {
                    return list;
                }
                if (string.IsNullOrEmpty(modelInfoById.TableName))
                {
                    return list;
                }
                tableName = modelInfoById.TableName;
            }
            if (!DataValidator.IsValidId(productTypeList))
            {
                return list;
            }
            return dal.GetProductInfoList(startRowIndexId, maxNumberRows, tableName, DataSecurity.FilterBadChar(searchProductName), productTypeList);
        }

        public static DataTable GetProductList(string productIdList)
        {
            string[] strArray = productIdList.Split(new char[] { ',' });
            DataTable table = new DataTable();
            table.Columns.Add("ProductId");
            table.Columns.Add("ProductName");
            foreach (string str in strArray)
            {
                string[] strArray2 = str.Split(new char[] { '|' });
                if (strArray2.Length > 0)
                {
                    int productId = DataConverter.CLng(strArray2[0]);
                    string tableName = DataSecurity.FilterBadChar(strArray2[1]);
                    string productName = dal.GetProductName(productId, tableName);
                    if (productName != null)
                    {
                        DataRow row = table.NewRow();
                        row["ProductId"] = productId + "|" + tableName;
                        row["ProductName"] = productName;
                        table.Rows.Add(row);
                    }
                }
            }
            return table;
        }

        public static IDictionary<int, string> GetProductList(int modelId, string productIdList)
        {
            if (!DataValidator.IsValidId(productIdList))
            {
                return null;
            }
            return dal.GetProductList(modelId, productIdList);
        }

        public static IDictionary<int, string> GetProductList(int modelId, int searchType, string keyword, string keyword2)
        {
            if (searchType == 1)
            {
                DataSecurity.FilterBadChar(keyword);
            }
            return dal.GetProductList(modelId, searchType, keyword, keyword2);
        }

        public static IList<string> GetProductPropertiesList(IList<string> attrList)
        {
            return GetProductPropertiesList(attrList, null);
        }

        public static IList<string> GetProductPropertiesList(string properties)
        {
            return GetProductPropertiesList(properties, null);
        }

        public static IList<string> GetProductPropertiesList(IList<string> attrList, char? splitor)
        {
            if (!splitor.HasValue)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -