Esempio n. 1
0
        public bool Insert(ProductCommentInfo productCommentInfo)
        {
            StringBuilder sql=new StringBuilder();
            sql.Append("INSERT INTO");
            sql.Append(" [Tbl_ProductComment](");
            sql.Append("[ProductNO],");
            sql.Append("[Title],");
            sql.Append("[Merits],");
            sql.Append("[Demerits],");
            sql.Append("[Summary],");
            sql.Append("[Star],");
            sql.Append("[ReplyCount]");
            sql.Append(") VALUES(");
            sql.Append("@ProductNO,");
            sql.Append("@Title,");
            sql.Append("@Merits,");
            sql.Append("@Demerits,");
            sql.Append("@Summary,");
            sql.Append("@Star,");
            sql.Append("@ReplyCount");
            sql.Append(");SELECT @@IDENTITY;");

            using(NetShopHelper dbhelper=new NetShopHelper())
            {
                IDbDataParameter[] p_Parms=new IDbDataParameter[]{
                    dbhelper.CreateParameter("@ProductNO",productCommentInfo.ProductNO),
                    dbhelper.CreateParameter("@Title",productCommentInfo.Title),
                    dbhelper.CreateParameter("@Merits",productCommentInfo.Merits),
                    dbhelper.CreateParameter("@Demerits",productCommentInfo.Demerits),
                    dbhelper.CreateParameter("@Summary",productCommentInfo.Summary),
                    dbhelper.CreateParameter("@Star",productCommentInfo.Star),
                    dbhelper.CreateParameter("@ReplyCount",productCommentInfo.ReplyCount)
                };
            int ret=(int)dbhelper.ExecuteScalar(sql.ToString(),p_Parms);
            productCommentInfo.Id=ret;
            return true;
            }
        }
Esempio n. 2
0
 public bool Update(ProductCommentInfo productCommentInfo)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("UPDATE");
     sql.Append(" [Tbl_ProductComment]");
     sql.Append(" SET");
     sql.Append(" [ProductNO]=@ProductNO,");
     sql.Append(" [Title]=@Title,");
     sql.Append(" [Merits]=@Merits,");
     sql.Append(" [Demerits]=@Demerits,");
     sql.Append(" [Summary]=@Summary,");
     sql.Append(" [Star]=@Star,");
     sql.Append(" [ReplyCount]=@ReplyCount");
     sql.Append(" WHERE");
     sql.Append(" [ID]=@ID");
     using(NetShopHelper dbhelper=new NetShopHelper())
     {
       IDbDataParameter[] p_Parms = new IDbDataParameter[]{
         dbhelper.CreateParameter("@ID",productCommentInfo.Id)
       };
      return 0 < dbhelper.ExecuteNonQuery(sql.ToString(),p_Parms);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Convert IDataReader To ProductCommentInfo
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static ProductCommentInfo SetValue(IDataReader reader)
        {
            ProductCommentInfo info = new ProductCommentInfo();

            int idIndex = reader.GetOrdinal("ID");
            int productNOIndex = reader.GetOrdinal("ProductNO");
            int titleIndex = reader.GetOrdinal("Title");
            int meritsIndex = reader.GetOrdinal("Merits");
            int demeritsIndex = reader.GetOrdinal("Demerits");
            int summaryIndex = reader.GetOrdinal("Summary");
            int starIndex = reader.GetOrdinal("Star");
            int replyCountIndex = reader.GetOrdinal("ReplyCount");

            info.Id = reader.GetInt32(idIndex);
            info.ProductNO = reader.GetString(productNOIndex);
            info.Title = reader.GetString(titleIndex);
            info.Merits = reader.GetString(meritsIndex);
            info.Demerits = reader.GetString(demeritsIndex);
            info.Summary = reader.GetString(summaryIndex);
            info.Star = reader.GetInt32(starIndex);
            info.ReplyCount = reader.GetInt32(replyCountIndex);

            return info;
        }