コード例 #1
0
ファイル: ProductBase.cs プロジェクト: locbet/stevenfolder
        public bool Insert(ProductInfo productInfo)
        {
            StringBuilder sql=new StringBuilder();
            sql.Append("INSERT INTO");
            sql.Append(" [Tbl_Product](");
            sql.Append("[ProductNO],");
            sql.Append("[CateIDPath],");
            sql.Append("[NickName],");
            sql.Append("[ProductName],");
            sql.Append("[MarketPrice],");
            sql.Append("[InnerPrice],");
            sql.Append("[BrandID],");
            sql.Append("[BrandName]");
            sql.Append(") VALUES(");
            sql.Append("@ProductNO,");
            sql.Append("@CateIDPath,");
            sql.Append("@NickName,");
            sql.Append("@ProductName,");
            sql.Append("@MarketPrice,");
            sql.Append("@InnerPrice,");
            sql.Append("@BrandID,");
            sql.Append("@BrandName");
            sql.Append(")");

            using(NetShopHelper dbhelper=new NetShopHelper())
            {
                IDbDataParameter[] p_Parms=new IDbDataParameter[]{
                    dbhelper.CreateParameter("@ProductNO",productInfo.ProductNO),
                    dbhelper.CreateParameter("@CateIDPath",productInfo.CateIDPath),
                    dbhelper.CreateParameter("@NickName",productInfo.NickName),
                    dbhelper.CreateParameter("@ProductName",productInfo.ProductName),
                    dbhelper.CreateParameter("@MarketPrice",productInfo.MarketPrice),
                    dbhelper.CreateParameter("@InnerPrice",productInfo.InnerPrice),
                    dbhelper.CreateParameter("@BrandID",productInfo.BrandID),
                    dbhelper.CreateParameter("@BrandName",productInfo.BrandName)
                };
            return 0 < dbhelper.ExecuteNonQuery(sql.ToString(),p_Parms);
            }
        }
コード例 #2
0
ファイル: ProductBase.cs プロジェクト: locbet/stevenfolder
 public bool Update(ProductInfo productInfo)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("UPDATE");
     sql.Append(" [Tbl_Product]");
     sql.Append(" SET");
     sql.Append(" [CateIDPath]=@CateIDPath,");
     sql.Append(" [NickName]=@NickName,");
     sql.Append(" [ProductName]=@ProductName,");
     sql.Append(" [MarketPrice]=@MarketPrice,");
     sql.Append(" [InnerPrice]=@InnerPrice,");
     sql.Append(" [BrandID]=@BrandID,");
     sql.Append(" [BrandName]=@BrandName");
     sql.Append(" WHERE");
     sql.Append(" [ProductNO]=@ProductNO");
     using(NetShopHelper dbhelper=new NetShopHelper())
     {
       IDbDataParameter[] p_Parms = new IDbDataParameter[]{
         dbhelper.CreateParameter("@ProductNO",productInfo.ProductNO)
       };
      return 0 < dbhelper.ExecuteNonQuery(sql.ToString(),p_Parms);
     }
 }
コード例 #3
0
ファイル: ProductInfo.cs プロジェクト: locbet/stevenfolder
        /// <summary>
        /// Convert IDataReader To ProductInfo
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static ProductInfo SetValue(IDataReader reader)
        {
            ProductInfo info = new ProductInfo();

            int productNOIndex = reader.GetOrdinal("ProductNO");
            int cateIDPathIndex = reader.GetOrdinal("CateIDPath");
            int nickNameIndex = reader.GetOrdinal("NickName");
            int productNameIndex = reader.GetOrdinal("ProductName");
            int marketPriceIndex = reader.GetOrdinal("MarketPrice");
            int innerPriceIndex = reader.GetOrdinal("InnerPrice");
            int brandIDIndex = reader.GetOrdinal("BrandID");
            int brandNameIndex = reader.GetOrdinal("BrandName");

            info.ProductNO = reader.GetString(productNOIndex);
            info.CateIDPath = reader.GetString(cateIDPathIndex);
            info.NickName = reader.GetString(nickNameIndex);
            info.ProductName = reader.GetString(productNameIndex);
            info.MarketPrice = reader.GetDecimal(marketPriceIndex);
            info.InnerPrice = reader.GetDecimal(innerPriceIndex);
            info.BrandID = reader.GetInt32(brandIDIndex);
            info.BrandName = reader.GetString(brandNameIndex);

            return info;
        }