Example #1
0
        public bool Insert(BrandInfo brandInfo)
        {
            StringBuilder sql=new StringBuilder();
            sql.Append("INSERT INTO");
            sql.Append(" [Tbl_Brand](");
            sql.Append("[CateID],");
            sql.Append("[NickName],");
            sql.Append("[BrandName],");
            sql.Append("[OrderID]");
            sql.Append(") VALUES(");
            sql.Append("@CateID,");
            sql.Append("@NickName,");
            sql.Append("@BrandName,");
            sql.Append("@OrderID");
            sql.Append(");SELECT @@IDENTITY;");

            using(NetShopHelper dbhelper=new NetShopHelper())
            {
                IDbDataParameter[] p_Parms=new IDbDataParameter[]{
                    dbhelper.CreateParameter("@CateID",brandInfo.CateID),
                    dbhelper.CreateParameter("@NickName",brandInfo.NickName),
                    dbhelper.CreateParameter("@BrandName",brandInfo.BrandName),
                    dbhelper.CreateParameter("@OrderID",brandInfo.OrderID)
                };
            int ret=(int)dbhelper.ExecuteScalar(sql.ToString(),p_Parms);
            brandInfo.Id=ret;
            return true;
            }
        }
Example #2
0
        /// <summary>
        /// Convert IDataReader To BrandInfo
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static BrandInfo SetValue(IDataReader reader)
        {
            BrandInfo info = new BrandInfo();

            int idIndex = reader.GetOrdinal("ID");
            int cateIDIndex = reader.GetOrdinal("CateID");
            int nickNameIndex = reader.GetOrdinal("NickName");
            int brandNameIndex = reader.GetOrdinal("BrandName");
            int orderIDIndex = reader.GetOrdinal("OrderID");

            info.Id = reader.GetInt32(idIndex);
            info.CateID = reader.GetInt32(cateIDIndex);
            info.NickName = reader.GetString(nickNameIndex);
            info.BrandName = reader.GetString(brandNameIndex);
            info.OrderID = reader.GetInt32(orderIDIndex);

            return info;
        }
Example #3
0
 public bool Update(BrandInfo brandInfo)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("UPDATE");
     sql.Append(" [Tbl_Brand]");
     sql.Append(" SET");
     sql.Append(" [CateID]=@CateID,");
     sql.Append(" [NickName]=@NickName,");
     sql.Append(" [BrandName]=@BrandName,");
     sql.Append(" [OrderID]=@OrderID");
     sql.Append(" WHERE");
     sql.Append(" [ID]=@ID");
     using(NetShopHelper dbhelper=new NetShopHelper())
     {
       IDbDataParameter[] p_Parms = new IDbDataParameter[]{
         dbhelper.CreateParameter("@ID",brandInfo.Id)
       };
      return 0 < dbhelper.ExecuteNonQuery(sql.ToString(),p_Parms);
     }
 }