Beispiel #1
0
        /// <summary>
        /// Convert IDataReader To ProductAttrInfo
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static ProductAttrInfo SetValue(IDataReader reader)
        {
            ProductAttrInfo info = new ProductAttrInfo();

            int attrIDIndex = reader.GetOrdinal("AttrID");
            int cateIDIndex = reader.GetOrdinal("CateID");
            int attrNameIndex = reader.GetOrdinal("AttrName");

            info.AttrID = reader.GetInt32(attrIDIndex);
            info.CateID = reader.GetInt32(cateIDIndex);
            info.AttrName = reader.GetString(attrNameIndex);

            return info;
        }
Beispiel #2
0
        public bool Insert(ProductAttrInfo productAttrInfo)
        {
            StringBuilder sql=new StringBuilder();
            sql.Append("INSERT INTO");
            sql.Append(" [Tbl_ProductAttr](");
            sql.Append("[CateID],");
            sql.Append("[AttrName]");
            sql.Append(") VALUES(");
            sql.Append("@CateID,");
            sql.Append("@AttrName");
            sql.Append(");SELECT @@IDENTITY;");

            using(NetShopHelper dbhelper=new NetShopHelper())
            {
                IDbDataParameter[] p_Parms=new IDbDataParameter[]{
                    dbhelper.CreateParameter("@CateID",productAttrInfo.CateID),
                    dbhelper.CreateParameter("@AttrName",productAttrInfo.AttrName)
                };
            int ret=(int)dbhelper.ExecuteScalar(sql.ToString(),p_Parms);
            productAttrInfo.AttrID=ret;
            return true;
            }
        }
Beispiel #3
0
 public bool Update(ProductAttrInfo productAttrInfo)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("UPDATE");
     sql.Append(" [Tbl_ProductAttr]");
     sql.Append(" SET");
     sql.Append(" [CateID]=@CateID,");
     sql.Append(" [AttrName]=@AttrName");
     sql.Append(" WHERE");
     sql.Append(" [AttrID]=@AttrID");
     using(NetShopHelper dbhelper=new NetShopHelper())
     {
       IDbDataParameter[] p_Parms = new IDbDataParameter[]{
         dbhelper.CreateParameter("@AttrID",productAttrInfo.AttrID)
       };
      return 0 < dbhelper.ExecuteNonQuery(sql.ToString(),p_Parms);
     }
 }