Beispiel #1
0
        public bool Insert(PriceLevelInfo priceLevelInfo)
        {
            StringBuilder sql=new StringBuilder();
            sql.Append("INSERT INTO");
            sql.Append(" [Tbl_PriceLevel](");
            sql.Append("[CateID],");
            sql.Append("[NickName],");
            sql.Append("[StartPrice],");
            sql.Append("[EndPrice],");
            sql.Append("[OrderID]");
            sql.Append(") VALUES(");
            sql.Append("@CateID,");
            sql.Append("@NickName,");
            sql.Append("@StartPrice,");
            sql.Append("@EndPrice,");
            sql.Append("@OrderID");
            sql.Append(");SELECT @@IDENTITY;");

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

            int idIndex = reader.GetOrdinal("ID");
            int cateIDIndex = reader.GetOrdinal("CateID");
            int nickNameIndex = reader.GetOrdinal("NickName");
            int startPriceIndex = reader.GetOrdinal("StartPrice");
            int endPriceIndex = reader.GetOrdinal("EndPrice");
            int orderIDIndex = reader.GetOrdinal("OrderID");

            info.Id = reader.GetInt32(idIndex);
            info.CateID = reader.GetInt32(cateIDIndex);
            info.NickName = reader.GetString(nickNameIndex);
            info.StartPrice = reader.GetInt32(startPriceIndex);
            info.EndPrice = reader.GetInt32(endPriceIndex);
            info.OrderID = reader.GetInt32(orderIDIndex);

            return info;
        }
Beispiel #3
0
 public bool Update(PriceLevelInfo priceLevelInfo)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("UPDATE");
     sql.Append(" [Tbl_PriceLevel]");
     sql.Append(" SET");
     sql.Append(" [CateID][email protected],");
     sql.Append(" [NickName][email protected],");
     sql.Append(" [StartPrice][email protected],");
     sql.Append(" [EndPrice][email protected],");
     sql.Append(" [OrderID][email protected]");
     sql.Append(" WHERE");
     sql.Append(" [ID][email protected]");
     using(NetShopHelper dbhelper=new NetShopHelper())
     {
       IDbDataParameter[] p_Parms = new IDbDataParameter[]{
         dbhelper.CreateParameter("@ID",priceLevelInfo.Id)
       };
      return 0 < dbhelper.ExecuteNonQuery(sql.ToString(),p_Parms);
     }
 }