コード例 #1
0
        public static ShipGatewayCollection LoadForStore(int maximumRows, int startRowIndex, string sortExpression)
        {
            int storeId = Token.Instance.StoreId;
            //CREATE THE DYNAMIC SQL TO LOAD OBJECT
            StringBuilder selectQuery = new StringBuilder();

            selectQuery.Append("SELECT");
            if (maximumRows > 0)
            {
                selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString());
            }
            selectQuery.Append(" " + ShipGateway.GetColumnNames(string.Empty));
            selectQuery.Append(" FROM ac_ShipGateways");
            selectQuery.Append(" WHERE StoreId = @storeId");
            if (!string.IsNullOrEmpty(sortExpression))
            {
                selectQuery.Append(" ORDER BY " + sortExpression);
            }
            Database  database      = Token.Instance.Database;
            DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString());

            database.AddInParameter(selectCommand, "@storeId", System.Data.DbType.Int32, storeId);
            //EXECUTE THE COMMAND
            ShipGatewayCollection results = new ShipGatewayCollection();
            int thisIndex = 0;
            int rowCount  = 0;

            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows)))
                {
                    if (thisIndex >= startRowIndex)
                    {
                        ShipGateway shipGateway = new ShipGateway();
                        ShipGateway.LoadDataReader(shipGateway, dr);
                        results.Add(shipGateway);
                        rowCount++;
                    }
                    thisIndex++;
                }
                dr.Close();
            }
            return(results);
        }
コード例 #2
0
        public static ShipGatewayCollection LoadForClassId(string classId)
        {
            ShipGatewayCollection ShipGateways = new ShipGatewayCollection();
            Database  database      = Token.Instance.Database;
            DbCommand selectCommand = database.GetSqlStringCommand("SELECT " + ShipGateway.GetColumnNames(string.Empty) + "  FROM ac_ShipGateways WHERE StoreId=@storeId AND ClassId=@classId");

            database.AddInParameter(selectCommand, "@storeId", DbType.Int32, Token.Instance.StoreId);
            database.AddInParameter(selectCommand, "@classId", DbType.String, classId);
            //EXECUTE THE COMMAND
            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                while (dr.Read())
                {
                    ShipGateway shipGateway = new ShipGateway();
                    ShipGateway.LoadDataReader(shipGateway, dr);
                    ShipGateways.Add(shipGateway);
                }
                dr.Close();
            }
            return(ShipGateways);
        }